diff --git a/irregular.cpp b/irregular.cpp index 10328d15..edc0de66 100644 --- a/irregular.cpp +++ b/irregular.cpp @@ -63,7 +63,7 @@ EX hrmap *base; EX euc::torus_config_full base_config; -bool gridmaking; +EX bool gridmaking; int rearrange_index; @@ -918,19 +918,24 @@ EX void load_map_bin(hstream& f) { EX void load_map_full(hstream& f) { init(); - load_map_bin(f); - while(runlevel < 10) step(1000); - start_game_on_created_map(); + try { + load_map_bin(f); + while(runlevel < 10) step(1000); + start_game_on_created_map(); + } + catch(hr_exception& e) { + cancel_map_creation(); + throw e; + } } -void cancel_map_creation() { +EX void cancel_map_creation() { base = NULL; runlevel = 0; popScreen(); gridmaking = false; stop_game(); geometry = orig_geometry; - start_game(); } string irrmapfile = "irregularmap.txt"; @@ -984,7 +989,7 @@ void show_gridmaker() { dialog::addSelItem(XLAT("activate"), runlevel == 10 ? XLAT("ready") : XLAT("wait..."), 'f'); if(runlevel == 10) dialog::add_action(start_game_on_created_map); dialog::addItem(XLAT("cancel"), 'c'); - dialog::add_action(cancel_map_creation); + dialog::add_action([] { cancel_map_creation(); start_game(); }); dialog::addItem(XLAT("save"), 's'); dialog::add_action([] () { dialog::openFileDialog(irrmapfile, XLAT("irregular to save:"), ".txt", [] () {