From be15697fc80c7c8743e961d05d11135ff8928f88 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Fri, 29 Mar 2024 22:18:00 -0500 Subject: [PATCH] Make sure file hash does not include the | character due to emscripten using it to split a save request. --- Adventures in Lestoria/SaveFile.cpp | 5 +++-- Adventures in Lestoria/olcUTIL_DataFile.h | 4 +++- Adventures in Lestoria/util.cpp | 5 +++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Adventures in Lestoria/SaveFile.cpp b/Adventures in Lestoria/SaveFile.cpp index 708477fd..5f0aa8ea 100644 --- a/Adventures in Lestoria/SaveFile.cpp +++ b/Adventures in Lestoria/SaveFile.cpp @@ -184,7 +184,7 @@ const void SaveFile::SaveGame(){ std::string fileHash=util::GetHash("save_file_path"_S+std::format("save.{:04}",saveFileID)); saveFile["Hash"].SetString(fileHash); - + std::cout<<"Setting Hash to "<='A'&&c<='Z'||c>='a'&&c<='z'||c>='0'&&c<='9'||std::find(uriReserved.begin(),uriReserved.end(),c)!=uriReserved.end())return std::move(str)+c; - + std::string convertedChar=std::format("%{:02x}",c); std::for_each(convertedChar.begin(),convertedChar.end(),[](char&c){c=char(std::toupper(c));}); return std::move(str)+convertedChar; diff --git a/Adventures in Lestoria/olcUTIL_DataFile.h b/Adventures in Lestoria/olcUTIL_DataFile.h index 89f3a0cb..a2dd40a9 100644 --- a/Adventures in Lestoria/olcUTIL_DataFile.h +++ b/Adventures in Lestoria/olcUTIL_DataFile.h @@ -267,9 +267,11 @@ namespace olc::utils // Value does not contain separator, so just write out file << property.second.GetString(i) << ((nItems > 1) ? sSeperator : ""); } + std::cout<<"Written: "<0)hashChar+=hash[hashIndex-1]; hashChar%=94; hashChar+=32; - if(hashChar=='"'){hashChar+=60;} + if(hashChar=='"'||hashChar==',')hashChar+=60; + if(hashChar=='|')hashChar++; //FORBIDDEN CHARACTER IN EMSCRIPTEN BUILD! if(hash.size()::max()){ hash+=hashChar; }else{