mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-17 08:39:19 +02:00
start without scenery flag
This commit is contained in:
61
maj0sted/include/maj0sted/editor/join.hpp
Normal file
61
maj0sted/include/maj0sted/editor/join.hpp
Normal file
@@ -0,0 +1,61 @@
|
||||
#pragma once
|
||||
|
||||
// TYMCZASOWA ZASLEPKA. Modul scalania koncow (plan_join / join_ends) nie zostal nigdy
|
||||
// zacommitowany: commit 4ddfeb02 dopisal `src/editor/join.cpp` do CMakeLists i `#include` w
|
||||
// planpanel.cpp, ale samych plikow nie ma ani w drzewie, ani w historii, ani w stashach. Bez
|
||||
// tego naglowka i join.cpp branch sie nie kompiluje wcale. Ta zaslepka odtwarza dokladnie to
|
||||
// API, ktorego uzywa panel planu, i mowi "niedostepne" - zeby reszta edytora dala sie uruchomic.
|
||||
// Do zastapienia prawdziwym rozwiazaniem geometrii (luk-prosta-luk) i chirurgia dokumentu.
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "maj0sted/domain/geometry/segment_layout.hpp" // Pose
|
||||
#include "maj0sted/editor/model.hpp"
|
||||
#include "maj0sted/editor/solution.hpp"
|
||||
|
||||
namespace maj0sted::editor {
|
||||
|
||||
/// Co stanelo miedzy dwoma koncami.
|
||||
enum class JoinKind {
|
||||
None,
|
||||
Straight,
|
||||
Arc,
|
||||
ArcLineArc,
|
||||
ArcArc,
|
||||
};
|
||||
|
||||
[[nodiscard]] const char* join_kind_name(JoinKind kind);
|
||||
|
||||
/// Czym wolno gietc to, co lezy miedzy koncami.
|
||||
struct JoinSettings {
|
||||
double radius{300.0};
|
||||
};
|
||||
|
||||
/// Propozycja, przed tknieciem dokumentu.
|
||||
struct JoinPlan {
|
||||
bool ok{false};
|
||||
std::string why{};
|
||||
JoinKind kind{JoinKind::None};
|
||||
std::vector<Element> elements{};
|
||||
double tightest{0.0};
|
||||
};
|
||||
|
||||
[[nodiscard]] JoinPlan plan_join(const domain::geometry::Pose& leaving,
|
||||
const domain::geometry::Pose& arriving,
|
||||
const JoinSettings& settings);
|
||||
|
||||
/// Co scalenie kosztowalo.
|
||||
struct JoinReport {
|
||||
bool ok{false};
|
||||
std::string why{};
|
||||
JoinPlan join{};
|
||||
int fused{0};
|
||||
int turnouts{0};
|
||||
bool reversed{false};
|
||||
};
|
||||
|
||||
[[nodiscard]] JoinReport join_ends(Document& document, const Solution& solution, TrackId a,
|
||||
int a_end, TrackId b, int b_end, const JoinSettings& settings);
|
||||
|
||||
} // namespace maj0sted::editor
|
||||
51
maj0sted/src/editor/join.cpp
Normal file
51
maj0sted/src/editor/join.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
// TYMCZASOWA ZASLEPKA - patrz komentarz w join.hpp.
|
||||
|
||||
#include "maj0sted/editor/join.hpp"
|
||||
|
||||
namespace maj0sted::editor {
|
||||
|
||||
namespace {
|
||||
constexpr const char* kMissing = "scalanie koncow niedostepne: brak modulu join";
|
||||
} // namespace
|
||||
|
||||
const char* join_kind_name(JoinKind kind) {
|
||||
switch (kind) {
|
||||
case JoinKind::Straight:
|
||||
return "prosta";
|
||||
case JoinKind::Arc:
|
||||
return "luk";
|
||||
case JoinKind::ArcLineArc:
|
||||
return "luk-prosta-luk";
|
||||
case JoinKind::ArcArc:
|
||||
return "luk-luk";
|
||||
case JoinKind::None:
|
||||
break;
|
||||
}
|
||||
return "nic";
|
||||
}
|
||||
|
||||
JoinPlan plan_join(const domain::geometry::Pose& leaving, const domain::geometry::Pose& arriving,
|
||||
const JoinSettings& settings) {
|
||||
(void)leaving;
|
||||
(void)arriving;
|
||||
(void)settings;
|
||||
JoinPlan plan;
|
||||
plan.why = kMissing;
|
||||
return plan;
|
||||
}
|
||||
|
||||
JoinReport join_ends(Document& document, const Solution& solution, TrackId a, int a_end, TrackId b,
|
||||
int b_end, const JoinSettings& settings) {
|
||||
(void)document;
|
||||
(void)solution;
|
||||
(void)a;
|
||||
(void)a_end;
|
||||
(void)b;
|
||||
(void)b_end;
|
||||
(void)settings;
|
||||
JoinReport report;
|
||||
report.why = kMissing;
|
||||
return report;
|
||||
}
|
||||
|
||||
} // namespace maj0sted::editor
|
||||
@@ -76,8 +76,16 @@ state_serializer::deserialize_begin( std::string const &Scenariofile ) {
|
||||
}
|
||||
scene::Groups.create();
|
||||
|
||||
if( false == state->input.ok() )
|
||||
throw invalid_scenery_exception();
|
||||
if( false == state->input.ok() ) {
|
||||
if( false == Global.editor_startup ) {
|
||||
throw invalid_scenery_exception();
|
||||
}
|
||||
// the editor is allowed to work on ground that has no scenery file yet: starting with -editor,
|
||||
// or beginning a new map, names a file which will only exist once it gets saved. an unreadable
|
||||
// scenery means an empty world here, not a failed load
|
||||
WriteLog( "Scenery \"" + Scenariofile + "\" not found, the editor starts on empty ground" );
|
||||
state->blank = true;
|
||||
}
|
||||
|
||||
// prepare deserialization function table
|
||||
// since all methods use the same objects, we can have simple, hard-coded binds or lambdas for the task
|
||||
@@ -164,6 +172,7 @@ state_serializer::deserialize_continue(std::shared_ptr<deserializer_state> state
|
||||
|
||||
if( true == Global.file_binary_terrain
|
||||
&& false == state->scratchpad.binary.terrain
|
||||
&& false == state->blank
|
||||
&& state->scenariofile != "$.scn" ) {
|
||||
// if we didn't find usable binary version of the scenario files, create them now for future use
|
||||
// as long as the scenario file wasn't rainsted-created base file override
|
||||
|
||||
@@ -16,6 +16,8 @@ namespace simulation {
|
||||
|
||||
struct deserializer_state {
|
||||
std::string scenariofile;
|
||||
// the named scenery has no file on disk: the world is empty, so there's nothing to compile to SBT
|
||||
bool blank{ false };
|
||||
cParser input;
|
||||
scene::scratch_data scratchpad;
|
||||
using deserializefunctionbind = std::function<void()>;
|
||||
|
||||
Reference in New Issue
Block a user