Fix a bug where save file hashes with trailing spaces were not read properly, locking players out of the character. Release Build 8647.

mac-build
sigonasr2 8 months ago
parent 5cc7139025
commit 564ab7434c
  1. 3
      Adventures in Lestoria/Item.cpp
  2. 10
      Adventures in Lestoria/SaveFile.cpp
  3. 2
      Adventures in Lestoria/Version.h
  4. BIN
      x64/Release/Adventures in Lestoria.exe

@ -490,6 +490,9 @@ std::vector<std::weak_ptr<Item>>Inventory::GetItem(IT it){
uint32_t Inventory::GetItemCount(IT it){
if(!_inventory.count(it)){
return 0;
}else
if(ITEM_DATA.at(it).IsAccessory()){
return 1; //We always only have 1 of any given accessory.
}else{
auto inventory=_inventory.equal_range(it);
return std::accumulate(inventory.first,inventory.second,0,[](int val,std::pair<IT,std::shared_ptr<Item>>it){return val+(*it.second).Amt();});

@ -304,10 +304,18 @@ void SaveFile::LoadFile(){
std::string expectedFileHash=loadFile["Hash"].GetString();
loadFile["Hash"].SetString("");
utils::datafile::Write(loadFile,"save_file_path"_S+std::format("save.{:04}",saveFileID));
auto trim = [](std::string& s)
{
s.erase(0, s.find_first_not_of(" \t\n\r\f\v"));
s.erase(s.find_last_not_of(" \t\n\r\f\v") + 1);
};
std::string fileHash=util::GetHash("save_file_path"_S+std::format("save.{:04}",saveFileID));
trim(fileHash); //It's possible the expected file hash has a space at the end/beginning that gets stripped out. We want to trim and match that string.
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)));
ERR(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;
}

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1
#define VERSION_MINOR 0
#define VERSION_PATCH 0
#define VERSION_BUILD 8630
#define VERSION_BUILD 8647
#define stringify(a) stringify_(a)
#define stringify_(a) #a

Loading…
Cancel
Save