16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-17 23:39:18 +02:00

root scenegroup, map.manualswitchcontrol feature

This commit is contained in:
milek7
2020-10-19 19:18:44 +02:00
parent 181249b1e7
commit f96575ac79
4 changed files with 52 additions and 16 deletions

View File

@@ -1162,6 +1162,10 @@ global_settings::ConfigParse(cParser &Parser) {
Parser >> exec_on_exit;
std::replace(std::begin(exec_on_exit), std::end(exec_on_exit), '_', ' ');
}
else if (token == "map.manualswitchcontrol") {
Parser.getTokens(1);
Parser >> map_manualswitchcontrol;
}
/*
else if (token == "crashdamage") {
Parser.getTokens(1);

View File

@@ -296,6 +296,8 @@ struct global_settings {
glm::vec3 viewport_move;
glm::mat3 viewport_rotate;
bool map_manualswitchcontrol = false;;
std::vector<std::pair<std::string, std::string>> network_servers;
std::optional<std::pair<std::string, std::string>> network_client;
float desync = 0.0f;

View File

@@ -86,25 +86,50 @@ node_groups::update_map()
if (string_starts_with(model->name(), sem_name))
sem_info->models.push_back(model);
}
if (TEventLauncher *launcher = dynamic_cast<TEventLauncher*>(node)) {
if (!launcher || !launcher->Event1 || !launcher->Event2)
continue;
auto map_launcher = std::make_shared<map::launcher>();
map::Objects.entries.push_back(map_launcher);
if (Global.map_manualswitchcontrol) {
if (TTrack *track = dynamic_cast<TTrack*>(node)) {
if (track->eType != tt_Switch)
continue;
map_launcher->location = node->location();
map_launcher->name = node->name();
map_launcher->first_event = launcher->Event1;
map_launcher->second_event = launcher->Event2;
if (map_launcher->name.empty())
map_launcher->name = launcher->Event1->name();
basic_event *sw_straight = simulation::Events.FindEvent(track->name() + "+");
basic_event *sw_divert = simulation::Events.FindEvent(track->name() + "-");
if (launcher->Event1->name().find_first_of("-+:") != std::string::npos)
map_launcher->type = map::launcher::track_switch;
else
map_launcher->type = map::launcher::level_crossing;
}
if (sw_straight && sw_divert) {
auto map_launcher = std::make_shared<map::launcher>();
map::Objects.entries.push_back(map_launcher);
map_launcher->location = node->location();
map_launcher->name = node->name();
map_launcher->first_event = sw_straight;
map_launcher->second_event = sw_divert;
if (map_launcher->name.empty())
map_launcher->name = sw_straight->name();
map_launcher->type = map::launcher::track_switch;
}
}
} else {
if (TEventLauncher *launcher = dynamic_cast<TEventLauncher*>(node)) {
if (!launcher || !launcher->Event1 || !launcher->Event2)
continue;
auto map_launcher = std::make_shared<map::launcher>();
map::Objects.entries.push_back(map_launcher);
map_launcher->location = node->location();
map_launcher->name = node->name();
map_launcher->first_event = launcher->Event1;
map_launcher->second_event = launcher->Event2;
if (map_launcher->name.empty())
map_launcher->name = launcher->Event1->name();
if (launcher->Event1->name().find_first_of("-+:") != std::string::npos)
map_launcher->type = map::launcher::track_switch;
else
map_launcher->type = map::launcher::level_crossing;
}
}
}
}
}

View File

@@ -53,6 +53,8 @@ state_serializer::deserialize_begin( std::string const &Scenariofile ) {
state->scratchpad.binary.terrain = Region->is_scene( Scenariofile ) ;
}
scene::Groups.create();
if( false == state->input.ok() )
throw invalid_scenery_exception();
@@ -124,6 +126,9 @@ state_serializer::deserialize_continue(std::shared_ptr<deserializer_state> state
// manually perform scenario initialization
deserialize_firstinit( Input, Scratchpad );
}
scene::Groups.close();
scene::Groups.update_map();
Region->create_map_geometry();