Make sure file hash does not include the | character due to emscripten using it to split a save request.
This commit is contained in:
parent
2a9e698e0a
commit
be15697fc8
Adventures in Lestoria
@ -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 "<<fileHash<<". Writing to File..."<<std::endl;
|
||||
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;
|
||||
@ -298,6 +298,7 @@ void SaveFile::LoadFile(){
|
||||
|
||||
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)));
|
||||
LOG("Expected vs Actual: "<<expectedFileHash<<std::endl<<fileHash<<std::endl)
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -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: "<<property.second.GetString(i)<<std::endl;
|
||||
nItems--;
|
||||
}
|
||||
|
||||
std::cout<<"Write newline."<<std::endl;
|
||||
// Property written, move to next line
|
||||
file << "\n";
|
||||
}
|
||||
|
@ -161,13 +161,14 @@ std::string util::GetHash(std::string fileName){
|
||||
hashChar=hash[hashIndex];
|
||||
}
|
||||
char newChar=file.get();
|
||||
if(newChar=='\r'||newChar=='\n')continue;
|
||||
if(newChar=='\r'||newChar=='\f'||newChar=='\n')continue;
|
||||
hashChar+=newChar*21-7;
|
||||
hashChar^=hashIndex;
|
||||
if(hashIndex>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()<std::numeric_limits<uint8_t>::max()){
|
||||
hash+=hashChar;
|
||||
}else{
|
||||
|
Loading…
x
Reference in New Issue
Block a user