From b3d3661e136b8ca87b2c2b62f632a5feccd1e992 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 22 Jun 2024 02:04:34 +0200 Subject: [PATCH] do not generate modecodes without need --- menus.cpp | 1 + system.cpp | 2 +- yendor.cpp | 8 +++++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/menus.cpp b/menus.cpp index 0403b1c1..f32807ae 100644 --- a/menus.cpp +++ b/menus.cpp @@ -511,6 +511,7 @@ EX void show_custom() { auto m = at_or_null(modename, current_modecode); dialog::addSelItem("name custom mode", m ? *m : "", 'N'); dialog::add_action([] { + modecode(); name_to_edit = modename[current_modecode]; dialog::edit_string(name_to_edit, "name custom mode", ""); dialog::get_di().reaction_final = [] { update_modename(name_to_edit); }; diff --git a/system.cpp b/system.cpp index b252baae..26712ebe 100644 --- a/system.cpp +++ b/system.cpp @@ -171,7 +171,7 @@ EX void initgame() { DEBBI(DF_INIT, ("initGame")); callhooks(hooks_initgame); - modecode(); + modecode(1); if(!safety) fix_land_structure_choice(); diff --git a/yendor.cpp b/yendor.cpp index 9d0c04b6..4a6dc78d 100644 --- a/yendor.cpp +++ b/yendor.cpp @@ -1156,7 +1156,7 @@ EX modecode_t modecode(int mode) { if(code_for.count(nover)) return code_for[nover]; - if(mode == 1) return UNKNOWN; + if(mode == 1) return current_modecode = UNKNOWN; modecode_t next = FIRST_MODECODE; while(meaning.count(next)) next++; @@ -1211,6 +1211,7 @@ EX void load_modename_line(string s) { } EX void update_modename(string newname) { + modecode(); string old = modename.count(current_modecode) ? modename[current_modecode] : ""; if(old == newname) return; if(newname == "") modename.erase(current_modecode); @@ -1442,7 +1443,7 @@ void mode_screen_for_current() { cmode = sm::SIDE | sm::MAYDARK; gamescreen(); - modecode(); + modecode(1); auto& mc = current_modecode; dialog::init(XLAT("recorded mode %1", its(mc)), iinf[itOrbYendor].color, 150, 100); dialog::addInfo(mode_description1()); @@ -1450,7 +1451,7 @@ void mode_screen_for_current() { dialog::addBreak(100); dialog::addSelItem(XLAT("scores recorded"), its(qty_scores_for[mc]), 's'); - dialog::add_action([] { scores::load(); scores::which_mode = current_modecode; }); + dialog::add_action([] { modecode(); scores::load(); scores::which_mode = current_modecode; }); dialog::addSelItem(XLAT("Yendor Challenge"), its(yendor::compute_tscore(mc)), 'y'); dialog::add_action([] { @@ -1523,6 +1524,7 @@ EX vector mode_list; EX map modename; EX void prepare_custom() { + modecode(); scores::load_only(); gen_mode_list(); pushScreen(show_custom);