allow for multiple isolated segments in track

This commit is contained in:
milek7
2022-06-22 00:46:28 +02:00
parent be22d2d093
commit a712cf1e64
4 changed files with 26 additions and 20 deletions

View File

@@ -853,7 +853,7 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
{ // obwód izolowany, do którego tor należy { // obwód izolowany, do którego tor należy
parser->getTokens(); parser->getTokens();
*parser >> token; *parser >> token;
pIsolated = TIsolated::Find(token); Isolated.push_back(TIsolated::Find(token));
} }
else if (str == "angle1") else if (str == "angle1")
{ // kąt ścięcia końca od strony 1 { // kąt ścięcia końca od strony 1
@@ -922,13 +922,11 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
str = token; str = token;
} }
// alternatywny zapis nazwy odcinka izolowanego - po znaku "@" w nazwie toru // alternatywny zapis nazwy odcinka izolowanego - po znaku "@" w nazwie toru
if (!pIsolated) if ((i = m_name.find("@")) != std::string::npos && i < m_name.length())
if ((i = m_name.find("@")) != std::string::npos) {
if (i < m_name.length()) // nie może być puste 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
pIsolated = TIsolated::Find(m_name.substr(i + 1, m_name.length())); }
m_name = m_name.substr(0, i - 1); // usunięcie z nazwy
}
// calculate path location // calculate path location
location( ( location( (
@@ -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ń { // podaje nazwę odcinka izolowanego, jesli nie ma on jeszcze przypisanych zdarzeń
if (pIsolated) for (const TIsolated *iso : Isolated)
if (!pIsolated->evBusy && !pIsolated->evFree) if (!iso->evBusy && !iso->evFree)
return pIsolated->asName; return iso->asName;
return ""; return "";
}; };
@@ -2333,8 +2331,8 @@ TTrack::export_as_text_( std::ostream &Output ) const {
Output << "velocity " << fVelocity << ' '; Output << "velocity " << fVelocity << ' ';
} }
} }
if( pIsolated ) { for( const TIsolated *iso : Isolated ) {
Output << "isolated " << pIsolated->asName << ' '; Output << "isolated " << iso->asName << ' ';
} }
if( fOverhead != -1.0 ) { if( fOverhead != -1.0 ) {
Output << "overhead " << fOverhead << ' '; Output << "overhead " << fOverhead << ' ';

View File

@@ -153,7 +153,7 @@ class TTrack : public scene::basic_node
friend itemproperties_panel; friend itemproperties_panel;
private: 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<TSwitchExtension> SwitchExtension; // dodatkowe dane do toru, który jest zwrotnicą
std::shared_ptr<TSegment> Segment; std::shared_ptr<TSegment> Segment;
TTrack * trNext = nullptr; // odcinek od strony punktu 2 - to powinno być w segmencie TTrack * trNext = nullptr; // odcinek od strony punktu 2 - to powinno być w segmencie
@@ -300,9 +300,9 @@ public:
void RadioStop(); void RadioStop();
void AxleCounter(int i, TDynamicObject *o) { void AxleCounter(int i, TDynamicObject *o) {
if (pIsolated) for (TIsolated *iso : Isolated)
pIsolated->Modify(i, o); }; // dodanie lub odjęcie osi iso->Modify(i, o); }; // dodanie lub odjęcie osi
std::string IsolatedName(); std::string RemoteIsolatedName();
double WidthTotal(); double WidthTotal();
bool IsGroupable(); bool IsGroupable();
int TestPoint( Math3D::vector3 *Point); int TestPoint( Math3D::vector3 *Point);

View File

@@ -109,9 +109,17 @@ itemproperties_panel::update( scene::basic_node const *Node ) {
else if( typeid( *node ) == typeid( TTrack ) ) { else if( typeid( *node ) == typeid( TTrack ) ) {
auto const *subnode = static_cast<TTrack const *>( node ); 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 // basic attributes
textline = 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 ) + "\nvelocity: " + to_string( subnode->SwitchExtension ? subnode->SwitchExtension->fVelocity : subnode->fVelocity )
+ "\nwidth: " + to_string( subnode->fTrackWidth ) + " m" + "\nwidth: " + to_string( subnode->fTrackWidth ) + " m"
+ "\nfriction: " + to_string( subnode->fFriction, 2 ) + "\nfriction: " + to_string( subnode->fFriction, 2 )

View File

@@ -371,7 +371,7 @@ WyslijObsadzone()
r.fPar[ 16 * i + 5 ] = vehicle->GetPosition().y; r.fPar[ 16 * i + 5 ] = vehicle->GetPosition().y;
r.fPar[ 16 * i + 6 ] = vehicle->GetPosition().z; r.fPar[ 16 * i + 6 ] = vehicle->GetPosition().z;
r.iPar[ 16 * i + 7 ] = static_cast<int>( vehicle->Mechanik->action() ); 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() ); strcpy( r.cString + 64 * i + 48, vehicle->Mechanik->TrainName().c_str() );
i++; i++;
if( i > 30 ) break; if( i > 30 ) break;