1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-14 09:24:48 +00:00

arb:: converted and rulegen status is now saved in save_geometry

This commit is contained in:
Zeno Rogue 2021-07-30 12:25:17 +02:00
parent 253c5ee531
commit 0dfa361453
4 changed files with 51 additions and 8 deletions

View File

@ -1026,6 +1026,9 @@ EX void set_sliders() {
/** convert a tessellation (e.g. Archimedean, regular, etc.) to the arb::current internal representation */
EX namespace convert {
EX eGeometry base_geometry;
EX eVariation base_variation;
struct id_record {
int target; /* master of this id type */
int shift; /* sample direction 0 == our direction shift */
@ -1219,6 +1222,21 @@ EX void convert() {
arb::compute_vertex_valence();
}
EX bool in() {
return arb::in() && base_geometry != gArbitrary;
}
/** activate the converted tessellation */
EX void activate() {
if(geometry != gArbitrary) {
base_geometry = geometry;
base_variation = variation;
stop_game();
geometry = gArbitrary;
variation = eVariation::pure;
}
}
EX }
#if CAP_COMMANDLINE

View File

@ -469,7 +469,17 @@ EX namespace mapstream {
#if CAP_ARCM
if(geometry == gArchimedean) f.write(arcm::current.symbol);
#endif
if(geometry == gArbitrary) f.write(arb::current.filename);
if(geometry == gArbitrary) {
f.write<bool>(rulegen::known());
f.write<bool>(arb::convert::in());
if(arb::convert::in()) {
dynamicval<eGeometry> dg(geometry, arb::convert::base_geometry);
dynamicval<eVariation> dv(variation, arb::convert::base_variation);
save_geometry(f);
}
else
f.write(arb::current.filename);
}
if(geometry == gNil) {
f.write(S7);
f.write(nilv::nilperiod);
@ -554,11 +564,21 @@ EX namespace mapstream {
}
}
#endif
if(geometry == gArbitrary) {
string s;
f.read(s);
arb::run(s);
stop_game();
if(geometry == gArbitrary) {
bool rk = vernum >= 0xA905 && f.get<bool>();
bool ac = vernum >= 0xA905 && f.get<bool>();
if(ac) {
load_geometry(f);
arb::convert::convert();
arb::convert::activate();
}
else {
string s;
f.read(s);
arb::run(s);
stop_game();
}
if(rk) rulegen::prepare_rules();
}
#if CAP_ARCM
if(geometry == gArchimedean) {

View File

@ -1520,7 +1520,7 @@ EX bool known() {
return rules_known_for == arb::current.name;
}
bool prepare_rules() {
EX bool prepare_rules() {
if(known()) return true;
try {
generate_rules();
@ -1555,7 +1555,7 @@ int args() {
PHASEFROM(3);
if(prepare_rules()) {
stop_game();
set_geometry(gArbitrary);
arb::convert::activate();
start_game();
}
}

View File

@ -1366,6 +1366,11 @@ EX void set_geometry(eGeometry target) {
if(was_default) pmodel = default_model();
if(WDIM == 2 && (cgflags & qIDEAL) && vid.always3 && vid.texture_step < 32) vid.texture_step = 32;
if(sl2) nisot::geodesic_movement = true;
if(geometry == gArbitrary) {
arb::convert::base_geometry = geometry;
arb::convert::base_variation = variation;
}
if(rotspace) {
check_cgi(); cgi.require_basics();