From e94386217452ff93df6fb089be0b2041de4c3367 Mon Sep 17 00:00:00 2001 From: NotImplementedLife Date: Sun, 23 Oct 2022 11:41:28 +0300 Subject: [PATCH] fixed save file --- include/data/mapstats.hpp | 25 +++---------------------- include/save_file.hpp | 2 +- source/data/mapstats.cpp | 22 ++++++++++++++++++++++ source/save_file.cpp | 2 +- source/scenes/map_scene.cpp | 18 +++++++++++++++--- text/messages.ini | 2 +- 6 files changed, 43 insertions(+), 28 deletions(-) diff --git a/include/data/mapstats.hpp b/include/data/mapstats.hpp index 73fd0ec..3c5ca7e 100644 --- a/include/data/mapstats.hpp +++ b/include/data/mapstats.hpp @@ -14,29 +14,10 @@ struct MapData #define cr_map(mapx, sx, sy, fx, fy) { #mapx, mapx, sx, sy, fx, fy } -#include "intro1.mapdata.h" -#include "intro2.mapdata.h" -#include "intro3.mapdata.h" +extern const MapData MAP_STATS[]; -#include "map1.mapdata.h" -#include "map2.mapdata.h" -#include "map3.mapdata.h" -#include "map4.mapdata.h" -#include "map5.mapdata.h" - -constexpr MapData MAP_STATS[] -{ - MAP_DATA_intro1, - MAP_DATA_intro2, - MAP_DATA_intro3, - MAP_DATA_map1, - MAP_DATA_map2, - MAP_DATA_map3, - MAP_DATA_map4, - MAP_DATA_map5, -}; - -#define MAP_STATS_COUNT ((int)(sizeof(MAP_STATS)/sizeof(MapData))) +//#define MAP_STATS_COUNT ((int)(sizeof(MAP_STATS)/sizeof(MapData))) +#define MAP_STATS_COUNT 8 const MapData* random_map(); \ No newline at end of file diff --git a/include/save_file.hpp b/include/save_file.hpp index 56fad0d..6ff2d81 100644 --- a/include/save_file.hpp +++ b/include/save_file.hpp @@ -7,7 +7,7 @@ struct SaveData { int header; int language; - int maps_mmss[MAP_STATS_COUNT]; + unsigned maps_mmss[MAP_STATS_COUNT]; }; diff --git a/source/data/mapstats.cpp b/source/data/mapstats.cpp index bed76ff..0a41d4f 100644 --- a/source/data/mapstats.cpp +++ b/source/data/mapstats.cpp @@ -1,7 +1,29 @@ #include "mapstats.hpp" +#include "intro1.mapdata.h" +#include "intro2.mapdata.h" +#include "intro3.mapdata.h" + +#include "map1.mapdata.h" +#include "map2.mapdata.h" +#include "map3.mapdata.h" +#include "map4.mapdata.h" +#include "map5.mapdata.h" + #include +const MapData MAP_STATS[] +{ + MAP_DATA_intro1, + MAP_DATA_intro2, + MAP_DATA_intro3, + MAP_DATA_map1, + MAP_DATA_map2, + MAP_DATA_map3, + MAP_DATA_map4, + MAP_DATA_map5, +}; + const MapData* random_map() { return &MAP_STATS[rand()%MAP_STATS_COUNT]; diff --git a/source/save_file.cpp b/source/save_file.cpp index 2add4d6..a16dab9 100644 --- a/source/save_file.cpp +++ b/source/save_file.cpp @@ -16,7 +16,7 @@ void SaveFile::load() data().header = HEADER; data().language = LANG_EN; for(int i=0;inext(nullptr); @@ -502,7 +504,17 @@ void MapScene::open_reports(int code) } else if(i==5) { - vwf.put_text(get_message(LMSG_HI_SCORE), Pal4bit, SolidColorBrush(0x4)); + int j = (mapdata-MAP_STATS); + unsigned mm_ss = (mm<<16)|ss; + //assert(SAVE_FILE.data().maps_mmss[i]!=0); + if(mm_ss < SAVE_FILE.data().maps_mmss[j]) + { + SAVE_FILE.data().maps_mmss[j] = mm_ss; + SAVE_FILE.save(); + vwf.put_text(get_message(LMSG_HI_SCORE), Pal4bit, SolidColorBrush(0x4)); + } + else + vwf.put_text("\n", Pal4bit, SolidColorBrush(0x4)); digits_moving = false; vwf.put_text(get_message(LMSG_NEXT_LEVEL_MSG), Pal4bit, SolidColorBrush(0x4)); diff --git a/text/messages.ini b/text/messages.ini index de9bf8f..b36d98c 100644 --- a/text/messages.ini +++ b/text/messages.ini @@ -4,7 +4,7 @@ GAME_OVER_PLAYER_FALL = "You fell out of the ice platform.\n" GAME_OVER_GHOST_ATK = "A ghost attacked you.\n" LEVEL_COMPLETE = " Well Done!\n" HI_SCORE = "\n HI SCORE!!!" -GAME_OVER_OPTIONS = "\n A - Restart\n B - Back to title" +GAME_OVER_OPTIONS = "\n A - Restart B - Back to title" NEXT_LEVEL_MSG = "\n\n A - next level" [ES]