mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 16:19:19 +02:00
build 170505. stl-based speed table replacement
This commit is contained in:
796
Driver.cpp
796
Driver.cpp
File diff suppressed because it is too large
Load Diff
34
Driver.h
34
Driver.h
@@ -102,6 +102,7 @@ enum TAction
|
|||||||
|
|
||||||
enum TSpeedPosFlag
|
enum TSpeedPosFlag
|
||||||
{ // wartości dla iFlag w TSpeedPos
|
{ // wartości dla iFlag w TSpeedPos
|
||||||
|
spNone = 0x0,
|
||||||
spEnabled = 0x1, // pozycja brana pod uwagę
|
spEnabled = 0x1, // pozycja brana pod uwagę
|
||||||
spTrack = 0x2, // to jest tor
|
spTrack = 0x2, // to jest tor
|
||||||
spReverse = 0x4, // odwrotnie
|
spReverse = 0x4, // odwrotnie
|
||||||
@@ -126,11 +127,11 @@ enum TSpeedPosFlag
|
|||||||
class TSpeedPos
|
class TSpeedPos
|
||||||
{ // pozycja tabeli prędkości dla AI
|
{ // pozycja tabeli prędkości dla AI
|
||||||
public:
|
public:
|
||||||
double fDist; // aktualna odległość (ujemna gdy minięte)
|
double fDist{ 0.0 }; // aktualna odległość (ujemna gdy minięte)
|
||||||
double fVelNext; // prędkość obowiązująca od tego miejsca
|
double fVelNext{ -1.0 }; // prędkość obowiązująca od tego miejsca
|
||||||
double fSectionVelocityDist; // długość ograniczenia prędkości
|
double fSectionVelocityDist{ 0.0 }; // długość ograniczenia prędkości
|
||||||
// double fAcc;
|
// double fAcc;
|
||||||
int iFlags; // flagi typu wpisu do tabelki
|
int iFlags{ spNone }; // flagi typu wpisu do tabelki
|
||||||
// 1=istotny,2=tor,4=odwrotnie,8-zwrotnica (może się zmienić),16-stan
|
// 1=istotny,2=tor,4=odwrotnie,8-zwrotnica (może się zmienić),16-stan
|
||||||
// zwrotnicy,32-minięty,64=koniec,128=łuk
|
// zwrotnicy,32-minięty,64=koniec,128=łuk
|
||||||
// 0x100=event,0x200=manewrowa,0x400=przystanek,0x800=SBL,0x1000=wysłana komenda,0x2000=W5
|
// 0x100=event,0x200=manewrowa,0x400=przystanek,0x800=SBL,0x1000=wysłana komenda,0x2000=W5
|
||||||
@@ -138,8 +139,8 @@ class TSpeedPos
|
|||||||
vector3 vPos; // współrzędne XYZ do liczenia odległości
|
vector3 vPos; // współrzędne XYZ do liczenia odległości
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
TTrack *trTrack; // wskaźnik na tor o zmiennej prędkości (zwrotnica, obrotnica)
|
TTrack *trTrack{ nullptr }; // wskaźnik na tor o zmiennej prędkości (zwrotnica, obrotnica)
|
||||||
TEvent *evEvent; // połączenie z eventem albo komórką pamięci
|
TEvent *evEvent{ nullptr }; // połączenie z eventem albo komórką pamięci
|
||||||
};
|
};
|
||||||
void CommandCheck();
|
void CommandCheck();
|
||||||
|
|
||||||
@@ -166,16 +167,25 @@ extern bool WriteLogFlag; // logowanie parametrów fizycznych
|
|||||||
class TController
|
class TController
|
||||||
{
|
{
|
||||||
private: // obsługa tabelki prędkości (musi mieć możliwość odhaczania stacji w rozkładzie)
|
private: // obsługa tabelki prędkości (musi mieć możliwość odhaczania stacji w rozkładzie)
|
||||||
|
#ifdef EU07_USE_OLD_SPEEDTABLE
|
||||||
TSpeedPos *sSpeedTable = nullptr; // najbliższe zmiany prędkości
|
TSpeedPos *sSpeedTable = nullptr; // najbliższe zmiany prędkości
|
||||||
int iSpeedTableSize = 16; // wielkość tabelki
|
int iSpeedTableSize = 16; // wielkość tabelki
|
||||||
int iFirst = 0; // aktualna pozycja w tabeli (modulo iSpeedTableSize)
|
int iFirst = 0; // aktualna pozycja w tabeli (modulo iSpeedTableSize)
|
||||||
int iLast = 0; // ostatnia wypełniona pozycja w tabeli <iFirst (modulo iSpeedTableSize)
|
#else
|
||||||
int iTableDirection = 0; // kierunek zapełnienia tabelki względem pojazdu z AI
|
int iLast{ 0 }; // ostatnia wypełniona pozycja w tabeli <iFirst (modulo iSpeedTableSize)
|
||||||
|
int iTableDirection{ 0 }; // kierunek zapełnienia tabelki względem pojazdu z AI
|
||||||
|
std::vector<TSpeedPos> sSpeedTable;
|
||||||
|
#endif
|
||||||
double fLastVel = 0.0; // prędkość na poprzednio sprawdzonym torze
|
double fLastVel = 0.0; // prędkość na poprzednio sprawdzonym torze
|
||||||
TTrack *tLast = nullptr; // ostatni analizowany tor
|
TTrack *tLast = nullptr; // ostatni analizowany tor
|
||||||
TEvent *eSignSkip = nullptr; // można pominąć ten SBL po zatrzymaniu
|
TEvent *eSignSkip = nullptr; // można pominąć ten SBL po zatrzymaniu
|
||||||
|
#ifdef EU07_USE_OLD_SPEEDTABLE
|
||||||
TSpeedPos *sSemNext = nullptr; // następny semafor na drodze zależny od trybu jazdy
|
TSpeedPos *sSemNext = nullptr; // następny semafor na drodze zależny od trybu jazdy
|
||||||
TSpeedPos *sSemNextStop = nullptr; // następny semafor na drodze zależny od trybu jazdy i na stój
|
TSpeedPos *sSemNextStop = nullptr; // następny semafor na drodze zależny od trybu jazdy i na stój
|
||||||
|
#else
|
||||||
|
std::size_t SemNextIndex{ -1 };
|
||||||
|
std::size_t SemNextStopIndex{ -1 };
|
||||||
|
#endif
|
||||||
private: // parametry aktualnego składu
|
private: // parametry aktualnego składu
|
||||||
double fLength = 0.0; // długość składu (do wyciągania z ograniczeń)
|
double fLength = 0.0; // długość składu (do wyciągania z ograniczeń)
|
||||||
double fMass = 0.0; // całkowita masa do liczenia stycznej składowej grawitacji
|
double fMass = 0.0; // całkowita masa do liczenia stycznej składowej grawitacji
|
||||||
@@ -358,13 +368,15 @@ class TController
|
|||||||
TEvent *CheckTrackEvent(double fDirection, TTrack *Track);
|
TEvent *CheckTrackEvent(double fDirection, TTrack *Track);
|
||||||
bool TableCheckEvent(TEvent *e);
|
bool TableCheckEvent(TEvent *e);
|
||||||
bool TableAddNew();
|
bool TableAddNew();
|
||||||
bool TableNotFound(TEvent *e);
|
bool TableNotFound(TEvent const *Event) const;
|
||||||
void TableClear();
|
void TableClear();
|
||||||
TEvent *TableCheckTrackEvent(double fDirection, TTrack *Track);
|
TEvent *TableCheckTrackEvent(double fDirection, TTrack *Track);
|
||||||
void TableTraceRoute(double fDistance, TDynamicObject *pVehicle = NULL);
|
void TableTraceRoute(double fDistance, TDynamicObject *pVehicle = NULL);
|
||||||
void TableCheck(double fDistance);
|
void TableCheck(double fDistance);
|
||||||
TCommandType TableUpdate(double &fVelDes, double &fDist, double &fNext, double &fAcc);
|
TCommandType TableUpdate(double &fVelDes, double &fDist, double &fNext, double &fAcc);
|
||||||
void TablePurger();
|
void TablePurger();
|
||||||
|
public:
|
||||||
|
std::size_t TableSize() const { return sSpeedTable.size(); }
|
||||||
|
|
||||||
private: // Ra: stare funkcje skanujące, używane do szukania sygnalizatora z tyłu
|
private: // Ra: stare funkcje skanujące, używane do szukania sygnalizatora z tyłu
|
||||||
bool BackwardTrackBusy(TTrack *Track);
|
bool BackwardTrackBusy(TTrack *Track);
|
||||||
@@ -395,9 +407,9 @@ class TController
|
|||||||
};
|
};
|
||||||
void MoveTo(TDynamicObject *to);
|
void MoveTo(TDynamicObject *to);
|
||||||
void DirectionInitial();
|
void DirectionInitial();
|
||||||
std::string TableText(int i);
|
std::string TableText(std::size_t const Index);
|
||||||
int CrossRoute(TTrack *tr);
|
int CrossRoute(TTrack *tr);
|
||||||
void RouteSwitch(int d);
|
void RouteSwitch(int d);
|
||||||
std::string OwnerName();
|
std::string OwnerName() const;
|
||||||
TMoverParameters const *Controlling() const { return mvControlling; }
|
TMoverParameters const *Controlling() const { return mvControlling; }
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2562,7 +2562,7 @@ void TTrain::OnCommand_doortoggleleft( TTrain *Train, command_data const &Comman
|
|||||||
if( Train->ggDoorLeftButton.GetValue() > 0.5 ) {
|
if( Train->ggDoorLeftButton.GetValue() > 0.5 ) {
|
||||||
Train->play_sound( Train->dsbSwitch );
|
Train->play_sound( Train->dsbSwitch );
|
||||||
}
|
}
|
||||||
Train->play_sound( Train->dsbDoorOpen );
|
Train->play_sound( Train->dsbDoorClose );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -2573,7 +2573,7 @@ void TTrain::OnCommand_doortoggleleft( TTrain *Train, command_data const &Comman
|
|||||||
if( Train->ggDoorRightButton.GetValue() > 0.5 ) {
|
if( Train->ggDoorRightButton.GetValue() > 0.5 ) {
|
||||||
Train->play_sound( Train->dsbSwitch );
|
Train->play_sound( Train->dsbSwitch );
|
||||||
}
|
}
|
||||||
Train->play_sound( Train->dsbDoorOpen );
|
Train->play_sound( Train->dsbDoorClose );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2623,7 +2623,7 @@ void TTrain::OnCommand_doortoggleright( TTrain *Train, command_data const &Comma
|
|||||||
if( Train->ggDoorRightButton.GetValue() > 0.5 ) {
|
if( Train->ggDoorRightButton.GetValue() > 0.5 ) {
|
||||||
Train->play_sound( Train->dsbSwitch );
|
Train->play_sound( Train->dsbSwitch );
|
||||||
}
|
}
|
||||||
Train->play_sound( Train->dsbDoorOpen );
|
Train->play_sound( Train->dsbDoorClose );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -2634,7 +2634,7 @@ void TTrain::OnCommand_doortoggleright( TTrain *Train, command_data const &Comma
|
|||||||
if( Train->ggDoorLeftButton.GetValue() > 0.5 ) {
|
if( Train->ggDoorLeftButton.GetValue() > 0.5 ) {
|
||||||
Train->play_sound( Train->dsbSwitch );
|
Train->play_sound( Train->dsbSwitch );
|
||||||
}
|
}
|
||||||
Train->play_sound( Train->dsbDoorOpen );
|
Train->play_sound( Train->dsbDoorClose );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1935,13 +1935,13 @@ TWorld::Update_UI() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = 0;
|
std::size_t i = 0; std::size_t const speedtablesize = std::min( 30, std::max( 0, static_cast<int>(tmp->Mechanik->TableSize()) - 1 ) );
|
||||||
do {
|
do {
|
||||||
std::string scanline = tmp->Mechanik->TableText( i );
|
std::string scanline = tmp->Mechanik->TableText( i );
|
||||||
if( scanline.empty() ) { break; }
|
if( scanline.empty() ) { break; }
|
||||||
UITable->text_lines.emplace_back( Global::Bezogonkow( scanline ), Global::UITextColor );
|
UITable->text_lines.emplace_back( Global::Bezogonkow( scanline ), Global::UITextColor );
|
||||||
++i;
|
++i;
|
||||||
} while( i < 16 ); // TController:iSpeedTableSize TODO: change when the table gets recoded
|
} while( i < speedtablesize ); // TController:iSpeedTableSize TODO: change when the table gets recoded
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -2039,7 +2039,7 @@ TWorld::Update_UI() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uitextline1 =
|
uitextline1 =
|
||||||
"vel: " + to_string(tmp->GetVelocity(), 2) + " km/h"
|
"vel: " + to_string( tmp->GetVelocity(), 2 ) + " km/h" + ( tmp->MoverParameters->SlippingWheels ? " (!)" : "" )
|
||||||
+ "; dist: " + to_string( tmp->MoverParameters->DistCounter, 2 ) + " km"
|
+ "; dist: " + to_string( tmp->MoverParameters->DistCounter, 2 ) + " km"
|
||||||
+ "; pos: ("
|
+ "; pos: ("
|
||||||
+ to_string( tmp->GetPosition().x, 2 ) + ", "
|
+ to_string( tmp->GetPosition().x, 2 ) + ", "
|
||||||
@@ -2573,7 +2573,7 @@ world_environment::update() {
|
|||||||
m_moon.update();
|
m_moon.update();
|
||||||
// ...determine source of key light and adjust global state accordingly...
|
// ...determine source of key light and adjust global state accordingly...
|
||||||
auto const sunlightlevel = m_sun.getIntensity();
|
auto const sunlightlevel = m_sun.getIntensity();
|
||||||
auto const moonlightlevel = m_moon.getIntensity();
|
auto const moonlightlevel = m_moon.getIntensity() * 0.65f; // scaled down by arbitrary factor, it's pretty bright otherwise
|
||||||
float keylightintensity;
|
float keylightintensity;
|
||||||
float twilightfactor;
|
float twilightfactor;
|
||||||
float3 keylightcolor;
|
float3 keylightcolor;
|
||||||
|
|||||||
Reference in New Issue
Block a user