mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-08 06:59:55 +00:00
protected the loading of modes
This commit is contained in:
parent
43f998453e
commit
cd11bc2332
@ -202,14 +202,6 @@ int modecodetable[42][6] = {
|
|||||||
};
|
};
|
||||||
// unused codes: 6 (cheat/tampered), 25, 254, 255
|
// unused codes: 6 (cheat/tampered), 25, 254, 255
|
||||||
|
|
||||||
EX eLandStructure get_default_land_structure() {
|
|
||||||
return
|
|
||||||
(princess::challenge || tactic::on) ? lsSingle :
|
|
||||||
racing::on ? lsSingle :
|
|
||||||
yendor::on ? yendor::get_land_structure() :
|
|
||||||
lsNiceWalls;
|
|
||||||
}
|
|
||||||
|
|
||||||
EX modecode_t legacy_modecode() {
|
EX modecode_t legacy_modecode() {
|
||||||
if(int(geometry) > 3 || int(variation) > 1) return UNKNOWN;
|
if(int(geometry) > 3 || int(variation) > 1) return UNKNOWN;
|
||||||
if(casual) return UNKNOWN;
|
if(casual) return UNKNOWN;
|
||||||
|
47
yendor.cpp
47
yendor.cpp
@ -1160,7 +1160,10 @@ EX modecode_t modecode(int mode) {
|
|||||||
code_for[nover] = next;
|
code_for[nover] = next;
|
||||||
identify_modes[next] = next;
|
identify_modes[next] = next;
|
||||||
|
|
||||||
if(mode == 2) return next;
|
if(mode == 2) {
|
||||||
|
mode_description_of[next] = mode_description1();
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
|
||||||
if(scorefile == "") return next;
|
if(scorefile == "") return next;
|
||||||
|
|
||||||
@ -1403,7 +1406,7 @@ EX namespace peace {
|
|||||||
auto aNext = addHook(hooks_nextland, 100, getNext);
|
auto aNext = addHook(hooks_nextland, 100, getNext);
|
||||||
EX }
|
EX }
|
||||||
|
|
||||||
map<modecode_t, string> mode_description_of;
|
EX map<modecode_t, string> mode_description_of;
|
||||||
|
|
||||||
void mode_screen_for_current() {
|
void mode_screen_for_current() {
|
||||||
cmode = sm::SIDE | sm::MAYDARK;
|
cmode = sm::SIDE | sm::MAYDARK;
|
||||||
@ -1438,24 +1441,40 @@ void mode_screen_for_current() {
|
|||||||
dialog::display();
|
dialog::display();
|
||||||
}
|
}
|
||||||
|
|
||||||
void push_mode_screen_for(modecode_t mf) {
|
void enable_mode_by_code(modecode_t mf) {
|
||||||
stop_game();
|
stop_game();
|
||||||
shstream ss;
|
shstream ss;
|
||||||
ss.s = meaning[mf];
|
ss.s = meaning[mf];
|
||||||
if(ss.s == "LEGACY") {
|
println(hlog, "enabling modecode ", mf, " : ", as_hexstring(ss.s));
|
||||||
legacy_modecode_read(mf);
|
hlog.flush();
|
||||||
}
|
try {
|
||||||
else {
|
if(ss.s == "LEGACY" || mf < FIRST_MODECODE) {
|
||||||
ss.read(ss.vernum);
|
legacy_modecode_read(mf);
|
||||||
if(ss.vernum < 0xAA05)
|
|
||||||
mapstream::load_geometry(ss);
|
|
||||||
else {
|
|
||||||
ss.write_char(0);
|
|
||||||
load_mode_data_with_zero(ss);
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
ss.read(ss.vernum);
|
||||||
|
if(ss.vernum < 0xAA05) {
|
||||||
|
use_custom_land_list = false;
|
||||||
|
mapstream::load_geometry(ss);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ss.write_char(0);
|
||||||
|
load_mode_data_with_zero(ss);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mode_description_of[mf] = mode_description1();
|
||||||
}
|
}
|
||||||
|
catch(hr_exception& e) {
|
||||||
|
stop_game();
|
||||||
|
println(hlog, "failed: ", e.what());
|
||||||
|
mode_description_of[mf] = "FAILED";
|
||||||
|
geometry = gNormal; variation = eVariation::bitruncated;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void push_mode_screen_for(modecode_t mf) {
|
||||||
|
enable_mode_by_code(mf);
|
||||||
start_game();
|
start_game();
|
||||||
mode_description_of[mf] = mode_description1();
|
|
||||||
pushScreen(mode_screen_for_current);
|
pushScreen(mode_screen_for_current);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user