From 1b998a3321158763a03494399e277763b2137ae7 Mon Sep 17 00:00:00 2001 From: PatR Date: Tue, 17 Sep 2024 21:28:10 -0700 Subject: [PATCH] relink_light_sources comment I remembered some more of the light source problem that led to the panic() call that was fixed earlier today, but I'm not sure how accurate this new comment is. If it is accurate, the changes of impossible() to panic() that the fix included won't necessarily catch the old, apparently one-off, problem it describes. --- src/light.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/light.c b/src/light.c index f5985937d..5ab517177 100644 --- a/src/light.c +++ b/src/light.c @@ -496,6 +496,22 @@ relink_light_sources(boolean ghostly) unsigned nid; light_source *ls; + /* + * Caveat: + * There has been at least one instance during to-be-3.7 development + * where the light_base linked list ended up with a circular link. + * If that happens, then once all the traversed elements have their + * LSF_NEEDS_FIXUP flag cleared, the traversal attempt will run wild. + * + * The circular list instance was blamed on attempting to restore + * a save file which should have been invalidated by version/patch/ + * editlevel verification, but wasn't rejected because EDITLEVEL + * didn't get incremented when it should have been. Valid data should + * never produce the problem and it isn't possible in general to guard + * against code updates that neglect to set the verification info up + * to date. + */ + for (ls = gl.light_base; ls; ls = ls->next) { if (ls->flags & LSF_NEEDS_FIXUP) { if (ls->type == LS_OBJECT || ls->type == LS_MONSTER) {