16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-21 17:09:19 +02:00

Replace starts_with and ends_with with string class methods

This commit is contained in:
docentYT
2026-05-01 17:31:11 +02:00
parent 9c27b54960
commit ec1dfae953
15 changed files with 29 additions and 50 deletions

View File

@@ -298,7 +298,7 @@ basic_event::deserialize( cParser &Input, scene::scratch_data &Scratchpad ) {
Input >> token;
deserialize_targets( token );
if( starts_with( m_name, "none_" ) ) {
if( m_name.starts_with("none_") ) {
m_ignored = true; // Ra: takie są ignorowane
}
@@ -716,7 +716,7 @@ putvalues_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad )
Input.getTokens( 1, false ); // komendy 'case sensitive'
Input >> token;
// command type, previously held in param 6
if( starts_with( token, "PassengerStopPoint:" ) ) {
if( token.starts_with("PassengerStopPoint:") ) {
if( contains( token, '#' ) ) {
token.erase( token.find( '#' ) ); // obcięcie unikatowości
}
@@ -835,8 +835,9 @@ putvalues_event::export_as_text_( std::ostream &Output ) const {
bool
putvalues_event::is_command_for_owner( input_data const &Input ) const {
if( starts_with( Input.data_text, "Load=" ) ) { return false; }
if( starts_with( Input.data_text, "UnLoad=" ) ) { return false; }
if (Input.data_text.starts_with("Load=") || Input.data_text.starts_with("UnLoad=")) {
return false;
}
// TBD, TODO: add other exceptions
return true;
@@ -1268,7 +1269,7 @@ multi_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) {
}
else {
// potentially valid event name
if( starts_with( token, "none_" ) ) {
if( token.starts_with("none_") ) {
// eventy rozpoczynające się od "none_" są ignorowane
WriteLog( "Multi-event \"" + m_name + "\" ignored link to event \"" + token + "\"" );
}
@@ -1650,7 +1651,7 @@ animation_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad )
>> m_animationparams[ 2 ]
>> m_animationparams[ 3 ];
}
else if( ends_with( token, ".vmd" ) ) // na razie tu, może będzie inaczej
else if( token.ends_with(".vmd") ) // na razie tu, może będzie inaczej
{ // animacja z pliku VMD
{
m_animationfilename = token;
@@ -2305,15 +2306,15 @@ event_manager::insert( basic_event *Event ) {
return false;
}
// tymczasowo wyjątki:
else if( ends_with( Event->m_name, "lineinfo:" ) ) {
else if( Event->m_name.ends_with("lineinfo:") ) {
// tymczasowa utylizacja duplikatów W5
return false;
}
else if( ends_with( Event->m_name, "_warning" ) ) {
else if( Event->m_name.ends_with("_warning") ) {
// tymczasowa utylizacja duplikatu z trąbieniem
return false;
}
else if( ends_with( Event->m_name, "_shp" ) ) {
else if( Event->m_name.ends_with("_shp") ) {
// nie podlegają logowaniu
// tymczasowa utylizacja duplikatu SHP
return false;

View File

@@ -71,7 +71,7 @@ TCommandType TMemCell::CommandCheck()
eCommand = TCommandType::cm_OutsideStation;
bCommand = false; // tego nie powinno być w komórce
}
else if( starts_with( szText, "PassengerStopPoint:" ) ) // porównanie początków
else if( szText.starts_with("PassengerStopPoint:") ) // porównanie początków
{
eCommand = TCommandType::cm_PassengerStopPoint;
bCommand = false; // tego nie powinno być w komórce

View File

@@ -611,7 +611,7 @@ TTrainParameters::load_sounds() {
}
// specified arrival time means it's a scheduled stop
auto const stationname { (
ends_with( station.StationName, "_po" ) ?
station.StationName.ends_with("_po") ?
station.StationName.substr( 0, station.StationName.size() - 3 ) :
station.StationName ) };

View File

@@ -29,9 +29,7 @@ basic_station::update_load( TDynamicObject *First, Mtable::TTrainParameters &Sch
// HACK: determine whether current station is a (small) stop from the presence of "po" at the name end
auto const stationname { Schedule.TimeTable[ Schedule.StationIndex ].StationName };
auto const stationequipment { Schedule.TimeTable[ Schedule.StationIndex ].StationWare };
auto const trainstop { (
( ends_with( stationname, "po" ) )
|| ( contains( stationequipment, "po" ) ) ) };
auto const trainstop {stationname.ends_with("po") || contains( stationequipment, "po" ) };
auto const maintenancestop { ( contains( stationequipment, "pt" ) ) };
// train stops exchange smaller groups than regular stations
// NOTE: this is crude and unaccurate, but for now will do