From 078d16a4e4168bc12ed3c2c06b1749c53c23c8d9 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 2 Jun 2024 18:18:56 +0200 Subject: [PATCH] re-code when obtaining a new code different from the old one, due to the new version --- yendor.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/yendor.cpp b/yendor.cpp index 1cb7f55f..c23ee668 100644 --- a/yendor.cpp +++ b/yendor.cpp @@ -1138,6 +1138,9 @@ EX modecode_t get_identify(modecode_t xc) { return identify_modes[xc]; } +/** handle cases where the encoding changed in the new version */ +EX string expected_modecode; + EX modecode_t modecode(int mode) { modecode_t x = legacy_modecode(); if(x != UNKNOWN) return x; @@ -1155,6 +1158,11 @@ EX modecode_t modecode(int mode) { modecode_t next = FIRST_MODECODE; while(meaning.count(next)) next++; + + if(expected_modecode != "" && expected_modecode != nover && code_for.count(expected_modecode)) { + next = code_for[expected_modecode]; + // fallthrough -- will make an alias with the current encoding + } meaning[next] = code; code_for[nover] = next; @@ -1412,10 +1420,10 @@ void mode_screen_for_current() { cmode = sm::SIDE | sm::MAYDARK; gamescreen(); - dialog::init(XLAT("recorded mode"), iinf[itOrbYendor].color, 150, 100); + auto mc = modecode(); + dialog::init(XLAT("recorded mode %1", its(mc)), iinf[itOrbYendor].color, 150, 100); dialog::addInfo(mode_description1()); - auto mc = modecode(); dialog::addBreak(100); dialog::addSelItem(XLAT("scores recorded"), its(qty_scores_for[mc]), 's'); @@ -1457,6 +1465,9 @@ void enable_mode_by_code(modecode_t mf) { load_mode_data_with_zero(ss); } mode_description_of[mf] = mode_description1(); + dynamicval s(expected_modecode, meaning[mf].substr(2)); + auto mc = modecode(); hr::ignore(mc); + println(hlog, "read mode ", mc, " correctly"); } catch(hr_exception& e) { stop_game();