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

reformat: parameters can be made const

This commit is contained in:
jerrrrycho
2026-07-04 07:08:14 +02:00
parent 6fd1d6715b
commit 220689a5e3
121 changed files with 1380 additions and 1352 deletions

View File

@@ -2351,7 +2351,7 @@ event_manager::insert( basic_event *Event ) {
return true;
}
basic_event * event_manager::FindEventById(uint32_t id)
basic_event * event_manager::FindEventById(const uint32_t id)
{
if (id < m_events.size())
return m_events[id];
@@ -2381,7 +2381,7 @@ event_manager::FindEvent( std::string const &Name )
// legacy method, inserts specified event in the event query
bool
event_manager::AddToQuery( basic_event *Event, TDynamicObject const *Owner, double delay ) {
event_manager::AddToQuery( basic_event *Event, TDynamicObject const *Owner, const double delay ) {
if( Event->m_passive ) { return false; } // jeśli może być dodany do kolejki (nie używany w skanowaniu)
if( Event->m_inqueue > 0 ) { return false; } // jeśli nie dodany jeszcze do kolejki

View File

@@ -723,7 +723,7 @@ private:
inline
void
basic_event::group( scene::group_handle Group ) {
basic_event::group(const scene::group_handle Group ) {
m_group = Group;
}

View File

@@ -304,7 +304,7 @@ glm::dvec3 TSegment::GetDirection(double const fDistance) const
return FastGetPoint(t2) - FastGetPoint(t1);
}
glm::dvec3 TSegment::FastGetDirection(double fDistance, double fOffset)
glm::dvec3 TSegment::FastGetDirection(const double fDistance, const double fOffset)
{ // takie toporne liczenie pochodnej dla parametru 0.0÷1.0
const double t1 = fDistance - fOffset;
if (t1 <= 0.0)

View File

@@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/.
#include "stdafx.h"
#include "world/Spring.h"
void TSpring::Init(double nKs, double nKd) {
void TSpring::Init(const double nKs, const double nKd) {
Ks = nKs;
Kd = nKd;
ks = Ks;

View File

@@ -117,7 +117,7 @@ TIsolated::AssignEvents() {
evDec = simulation::Events.FindEvent( asName + ":dec" );
}
void TIsolated::Modify(int i, TDynamicObject *o)
void TIsolated::Modify(const int i, TDynamicObject *o)
{ // dodanie lub odjęcie osi
if (iAxles)
{ // grupa zajęta
@@ -207,7 +207,7 @@ TTrack::sort_by_material( TTrack const *Left, TTrack const *Right ) {
return std::tie( Left->m_material1, Left->m_material2 ) < std::tie( Right->m_material1, Right->m_material2 );
}
TTrack * TTrack::Create400m(int what, double dx)
TTrack * TTrack::Create400m(const int what, const double dx)
{ // tworzenie toru do wstawiania taboru podczas konwersji na E3D
scene::node_data nodedata;
nodedata.name = "auto_400m"; // track isn't visible so only name is needed
@@ -321,7 +321,7 @@ TTrack * TTrack::NullCreate(int dir)
return trk;
};
void TTrack::ConnectPrevPrev(TTrack *pTrack, int typ)
void TTrack::ConnectPrevPrev(TTrack *pTrack, const int typ)
{ //łączenie torów - Point1 własny do Point1 cudzego
if (pTrack)
{ //(pTrack) może być zwrotnicą, a (this) tylko zwykłym odcinkiem
@@ -331,7 +331,7 @@ void TTrack::ConnectPrevPrev(TTrack *pTrack, int typ)
pTrack->iPrevDirection = 0;
}
}
void TTrack::ConnectPrevNext(TTrack *pTrack, int typ)
void TTrack::ConnectPrevNext(TTrack *pTrack, const int typ)
{ //łaczenie torów - Point1 własny do Point2 cudzego
if (pTrack)
{
@@ -350,7 +350,7 @@ void TTrack::ConnectPrevNext(TTrack *pTrack, int typ)
pTrack->iTrapezoid |= 2; // to rysujemy potworka
}
}
void TTrack::ConnectNextPrev(TTrack *pTrack, int typ)
void TTrack::ConnectNextPrev(TTrack *pTrack, const int typ)
{ //łaczenie torów - Point2 własny do Point1 cudzego
if (pTrack)
{
@@ -369,7 +369,7 @@ void TTrack::ConnectNextPrev(TTrack *pTrack, int typ)
iTrapezoid |= 2; // to rysujemy potworka
}
}
void TTrack::ConnectNextNext(TTrack *pTrack, int typ)
void TTrack::ConnectNextNext(TTrack *pTrack, const int typ)
{ //łaczenie torów - Point2 własny do Point2 cudzego
if (pTrack)
{
@@ -1252,7 +1252,7 @@ void TTrack::get_map_active_paths(map_colored_paths &handles)
}
}
void TTrack::get_map_paths_for_state(map_colored_paths &handles, int state)
void TTrack::get_map_paths_for_state(map_colored_paths &handles, const int state)
{
if (iCategoryFlag != 1 || eType != tt_Switch)
return;
@@ -1759,7 +1759,7 @@ void TTrack::RenderDynSounds()
}
};
//---------------------------------------------------------------------------
bool TTrack::SetConnections(int i)
bool TTrack::SetConnections(const int i)
{ // przepisanie aktualnych połączeń toru do odpowiedniego segmentu
if (SwitchExtension)
{
@@ -1887,7 +1887,7 @@ bool TTrack::Switch(int i, float const t, float const d)
return false;
};
bool TTrack::SwitchForced(int i, TDynamicObject *o)
bool TTrack::SwitchForced(const int i, TDynamicObject *o)
{ // rozprucie rozjazdu
if (SwitchExtension)
if (eType == tt_Switch)
@@ -1915,7 +1915,7 @@ bool TTrack::SwitchForced(int i, TDynamicObject *o)
return true;
};
int TTrack::CrossSegment(int from, int into)
int TTrack::CrossSegment(const int from, const int into)
{ // ustawienie wskaźnika na segement w pożądanym kierunku (into) od strony (from)
// zwraca kod segmentu, z kierunkiem jazdy jako znakiem ±
int i = 0;
@@ -2540,7 +2540,7 @@ void TTrack::MovedUp1(float const dh)
};
// ustawienie prędkości z ograniczeniem do pierwotnej wartości (zapisanej w scenerii)
void TTrack::VelocitySet(float v) {
void TTrack::VelocitySet(const float v) {
// TBD, TODO: add a variable to preserve potential speed limit set by the track configuration on basic track pieces
if( SwitchExtension
&& SwitchExtension->fVelocity != -1 ) {
@@ -2602,7 +2602,7 @@ TTrack::DoubleSlip() const {
}
TTrack * TTrack::Connected(int s, double &d) const
TTrack * TTrack::Connected(const int s, double &d) const
{ // zwraca wskaźnik na sąsiedni tor, w kierunku określonym znakiem (s), odwraca (d) w razie
// niezgodności kierunku torów
TTrack *t; // nie zmieniamy kierunku (d), jeśli nie ma toru dalej

View File

@@ -309,7 +309,7 @@ public:
TTrack * RaAnimate();
void RadioStop();
void AxleCounter(int i, TDynamicObject *o) {
void AxleCounter(const int i, TDynamicObject *o) {
for (TIsolated *iso : Isolated)
iso->Modify(i, o); }; // dodanie lub odjęcie osi
std::string RemoteIsolatedName();

View File

@@ -358,7 +358,7 @@ int TTraction::TestPoint(glm::dvec3 const &Point)
//łączenie segmentu (with) od strony (my) do jego (to)
void
TTraction::Connect(int my, TTraction *with, int to) {
TTraction::Connect(const int my, TTraction *with, const int to) {
hvNext[ my ] = with;
iNext[ my ] = to;
@@ -463,7 +463,7 @@ void TTraction::PowerSet(TTractionPowerSource *ps)
}
};
double TTraction::VoltageGet(double u, double i)
double TTraction::VoltageGet(const double u, const double i)
{ // pobranie napięcia na przęśle po podłączeniu do niego rezystancji (res) - na razie jest to prąd
if (!psSection)
if (!psPowered)

View File

@@ -71,7 +71,7 @@ bool TTractionPowerSource::Load(cParser *parser) {
return true;
};
bool TTractionPowerSource::Update(double dt)
bool TTractionPowerSource::Update(const double dt)
{ // powinno być wykonane raz na krok fizyki
// iloczyn napięcia i admitancji daje prąd
if( FastFuse || SlowFuse ) {
@@ -114,7 +114,7 @@ bool TTractionPowerSource::Update(double dt)
return true;
};
double TTractionPowerSource::CurrentGet(double res)
double TTractionPowerSource::CurrentGet(const double res)
{ // pobranie wartości prądu przypadającego na rezystancję (res)
// niech pamięta poprzednią admitancję i wg niej przydziela prąd
if (SlowFuse || FastFuse)

View File

@@ -26,7 +26,7 @@ TTrackFollower::~TTrackFollower()
{
}
bool TTrackFollower::Init(TTrack *pTrack, TDynamicObject *NewOwner, double fDir)
bool TTrackFollower::Init(TTrack *pTrack, TDynamicObject *NewOwner, const double fDir)
{
fDirection = fDir;
Owner = NewOwner;
@@ -44,7 +44,7 @@ void TTrackFollower::Reset()
fDirection = 1.0;
}
TTrack * TTrackFollower::SetCurrentTrack(TTrack *pTrack, int end)
TTrack * TTrackFollower::SetCurrentTrack(TTrack *pTrack, const int end)
{ // przejechanie na inny odcinkek toru, z ewentualnym rozpruciem
if (pTrack)
switch (pTrack->eType)
@@ -97,7 +97,7 @@ TTrack * TTrackFollower::SetCurrentTrack(TTrack *pTrack, int end)
return pCurrentTrack;
};
bool TTrackFollower::Move(double fDistance, bool bPrimary)
bool TTrackFollower::Move(double fDistance, const bool bPrimary)
{ // przesuwanie wózka po torach o odległość (fDistance), z wyzwoleniem eventów
// bPrimary=true - jest pierwszą osią w pojeździe, czyli generuje eventy i przepisuje pojazd
// Ra: zwraca false, jeśli pojazd ma być usunięty

View File

@@ -22,7 +22,7 @@ double TTrainParameters::CheckTrainLatency()
return 0;
}
double TTrainParameters::WatchMTable(double DistCounter)
double TTrainParameters::WatchMTable(const double DistCounter)
{ // zwraca odleglość do najblizszej stacji z zatrzymaniem
double dist;
@@ -105,7 +105,7 @@ bool TTrainParameters::UpdateMTable( scenario_time const &Time, std::string cons
return UpdateMTable( Time.data().wHour, Time.data().wMinute + Time.data().wSecond * 0.0167, NewName );
}
bool TTrainParameters::UpdateMTable(double hh, double mm, std::string const &NewName)
bool TTrainParameters::UpdateMTable(const double hh, const double mm, std::string const &NewName)
/*odfajkowanie dojechania do stacji (NewName) i przeliczenie opóźnienia*/
{
bool OK;
@@ -163,7 +163,7 @@ void TTrainParameters::StationIndexInc()
++StationIndex;
}
bool TTrainParameters::IsTimeToGo(double hh, double mm)
bool TTrainParameters::IsTimeToGo(const double hh, const double mm)
// sprawdzenie, czy można już odjechać z aktualnego zatrzymania
// StationIndex to numer następnego po dodarciu do aktualnego
{
@@ -231,7 +231,7 @@ void TTrainParameters::NewName(std::string const &NewTrainName)
LocLoad = 0;
}
void TTrainParameters::UpdateVelocity(int StationCount, double vActual)
void TTrainParameters::UpdateVelocity(const int StationCount, const double vActual)
// zapisywanie prędkości maksymalnej do wcześniejszych odcinków
// wywoływane z numerem ostatniego przetworzonego przystanku
{
@@ -674,7 +674,7 @@ void TTrainParameters::serialize( dictionary_source *Output ) const {
}
}
void TMTableTime::UpdateMTableTime(double deltaT)
void TMTableTime::UpdateMTableTime(const double deltaT)
// dodanie czasu (deltaT) w sekundach, z przeliczeniem godziny
{
mr += deltaT; // dodawanie sekund

View File

@@ -105,7 +105,7 @@ class TMTableTime
int mm = 0;
double mr = 0.0;
void UpdateMTableTime(double deltaT);
TMTableTime(int InitH, int InitM ) :
TMTableTime(const int InitH, const int InitM ) :
hh( InitH ),
mm( InitM )
{}