mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-04 14:55:52 +01:00
refactor(editor): a signal head tells the next one shows stop by its chambers alone, an orange light above the red one, not by the events of its template reading the next signal, which the templates of the old sceneries lack
This commit is contained in:
@@ -1920,7 +1920,6 @@ class editor_mode : public application_mode, private editor_track::observer, pri
|
|||||||
bool plate{false};
|
bool plate{false};
|
||||||
bool linked{false};
|
bool linked{false};
|
||||||
std::vector<int> speeds;
|
std::vector<int> speeds;
|
||||||
bool informs{false};
|
|
||||||
};
|
};
|
||||||
struct signal_spot
|
struct signal_spot
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ bool editor_mode::signal_scan(bool const Wait)
|
|||||||
if (parameter.id == 7)
|
if (parameter.id == 7)
|
||||||
item.linked = true;
|
item.linked = true;
|
||||||
}
|
}
|
||||||
editor_includes::signal_speeds(entry.file, item.speeds, item.informs);
|
editor_includes::signal_speeds(entry.file, item.speeds);
|
||||||
tool.templates.push_back(std::move(item));
|
tool.templates.push_back(std::move(item));
|
||||||
}
|
}
|
||||||
std::sort(tool.templates.begin(), tool.templates.end(), [](signal_template const &A, signal_template const &B) {
|
std::sort(tool.templates.begin(), tool.templates.end(), [](signal_template const &A, signal_template const &B) {
|
||||||
@@ -912,7 +912,7 @@ bool editor_mode::signal_heads(std::vector<signal_head> &Heads, bool const Wait)
|
|||||||
if (item.lamps.empty())
|
if (item.lamps.empty())
|
||||||
continue;
|
continue;
|
||||||
auto const kind{kind_index(item.kind)};
|
auto const kind{kind_index(item.kind)};
|
||||||
Heads.push_back({item.file, item.name, item.kind, item.mount, item.lamps, item.speeds, item.informs, kind >= 0 && m_signal.chosen[kind] == index});
|
Heads.push_back({item.file, item.name, item.kind, item.mount, item.lamps, item.speeds, kind >= 0 && m_signal.chosen[kind] == index});
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -302,15 +302,16 @@ bool has_speed(std::vector<int> const &Speeds, int const Speed)
|
|||||||
return std::find(Speeds.begin(), Speeds.end(), Speed) != Speeds.end();
|
return std::find(Speeds.begin(), Speeds.end(), Speed) != Speeds.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
// the template has the lights the need takes: a lower orange one for a lower speed, a strip for 60 and 100, Ie-1 § 7, two orange
|
// the template has the lights the need takes, by its chambers: an orange one to tell the next signal shows stop, a lower orange one
|
||||||
// ones to show a lower speed with the next signal at stop
|
// for a lower speed, a strip for 60 and 100 by the speeds its events set, Ie-1 § 7, two orange ones to show a lower speed with the
|
||||||
|
// next signal at stop
|
||||||
bool shows(signal_head const &Head, head_need const &Need)
|
bool shows(signal_head const &Head, head_need const &Need)
|
||||||
{
|
{
|
||||||
auto const &lamps{Head.lamps};
|
auto const &lamps{Head.lamps};
|
||||||
auto const count = [&](char const Lamp) { return std::count(lamps.begin(), lamps.end(), Lamp); };
|
auto const count = [&](char const Lamp) { return std::count(lamps.begin(), lamps.end(), Lamp); };
|
||||||
if (count('z') == 0 || count('c') == 0 || (Need.white && count('b') == 0))
|
if (count('z') == 0 || count('c') == 0 || (Need.white && count('b') == 0))
|
||||||
return false;
|
return false;
|
||||||
if (Need.informs && (false == Head.informs || count('p') == 0))
|
if (Need.informs && count('p') == 0)
|
||||||
return false;
|
return false;
|
||||||
if (Need.speeds.empty())
|
if (Need.speeds.empty())
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -115,7 +115,6 @@ struct signal_head
|
|||||||
std::string mount;
|
std::string mount;
|
||||||
std::string lamps; // its chambers from the top: z green, c red, p orange, b white, n blue, x blind
|
std::string lamps; // its chambers from the top: z green, c red, p orange, b white, n blue, x blind
|
||||||
std::vector<int> speeds; // of the signal itself, km/h: -1 the highest allowed, 20 the substitute signal
|
std::vector<int> speeds; // of the signal itself, km/h: -1 the highest allowed, 20 the substitute signal
|
||||||
bool informs{false}; // it tells the next signal shows stop
|
|
||||||
bool chosen{false}; // the Signals tool places it for its kind
|
bool chosen{false}; // the Signals tool places it for its kind
|
||||||
};
|
};
|
||||||
// one step of the history of the signalling: signals placed, standing ones renamed, other templates placed with them, the values
|
// one step of the history of the signalling: signals placed, standing ones renamed, other templates placed with them, the values
|
||||||
|
|||||||
@@ -501,10 +501,9 @@ int parameter_count(std::string const &File)
|
|||||||
return read_template(File, text, error) ? count_parameters(text) : 0;
|
return read_template(File, text, error) ? count_parameters(text) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool signal_speeds(std::string const &File, std::vector<int> &Speeds, bool &Informs)
|
bool signal_speeds(std::string const &File, std::vector<int> &Speeds)
|
||||||
{
|
{
|
||||||
Speeds.clear();
|
Speeds.clear();
|
||||||
Informs = false;
|
|
||||||
template_text text;
|
template_text text;
|
||||||
std::string error;
|
std::string error;
|
||||||
if (false == read_template(File, text, error))
|
if (false == read_template(File, text, error))
|
||||||
@@ -522,23 +521,17 @@ bool signal_speeds(std::string const &File, std::vector<int> &Speeds, bool &Info
|
|||||||
Speed = static_cast<int>(std::lround(value));
|
Speed = static_cast<int>(std::lround(value));
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
for (std::size_t idx = 0; idx + 2 < tokens.size(); ++idx)
|
for (std::size_t idx = 0; idx + 1 < tokens.size(); ++idx)
|
||||||
{
|
{
|
||||||
if (tokens[idx] != "setvelocity")
|
if (tokens[idx] != "setvelocity")
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int own{0};
|
int own{0};
|
||||||
int next{0};
|
if (speed(tokens[idx + 1], own) && own != 0 && std::find(Speeds.begin(), Speeds.end(), own) == Speeds.end())
|
||||||
auto const shown{speed(tokens[idx + 1], own)};
|
|
||||||
if (shown && own != 0 && std::find(Speeds.begin(), Speeds.end(), own) == Speeds.end())
|
|
||||||
{
|
{
|
||||||
Speeds.push_back(own);
|
Speeds.push_back(own);
|
||||||
}
|
}
|
||||||
if (speed(tokens[idx + 2], next) && next == 0 && (tokens[idx + 1] == "*" || (shown && own != 0 && own != 20)))
|
|
||||||
{
|
|
||||||
Informs = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
std::sort(Speeds.begin(), Speeds.end());
|
std::sort(Speeds.begin(), Speeds.end());
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -69,8 +69,8 @@ bool save(std::string const &File, include_info const &Info, std::string &Error)
|
|||||||
// highest number of (pN) placeholder used by specified template, 0 if it has none
|
// highest number of (pN) placeholder used by specified template, 0 if it has none
|
||||||
int parameter_count(std::string const &File);
|
int parameter_count(std::string const &File);
|
||||||
// the speeds the events of a signal template set it to show, by their SetVelocity: of the signal itself, km/h, -1 the highest
|
// the speeds the events of a signal template set it to show, by their SetVelocity: of the signal itself, km/h, -1 the highest
|
||||||
// allowed, 20 the substitute signal. Informs: one of them tells the next signal shows stop. returns: false if the file can't be read
|
// allowed, 20 the substitute signal. returns: false if the file can't be read
|
||||||
bool signal_speeds(std::string const &File, std::vector<int> &Speeds, bool &Informs);
|
bool signal_speeds(std::string const &File, std::vector<int> &Speeds);
|
||||||
// sets roles of the parameters whose use in the template makes their meaning clear. roles already set are left alone
|
// sets roles of the parameters whose use in the template makes their meaning clear. roles already set are left alone
|
||||||
void suggest(std::string const &File, include_info &Info);
|
void suggest(std::string const &File, include_info &Info);
|
||||||
// true if value of a parameter with specified role is supplied by the editor when the template is placed
|
// true if value of a parameter with specified role is supplied by the editor when the template is placed
|
||||||
|
|||||||
Reference in New Issue
Block a user