Make android save more robust

This commit is contained in:
Yousef Khadadeh 2026-05-17 22:18:53 +03:00
parent 3ba403f30e
commit e8cba9dc15
14 changed files with 61 additions and 33 deletions

View file

@ -476,7 +476,7 @@ void World::autosave_to_directory(const std::filesystem::path& directoryToSaveAt
save_to_file(directoryToSaveAt / std::filesystem::path(nameToSaveUnder + "." + FILE_EXTENSION));
}
void World::save_to_file(const std::filesystem::path& filePathToSaveAt) {
void World::save_to_file(const std::filesystem::path& filePathToSaveAt, bool saveThumbnailIfAvailable) {
try {
filePath = filePathToSaveAt;
@ -508,7 +508,7 @@ void World::save_to_file(const std::filesystem::path& filePathToSaveAt) {
#else
if(!SDL_SaveFile(filePath.string().c_str(), f.view().data(), f.view().size()))
throw std::runtime_error("SDL_SaveFile failed with error: " + std::string(SDL_GetError()));
else if(saveThumbnail) {
else if(saveThumbnail && saveThumbnailIfAvailable) {
Vector2f imageCenter{main.window.size.x() * 0.5f, main.window.size.y() * 0.5f};
float imageDim = std::max(main.window.size.x(), main.window.size.y());
Vector2f imageDimVec{imageDim * 0.5f, imageDim * 0.5f};