From 0dfa361453ef31e76ee8f669d9da3670c68a9e3a Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Fri, 30 Jul 2021 12:25:17 +0200 Subject: [PATCH] arb:: converted and rulegen status is now saved in save_geometry --- arbitrile.cpp | 18 ++++++++++++++++++ mapeditor.cpp | 32 ++++++++++++++++++++++++++------ rulegen.cpp | 4 ++-- system.cpp | 5 +++++ 4 files changed, 51 insertions(+), 8 deletions(-) diff --git a/arbitrile.cpp b/arbitrile.cpp index 1d9b1fac..97081147 100644 --- a/arbitrile.cpp +++ b/arbitrile.cpp @@ -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 diff --git a/mapeditor.cpp b/mapeditor.cpp index 57575084..6a42999e 100644 --- a/mapeditor.cpp +++ b/mapeditor.cpp @@ -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(rulegen::known()); + f.write(arb::convert::in()); + if(arb::convert::in()) { + dynamicval dg(geometry, arb::convert::base_geometry); + dynamicval 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 ac = vernum >= 0xA905 && f.get(); + 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) { diff --git a/rulegen.cpp b/rulegen.cpp index 41715431..e9099b7e 100644 --- a/rulegen.cpp +++ b/rulegen.cpp @@ -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(); } } diff --git a/system.cpp b/system.cpp index 541ec8d8..e847d6ad 100644 --- a/system.cpp +++ b/system.cpp @@ -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();