From 8ca1a31ccc3b6a34496d04de87d5ed9ec14d4e9c Mon Sep 17 00:00:00 2001 From: kichikuou Date: Tue, 31 Mar 2026 14:06:15 +0900 Subject: [PATCH] PartsEngine: clamp passed_time to 0 in PE_UpdateComponent After loading a save, the game script may give a negative passed_time because it computes the delta time using an absolute system.GetTime() value stored in the save data. This fixes hang on load in Rance 9. This also removes the equivalent workaround in parts_render_update for Rance 01, since the new clamp covers that case as well. --- src/parts/parts.c | 5 +++++ src/parts/render.c | 6 ------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/parts/parts.c b/src/parts/parts.c index dae8334..6d04aaf 100644 --- a/src/parts/parts.c +++ b/src/parts/parts.c @@ -1120,6 +1120,11 @@ static void parts_update_component(struct parts *parts) void PE_UpdateComponent(possibly_unused int passed_time) { + // After loading a save, the game script may compute a negative time delta + // because it stores an absolute system.GetTime() value in the save data, + // which is meaningless across process restarts. + if (passed_time < 0) + passed_time = 0; while (!TAILQ_EMPTY(&dirty_list)) { // pop parts object from dirty list struct parts *parts = TAILQ_FIRST(&dirty_list); diff --git a/src/parts/render.c b/src/parts/render.c index 570c4e9..6a91641 100644 --- a/src/parts/render.c +++ b/src/parts/render.c @@ -634,12 +634,6 @@ static bool pe_dirty = false; void parts_render_update(int passed_time) { - // XXX: hack for Rance 01 load issue - // There is a bug in Rance 01 where a single bad frame is displayed after - // loading a save. When this happens, the game passes a negative time delta - // to PE_Update. We fix this issue by ignoring such calls. - if (passed_time < 0) - return; if (pe_dirty) { struct parts *p; PARTS_LIST_FOREACH(p) {