Keep the newest 15 autosaves; phones start without the heavy render features

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NMSrd5oe1GpUD7E6d825KP
This commit is contained in:
Nexoniarz 2026-10-19 22:43:45 +02:00
commit 39a11e401e

View file

@ -476,6 +476,9 @@ public:
static keel::Cmd recover("fry_recover", [](const keel::Args&) { self->findAutosaves(), self->showRecover_ = !self->recover_.empty(); }, "Fry3DX: show the autosaves to recover"); static keel::Cmd recover("fry_recover", [](const keel::Args&) { self->findAutosaves(), self->showRecover_ = !self->recover_.empty(); }, "Fry3DX: show the autosaves to recover");
static keel::Cmd about("fry_about", [](const keel::Args&) { self->showAbout_ = true; }, "Fry3DX: show the About window"); static keel::Cmd about("fry_about", [](const keel::Args&) { self->showAbout_ = true; }, "Fry3DX: show the About window");
keel::execute("r_autoexposure 0; r_ssr 0; r_volumetric 0; r_shafts 0; r_dynres 0; r_renderscale 1; fps_max 144"); keel::execute("r_autoexposure 0; r_ssr 0; r_volumetric 0; r_shafts 0; r_dynres 0; r_renderscale 1; fps_max 144");
#if defined(__ANDROID__) // a phone: none of the heavy parts (and its GPU's driver is kept to well-trodden ground)
keel::execute("r_gpuculling 0; r_occlusion 0; r_volumetricfog 0; r_mirrors 0; r_taa 0; r_shadowres 2048; r_lightshadows 0; fps_max 60");
#endif
newScene(); newScene();
if (!startPath_.empty()) openFile(startPath_); if (!startPath_.empty()) openFile(startPath_);
findAutosaves(); findAutosaves();
@ -1102,13 +1105,20 @@ private:
stdfs::remove(autosavePath_, ec), stdfs::remove(autosavePath_ + ".from", ec); stdfs::remove(autosavePath_, ec), stdfs::remove(autosavePath_ + ".from", ec);
autosavePath_.clear(), lastAutosave_ = now(); autosavePath_.clear(), lastAutosave_ = now();
} }
// Autosaves left behind (it didn't close properly): offered back. // Autosaves left behind (it didn't close properly): offered back. Only the newest 15 are
// kept; older ones are deleted.
void findAutosaves() { void findAutosaves() {
static constexpr size_t kKeep = 15;
recover_.clear(); recover_.clear();
std::error_code ec; std::error_code ec;
std::vector<std::pair<stdfs::file_time_type, std::string>> found;
for (const auto& e : stdfs::directory_iterator(autosaveDir(), ec)) for (const auto& e : stdfs::directory_iterator(autosaveDir(), ec))
if (e.path().extension() == ".fry") recover_.push_back(e.path().string()); if (e.path().extension() == ".fry") found.emplace_back(e.last_write_time(ec), e.path().string());
std::sort(recover_.begin(), recover_.end()); std::sort(found.begin(), found.end(), [](const auto& a, const auto& b) { return a.first > b.first; }); // newest first
for (size_t i = 0; i < found.size(); ++i) {
if (i < kKeep || found[i].second == autosavePath_) recover_.push_back(found[i].second);
else stdfs::remove(found[i].second, ec), stdfs::remove(found[i].second + ".from", ec);
}
showRecover_ = !recover_.empty() && !keel::isTestMode(); showRecover_ = !recover_.empty() && !keel::isTestMode();
} }
void recoverWindow() { void recoverWindow() {
@ -4395,14 +4405,19 @@ private:
// ───────────────────────────── 3D ───────────────────────────── // ───────────────────────────── 3D ─────────────────────────────
#if defined(__ANDROID__)
static constexpr int kRayLight = 0; // (light bounced by ray tracing: not on phones)
#else
static constexpr int kRayLight = 1;
#endif
// Solid: a plain grey room and soft studio light, no shadows or effects — for seeing shapes. // Solid: a plain grey room and soft studio light, no shadows or effects — for seeing shapes.
// Rendered: sky, sun, shadows and effects. // Rendered: sky, sun, shadows and effects.
void applyShading() { void applyShading() {
const Look& k = scene_.look; const Look& k = scene_.look;
const std::string want = const std::string want =
shading() == Shading::Rendered shading() == Shading::Rendered
? std::format("r_ssao {}; r_bloom {}; r_vignette {}; r_exposure {}; r_saturation {}; r_sharpen {}; r_shadowsoft {}; r_gi 1; r_fog 0; r_skycolor \"{} {} {}\"", k.ao, ? std::format("r_ssao {}; r_bloom {}; r_vignette {}; r_exposure {}; r_saturation {}; r_sharpen {}; r_shadowsoft {}; r_gi {}; r_fog 0; r_skycolor \"{} {} {}\"", k.ao,
k.bloom, k.vignette, k.exposure, k.saturation, k.sharpen, k.shadowSoft, k.background.r, k.background.g, k.background.b) k.bloom, k.vignette, k.exposure, k.saturation, k.sharpen, k.shadowSoft, kRayLight, k.background.r, k.background.g, k.background.b)
: std::string("r_ssao 0; r_bloom 0; r_vignette 0; r_exposure 1; r_saturation 1; r_sharpen 0; r_gi 0; r_fog 0; r_skycolor \"0.2 0.2 0.215\""); : std::string("r_ssao 0; r_bloom 0; r_vignette 0; r_exposure 1; r_saturation 1; r_sharpen 0; r_gi 0; r_fog 0; r_skycolor \"0.2 0.2 0.215\"");
if (want == appliedLook_) return; if (want == appliedLook_) return;
appliedLook_ = want; appliedLook_ = want;