From ac7fe4475ccfc8acb3e8755b3ee1e8e35a38bc4f Mon Sep 17 00:00:00 2001 From: Dav999 Date: Wed, 13 Sep 2023 18:25:16 +0200 Subject: [PATCH] Remove more tele/quick variables duplicating info in struct Summary For both `tele` and `quick`, I removed these attributes of class Game: - std::string *_gametime - int *_trinkets - std::string *_currentarea - bool *_crewstats[numcrew] All this info can now be gotten from members of Game::last_telesave and Game::last_telesave. I've also cleaned up the continue menu to not have all the display code appear twice (once for telesave and once for quicksave). RIP "Error! Error!" though lol --- desktop_version/src/Game.cpp | 27 --------------- desktop_version/src/Game.h | 11 ------- desktop_version/src/Render.cpp | 60 +++++++++++++++++----------------- 3 files changed, 30 insertions(+), 68 deletions(-) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index fb99596c..3f41372f 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -225,8 +225,6 @@ void Game::init(void) SDL_memset(crewstats, false, sizeof(crewstats)); SDL_memset(ndmresultcrewstats, false, sizeof(ndmresultcrewstats)); - SDL_memset(tele_crewstats, false, sizeof(tele_crewstats)); - SDL_memset(quick_crewstats, false, sizeof(quick_crewstats)); SDL_memset(besttimes, -1, sizeof(besttimes)); SDL_memset(bestframes, -1, sizeof(bestframes)); SDL_memset(besttrinkets, -1, sizeof(besttrinkets)); @@ -236,13 +234,6 @@ void Game::init(void) crewstats[0] = true; lastsaved = 0; - tele_gametime = "00:00"; - tele_trinkets = 0; - tele_currentarea = "Error! Error!"; - quick_gametime = "00:00"; - quick_trinkets = 0; - quick_currentarea = "Error! Error!"; - //Menu stuff initiliased here: SDL_memset(unlock, false, sizeof(unlock)); SDL_memset(unlocknotify, false, sizeof(unlock)); @@ -5629,29 +5620,11 @@ void Game::loadsummary(void) if (FILESYSTEM_loadTiXml2Document("saves/tsave.vvv", doc)) { loadthissummary("tsave.vvv", &last_telesave, doc); - - tele_gametime = giventimestring( - last_telesave.hours, - last_telesave.minutes, - last_telesave.seconds - ); - tele_currentarea = map.currentarea(last_telesave.saverx, last_telesave.savery); - SDL_memcpy(tele_crewstats, last_telesave.crewstats, sizeof(tele_crewstats)); - tele_trinkets = last_telesave.trinkets; } if (FILESYSTEM_loadTiXml2Document("saves/qsave.vvv", doc)) { loadthissummary("qsave.vvv", &last_quicksave, doc); - - quick_gametime = giventimestring( - last_quicksave.hours, - last_quicksave.minutes, - last_quicksave.seconds - ); - quick_currentarea = map.currentarea(last_quicksave.saverx, last_quicksave.savery); - SDL_memcpy(quick_crewstats, last_quicksave.crewstats, sizeof(quick_crewstats)); - quick_trinkets = last_quicksave.trinkets; } } diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index fe162807..d81c7762 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -457,10 +457,6 @@ public: int alarmdelay; bool blackout; - bool tele_crewstats[numcrew]; - - bool quick_crewstats[numcrew]; - static const int numunlock = 25; bool unlock[numunlock]; bool unlocknotify[numunlock]; @@ -476,13 +472,6 @@ public: int bestlives[numtrials]; int bestrank[numtrials]; - std::string tele_gametime; - int tele_trinkets; - std::string tele_currentarea; - std::string quick_gametime; - int quick_trinkets; - std::string quick_currentarea; - int screenshake, flashlight; bool advancetext, pausescript; diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index 53f29367..224aff1a 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -1259,58 +1259,58 @@ static void menurender(void) font::print_wrap(PR_CEN, -1, 75, loc::gettext("Are you sure you want to quit?"), tr, tg, tb); break; case Menu::continuemenu: + { + const char* title = NULL; + struct Game::Summary* summary = NULL; + switch (game.currentmenuoption) { case 0: - { - //Show teleporter save info - graphics.drawpixeltextbox(17, 65-20, 286, 90, 65, 185, 207); - - font::print(PR_2X | PR_CEN, -1, 20, loc::gettext("Tele Save"), tr, tg, tb); - font::print(PR_CEN, -1, 80-20, game.tele_currentarea, 25, 255 - (help.glow / 2), 255 - (help.glow / 2)); - for (int i = 0; i < 6; i++) - { - graphics.drawcrewman(169-(3*42)+(i*42), 95-20, i, game.tele_crewstats[i], true); - } - font::print(0, 59, 132-20, game.tele_gametime, 255 - (help.glow / 2), 255 - (help.glow / 2), 255 - (help.glow / 2)); - char buffer[SCREEN_WIDTH_CHARS + 1]; - vformat_buf(buffer, sizeof(buffer), - loc::gettext("{savebox_n_trinkets|wordy}"), - "savebox_n_trinkets:int", - game.tele_trinkets - ); - font::print(PR_RIGHT, 262, 132-20, buffer, 255 - (help.glow / 2), 255 - (help.glow / 2), 255 - (help.glow / 2)); - - graphics.draw_sprite(34, 126-20, 50, graphics.col_clock); - graphics.draw_sprite(270, 126-20, 22, graphics.col_trinket); + title = loc::gettext("Tele Save"); + summary = &game.last_telesave; break; - } case 1: + title = loc::gettext("Quick Save"); + summary = &game.last_quicksave; + break; + } + + if (summary != NULL) { - //Show quick save info graphics.drawpixeltextbox(17, 65-20, 286, 90, 65, 185, 207); - font::print(PR_2X | PR_CEN, -1, 20, loc::gettext("Quick Save"), tr, tg, tb); - font::print(PR_CEN, -1, 80-20, game.quick_currentarea, 25, 255 - (help.glow / 2), 255 - (help.glow / 2)); + font::print(PR_2X | PR_CEN, -1, 20, title, tr, tg, tb); + font::print( + PR_CEN, -1, 80-20, + map.currentarea(summary->saverx, summary->savery), + 25, 255 - (help.glow / 2), 255 - (help.glow / 2) + ); for (int i = 0; i < 6; i++) { - graphics.drawcrewman(169-(3*42)+(i*42), 95-20, i, game.quick_crewstats[i], true); + graphics.drawcrewman(169-(3*42)+(i*42), 95-20, i, summary->crewstats[i], true); } - font::print(0, 59, 132-20, game.quick_gametime, 255 - (help.glow / 2), 255 - (help.glow / 2), 255 - (help.glow / 2)); + font::print( + 0, 59, 132-20, + game.giventimestring( + summary->hours, + summary->minutes, + summary->seconds + ), + 255 - (help.glow / 2), 255 - (help.glow / 2), 255 - (help.glow / 2) + ); char buffer[SCREEN_WIDTH_CHARS + 1]; vformat_buf(buffer, sizeof(buffer), loc::gettext("{savebox_n_trinkets|wordy}"), "savebox_n_trinkets:int", - game.quick_trinkets + summary->trinkets ); font::print(PR_RIGHT, 262, 132-20, buffer, 255 - (help.glow / 2), 255 - (help.glow / 2), 255 - (help.glow / 2)); graphics.draw_sprite(34, 126-20, 50, graphics.col_clock); graphics.draw_sprite(270, 126-20, 22, graphics.col_trinket); - break; - } } break; + } case Menu::gameover: case Menu::gameover2: {