mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
allow for multiple isolated segments in track
This commit is contained in:
20
Track.cpp
20
Track.cpp
@@ -853,7 +853,7 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
|
||||
{ // obwód izolowany, do którego tor należy
|
||||
parser->getTokens();
|
||||
*parser >> token;
|
||||
pIsolated = TIsolated::Find(token);
|
||||
Isolated.push_back(TIsolated::Find(token));
|
||||
}
|
||||
else if (str == "angle1")
|
||||
{ // kąt ścięcia końca od strony 1
|
||||
@@ -922,11 +922,9 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
|
||||
str = token;
|
||||
}
|
||||
// alternatywny zapis nazwy odcinka izolowanego - po znaku "@" w nazwie toru
|
||||
if (!pIsolated)
|
||||
if ((i = m_name.find("@")) != std::string::npos)
|
||||
if (i < m_name.length()) // nie może być puste
|
||||
if ((i = m_name.find("@")) != std::string::npos && i < m_name.length())
|
||||
{
|
||||
pIsolated = TIsolated::Find(m_name.substr(i + 1, m_name.length()));
|
||||
Isolated.push_back(TIsolated::Find(m_name.substr(i + 1, m_name.length())));
|
||||
m_name = m_name.substr(0, i - 1); // usunięcie z nazwy
|
||||
}
|
||||
|
||||
@@ -1010,11 +1008,11 @@ void TTrack::QueueEvents( event_sequence const &Events, TDynamicObject const *Ow
|
||||
}
|
||||
}
|
||||
|
||||
std::string TTrack::IsolatedName()
|
||||
std::string TTrack::RemoteIsolatedName()
|
||||
{ // podaje nazwę odcinka izolowanego, jesli nie ma on jeszcze przypisanych zdarzeń
|
||||
if (pIsolated)
|
||||
if (!pIsolated->evBusy && !pIsolated->evFree)
|
||||
return pIsolated->asName;
|
||||
for (const TIsolated *iso : Isolated)
|
||||
if (!iso->evBusy && !iso->evFree)
|
||||
return iso->asName;
|
||||
return "";
|
||||
};
|
||||
|
||||
@@ -2333,8 +2331,8 @@ TTrack::export_as_text_( std::ostream &Output ) const {
|
||||
Output << "velocity " << fVelocity << ' ';
|
||||
}
|
||||
}
|
||||
if( pIsolated ) {
|
||||
Output << "isolated " << pIsolated->asName << ' ';
|
||||
for( const TIsolated *iso : Isolated ) {
|
||||
Output << "isolated " << iso->asName << ' ';
|
||||
}
|
||||
if( fOverhead != -1.0 ) {
|
||||
Output << "overhead " << fOverhead << ' ';
|
||||
|
||||
8
Track.h
8
Track.h
@@ -153,7 +153,7 @@ class TTrack : public scene::basic_node
|
||||
friend itemproperties_panel;
|
||||
|
||||
private:
|
||||
TIsolated * pIsolated = nullptr; // obwód izolowany obsługujący zajęcia/zwolnienia grupy torów
|
||||
std::vector<TIsolated*> Isolated; // obwód izolowany obsługujący zajęcia/zwolnienia grupy torów
|
||||
std::shared_ptr<TSwitchExtension> SwitchExtension; // dodatkowe dane do toru, który jest zwrotnicą
|
||||
std::shared_ptr<TSegment> Segment;
|
||||
TTrack * trNext = nullptr; // odcinek od strony punktu 2 - to powinno być w segmencie
|
||||
@@ -300,9 +300,9 @@ public:
|
||||
|
||||
void RadioStop();
|
||||
void AxleCounter(int i, TDynamicObject *o) {
|
||||
if (pIsolated)
|
||||
pIsolated->Modify(i, o); }; // dodanie lub odjęcie osi
|
||||
std::string IsolatedName();
|
||||
for (TIsolated *iso : Isolated)
|
||||
iso->Modify(i, o); }; // dodanie lub odjęcie osi
|
||||
std::string RemoteIsolatedName();
|
||||
double WidthTotal();
|
||||
bool IsGroupable();
|
||||
int TestPoint( Math3D::vector3 *Point);
|
||||
|
||||
@@ -109,9 +109,17 @@ itemproperties_panel::update( scene::basic_node const *Node ) {
|
||||
else if( typeid( *node ) == typeid( TTrack ) ) {
|
||||
|
||||
auto const *subnode = static_cast<TTrack const *>( node );
|
||||
|
||||
std::string isolatedlist;
|
||||
for (const TIsolated *iso : subnode->Isolated) {
|
||||
if (!isolatedlist.empty())
|
||||
isolatedlist += ", ";
|
||||
isolatedlist += iso->asName;
|
||||
}
|
||||
|
||||
// basic attributes
|
||||
textline =
|
||||
"isolated: " + ( ( subnode->pIsolated != nullptr ) ? Bezogonkow( subnode->pIsolated->asName ) : "(none)" )
|
||||
"isolated: " + ( !isolatedlist.empty() ? isolatedlist : "(none)" )
|
||||
+ "\nvelocity: " + to_string( subnode->SwitchExtension ? subnode->SwitchExtension->fVelocity : subnode->fVelocity )
|
||||
+ "\nwidth: " + to_string( subnode->fTrackWidth ) + " m"
|
||||
+ "\nfriction: " + to_string( subnode->fFriction, 2 )
|
||||
|
||||
@@ -371,7 +371,7 @@ WyslijObsadzone()
|
||||
r.fPar[ 16 * i + 5 ] = vehicle->GetPosition().y;
|
||||
r.fPar[ 16 * i + 6 ] = vehicle->GetPosition().z;
|
||||
r.iPar[ 16 * i + 7 ] = static_cast<int>( vehicle->Mechanik->action() );
|
||||
strcpy( r.cString + 64 * i + 32, vehicle->GetTrack()->IsolatedName().c_str() );
|
||||
strcpy( r.cString + 64 * i + 32, vehicle->GetTrack()->RemoteIsolatedName().c_str() );
|
||||
strcpy( r.cString + 64 * i + 48, vehicle->Mechanik->TrainName().c_str() );
|
||||
i++;
|
||||
if( i > 30 ) break;
|
||||
|
||||
Reference in New Issue
Block a user