From 4b89d1dfd7cb79bcb143eb170d5e6ade24019a3b Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Fri, 14 Dec 2018 21:35:46 +0100 Subject: [PATCH] fixed some bugs with modecode and save format --- mapeditor.cpp | 9 +++++++-- yendor.cpp | 20 ++++++++++++++++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/mapeditor.cpp b/mapeditor.cpp index 24d432a3..a71e95a6 100644 --- a/mapeditor.cpp +++ b/mapeditor.cpp @@ -105,6 +105,8 @@ namespace mapstream { f.write(torusconfig::qty); f.write(torusconfig::dx); f.write(torusconfig::dy); + f.write(torusconfig::sdx); + f.write(torusconfig::sdy); f.write(torusconfig::torus_mode); } if(geometry == gFieldQuotient) { @@ -207,9 +209,12 @@ namespace mapstream { f.read(torusconfig::qty); f.read(torusconfig::dx); f.read(torusconfig::dy); - if(vernum >= 10504) + if(vernum >= 10504) { + f.read(torusconfig::sdx); + f.read(torusconfig::sdy); f.read(torusconfig::torus_mode); - + } + torusconfig::activate(); } if(geometry == gCrystal && vernum >= 10504) { int sides; diff --git a/yendor.cpp b/yendor.cpp index dff60b1f..b159786b 100644 --- a/yendor.cpp +++ b/yendor.cpp @@ -955,12 +955,24 @@ int modecode() { mct += irr::density_code() << 21; // 8 bits } + if(DUAL) { + mct += (1 << 19); + mct += (1 << 20); + } + // 32 bits [29..61) for geometry specifics if(torus) { - mct += ll(torusconfig::dx) << 29; - mct += ll(torusconfig::dy) << 37; - mct += ll(torusconfig::qty) << 45; - mct += ll(torusconfig::torusmode) << 53; + mct += ll(torusconfig::torusmode) << 29; + auto& mode = torusconfig::tmodes[torusconfig::torusmode]; + bool single = (mode.flags & torusconfig::TF_SINGLE); + if(single) { + mct += ll(torusconfig::qty) << 37; + mct += ll(torusconfig::dy) << 45; + } + else { + mct += ll(torusconfig::sdx) << 37; + mct += ll(torusconfig::sdy) << 45; + } } if(geometry == gQuotient) {