diff --git a/Adventures in Lestoria/SaveFile.cpp b/Adventures in Lestoria/SaveFile.cpp index a21d5785..708477fd 100644 --- a/Adventures in Lestoria/SaveFile.cpp +++ b/Adventures in Lestoria/SaveFile.cpp @@ -178,7 +178,14 @@ const void SaveFile::SaveGame(){ saveSystemFile["Fullscreen"].SetBool(game->IsFullscreen()); #pragma endregion + saveFile["Hash"].SetString(""); + utils::datafile::Write(saveFile,"save_file_path"_S+std::format("save.{:04}",saveFileID)); + + std::string fileHash=util::GetHash("save_file_path"_S+std::format("save.{:04}",saveFileID)); + saveFile["Hash"].SetString(fileHash); + + utils::datafile::Write(saveFile,"save_file_path"_S+std::format("save.{:04}",saveFileID)); //Once the hash has been computed and added, save the file a second time. utils::datafile::Write(saveSystemFile,"save_file_path"_S+"system.conf"); utils::datafile metadata; if(onlineMode){ @@ -279,6 +286,24 @@ void SaveFile::LoadFile(){ if(std::filesystem::exists(loadFilename)){ utils::datafile::Read(loadFile,"save_file_path"_S+std::format("save.{:04}",saveFileID)); + if(!loadFile.HasProperty("Hash")){ + LOG(std::format("WARNING! Filehash for file {} does not exist!","save_file_path"_S+std::format("save.{:04}",saveFileID))); + return; + } + if(loadFile.HasProperty("Hash")){ + std::string expectedFileHash=loadFile["Hash"].GetString(); + loadFile["Hash"].SetString(""); + utils::datafile::Write(loadFile,"save_file_path"_S+std::format("save.{:04}",saveFileID)); + std::string fileHash=util::GetHash("save_file_path"_S+std::format("save.{:04}",saveFileID)); + + if(expectedFileHash!=fileHash){ + LOG(std::format("WARNING! Filehash for file {} was not identified as proper! Will not load this file!","save_file_path"_S+std::format("save.{:04}",saveFileID))); + return; + } + + loadFile["Hash"].SetString(expectedFileHash); //Now write the hash back into the file since we tampered with it. + utils::datafile::Write(loadFile,"save_file_path"_S+std::format("save.{:04}",saveFileID)); + } game->ResetGame(); for(auto&[key,data]:loadFile["Items"].GetOrderedKeys()){ std::weak_ptrnewItem=Inventory::AddItem(data["Item Name"].GetString(),data["Amt"].GetInt()); diff --git a/Adventures in Lestoria/TODO.txt b/Adventures in Lestoria/TODO.txt index e124527c..38073cfa 100644 --- a/Adventures in Lestoria/TODO.txt +++ b/Adventures in Lestoria/TODO.txt @@ -10,6 +10,28 @@ Upon the second time entering a stage, the game will spawn a timer that the play Upon completion of a stage in time trial mode if the player beat their previous time (which they likely will) the record will update. For each class and stage combination there will be a "dev time" +Achievements +A Good Night's Rest - Unlock the Camp +Handyman - Unlock Greg the Blacksmith +A Strange Gemstone - Complete Chapter 1 +Slime Hunter(100), Killer(250), Slayer(1000) +Slime King +Slime King Destroyer (<1 Minute Kill) +Ursule, Mother of Bears +Ursule, Mother of Bears Destroyer (<1 Minute Kill) +Tough as Steel - Obtain Level 5 on Warrior +Skilled Marksman - Obtain Level 5 on Ranger +Controller of Elements - Obtain Level 5 on Wizard +Maxed out a Weapon in Chapter 1 +Maxed out an Armor piece in Chapter 1 +Wear a full set of maxed out gear +Beat the Devs - Obtained a Time Medal +Speedrunner - Obtained 11 Time Medals + +SetAchievement + +File Hash on Save/Load. + ============================================ Make another actions config file for the main build (The app # is different) \ No newline at end of file diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 116592c4..836b40b4 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 1 #define VERSION_MINOR 0 #define VERSION_PATCH 0 -#define VERSION_BUILD 8507 +#define VERSION_BUILD 8515 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Adventures in Lestoria/assets/Achievements/BronzeBorder.xcf b/Adventures in Lestoria/assets/Achievements/BronzeBorder.xcf new file mode 100644 index 00000000..8b91f087 Binary files /dev/null and b/Adventures in Lestoria/assets/Achievements/BronzeBorder.xcf differ diff --git a/Adventures in Lestoria/assets/Achievements/GoldBorder.xcf b/Adventures in Lestoria/assets/Achievements/GoldBorder.xcf new file mode 100644 index 00000000..6a318620 Binary files /dev/null and b/Adventures in Lestoria/assets/Achievements/GoldBorder.xcf differ diff --git a/Adventures in Lestoria/assets/Achievements/SilverBorder.xcf b/Adventures in Lestoria/assets/Achievements/SilverBorder.xcf new file mode 100644 index 00000000..2bc187b5 Binary files /dev/null and b/Adventures in Lestoria/assets/Achievements/SilverBorder.xcf differ diff --git a/Adventures in Lestoria/assets/Achievements/kill_slime_1.png b/Adventures in Lestoria/assets/Achievements/kill_slime_1.png new file mode 100644 index 00000000..21d1de3d Binary files /dev/null and b/Adventures in Lestoria/assets/Achievements/kill_slime_1.png differ diff --git a/Adventures in Lestoria/assets/Achievements/kill_slime_1_locked.png b/Adventures in Lestoria/assets/Achievements/kill_slime_1_locked.png new file mode 100644 index 00000000..05c0366c Binary files /dev/null and b/Adventures in Lestoria/assets/Achievements/kill_slime_1_locked.png differ diff --git a/Adventures in Lestoria/assets/Achievements/kill_slime_2.png b/Adventures in Lestoria/assets/Achievements/kill_slime_2.png new file mode 100644 index 00000000..b1fdc373 Binary files /dev/null and b/Adventures in Lestoria/assets/Achievements/kill_slime_2.png differ diff --git a/Adventures in Lestoria/assets/Achievements/kill_slime_2_locked.png b/Adventures in Lestoria/assets/Achievements/kill_slime_2_locked.png new file mode 100644 index 00000000..e75156b5 Binary files /dev/null and b/Adventures in Lestoria/assets/Achievements/kill_slime_2_locked.png differ diff --git a/Adventures in Lestoria/assets/Achievements/kill_slime_3.png b/Adventures in Lestoria/assets/Achievements/kill_slime_3.png new file mode 100644 index 00000000..2a4d68b7 Binary files /dev/null and b/Adventures in Lestoria/assets/Achievements/kill_slime_3.png differ diff --git a/Adventures in Lestoria/assets/Achievements/kill_slime_3_locked.png b/Adventures in Lestoria/assets/Achievements/kill_slime_3_locked.png new file mode 100644 index 00000000..806513c5 Binary files /dev/null and b/Adventures in Lestoria/assets/Achievements/kill_slime_3_locked.png differ diff --git a/Adventures in Lestoria/util.cpp b/Adventures in Lestoria/util.cpp index 7098f5d9..1255e074 100644 --- a/Adventures in Lestoria/util.cpp +++ b/Adventures in Lestoria/util.cpp @@ -148,6 +148,31 @@ std::u32string util::WrapText(PixelGameEngine*pge,std::u32string str,int width,F return newStr; } +std::string util::GetHash(std::string fileName){ + std::ifstream file(fileName); + std::string hash=""; + uint8_t hashIndex=0; + while(file.good()){ + uint8_t hashChar=0; + if(hash.size()==std::numeric_limits::max()){ + hashChar=hash[hashIndex]; + } + hashChar+=file.get()*21-7; + hashChar^=hashIndex; + if(hashIndex>0)hashChar+=hash[hashIndex-1]; + hashChar%=94; + hashChar+=32; + if(hashChar=='"'){hashChar+=60;} + if(hash.size()::max()){ + hash+=hashChar; + }else{ + hash[hashIndex]=hashChar; + } + hashIndex++; + } + return hash; +} + long double operator""_Pixels(long double unitDist){ return unitDist/100*24.; } diff --git a/Adventures in Lestoria/util.h b/Adventures in Lestoria/util.h index 71ad4225..f718e47b 100644 --- a/Adventures in Lestoria/util.h +++ b/Adventures in Lestoria/util.h @@ -58,6 +58,7 @@ namespace olc::util{ std::string WrapText(PixelGameEngine*pge,std::string str,int width,bool proportional,vd2d scale); std::u32string WrapText(PixelGameEngine*pge,std::u32string str,int width,Font&font,vd2d scale); float angle_difference(float angle_1, float angle_2); + std::string GetHash(std::string file); } template diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index ff51cab7..51f38ada 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ