mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 14:39:18 +02:00
Merged branch mover_in_c++ into speed_table
This commit is contained in:
@@ -36,7 +36,9 @@ class TMtableTime; // czas dla danego posterunku
|
||||
};
|
||||
|
||||
class TController; // obiekt sterujący pociągiem (AI)
|
||||
#ifdef EU07_USE_OLD_TNAMES_CLASS
|
||||
class TNames; // obiekt sortujący nazwy
|
||||
#endif
|
||||
|
||||
typedef enum
|
||||
{ // binarne odpowiedniki komend w komórce pamięci
|
||||
|
||||
56
Driver.cpp
56
Driver.cpp
@@ -160,7 +160,7 @@ void TSpeedPos::CommandCheck()
|
||||
case cm_PassengerStopPoint:
|
||||
// nie ma dostępu do rozkładu
|
||||
// przystanek, najwyżej AI zignoruje przy analizie tabelki
|
||||
if ((iFlags & spPassengerStopPoint) == 0)
|
||||
// if ((iFlags & spPassengerStopPoint) == 0)
|
||||
fVelNext = 0.0; // TrainParams->IsStop()?0.0:-1.0; //na razie tak
|
||||
iFlags |= spPassengerStopPoint; // niestety nie da się w tym miejscu współpracować z rozkładem
|
||||
break;
|
||||
@@ -829,7 +829,8 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
|
||||
{ // o ile dana pozycja tabelki jest istotna
|
||||
if (sSpeedTable[i].iFlags & spPassengerStopPoint)
|
||||
{ // jeśli przystanek, trzeba obsłużyć wg rozkładu
|
||||
if (sSpeedTable[i].evEvent->CommandGet() != asNextStop)
|
||||
// first 19 chars of the command is expected to be "PassengerStopPoint:" so we skip them
|
||||
if ( ToLower(sSpeedTable[i].evEvent->CommandGet()).compare( 19, sizeof(asNextStop), ToLower(asNextStop)) != 0 )
|
||||
{ // jeśli nazwa nie jest zgodna
|
||||
if (sSpeedTable[i].fDist < -fLength) // jeśli został przejechany
|
||||
sSpeedTable[i].iFlags =
|
||||
@@ -856,8 +857,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
|
||||
// licznika) ma przesunąć na
|
||||
// następny postój
|
||||
TrainParams->UpdateMTable(
|
||||
GlobalTime->hh, GlobalTime->mm,
|
||||
asNextStop.substr(19, asNextStop.length()));
|
||||
GlobalTime->hh, GlobalTime->mm, asNextStop);
|
||||
TrainParams->StationIndexInc(); // przejście do następnej
|
||||
asNextStop =
|
||||
TrainParams->NextStop(); // pobranie kolejnego miejsca zatrzymania
|
||||
@@ -956,8 +956,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
|
||||
// opóźnia również kierownika
|
||||
}
|
||||
if (TrainParams->UpdateMTable(
|
||||
GlobalTime->hh, GlobalTime->mm,
|
||||
asNextStop.substr(19, asNextStop.length())))
|
||||
GlobalTime->hh, GlobalTime->mm, asNextStop) )
|
||||
{ // to się wykona tylko raz po zatrzymaniu na W4
|
||||
if (TrainParams->CheckTrainLatency() < 0.0)
|
||||
iDrivigFlags |= moveLate; // odnotowano spóźnienie
|
||||
@@ -1277,8 +1276,8 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
|
||||
VelSignal = -1.0; // aby stojący ruszył
|
||||
if (sSpeedTable[i].fDist < 0.0) // jeśli przejechany
|
||||
{
|
||||
if (v != 0 ? VelSignal = -1.0 : VelSignal = 0.0)
|
||||
; // ustawienie, gdy przejechany jest lepsze niż
|
||||
VelSignal = (v != 0 ? -1.0 : 0.0);
|
||||
// ustawienie, gdy przejechany jest lepsze niż
|
||||
// wcale, ale to jeszcze nie to
|
||||
if (sSpeedTable[i].iFlags & spEvent) // jeśli event
|
||||
if ((sSpeedTable[i].evEvent != eSignSkip) ?
|
||||
@@ -2323,15 +2322,15 @@ bool TController::IncBrake()
|
||||
{
|
||||
case Individual:
|
||||
if (mvOccupied->LocalBrake == ManualBrake)
|
||||
OK = mvOccupied->IncManualBrakeLevel(1 + floor(0.5 + fabs(AccDesired)));
|
||||
OK = mvOccupied->IncManualBrakeLevel( 1 + static_cast<int>( std::floor( 0.5 + std::fabs(AccDesired))) );
|
||||
else
|
||||
OK = mvOccupied->IncLocalBrakeLevel(1 + floor(0.5 + fabs(AccDesired)));
|
||||
OK = mvOccupied->IncLocalBrakeLevel( 1 + static_cast<int>( std::floor( 0.5 + std::fabs(AccDesired))) );
|
||||
break;
|
||||
case Pneumatic:
|
||||
if ((mvOccupied->Couplers[0].Connected == NULL) &&
|
||||
(mvOccupied->Couplers[1].Connected == NULL))
|
||||
OK = mvOccupied->IncLocalBrakeLevel(
|
||||
1 + floor(0.5 + fabs(AccDesired))); // hamowanie lokalnym bo luzem jedzie
|
||||
1 + static_cast<int>( std::floor( 0.5 + std::fabs(AccDesired))) ); // hamowanie lokalnym bo luzem jedzie
|
||||
else
|
||||
{
|
||||
if (mvOccupied->BrakeCtrlPos + 1 == mvOccupied->BrakeCtrlPosNo)
|
||||
@@ -2438,7 +2437,8 @@ bool TController::IncSpeed()
|
||||
if (tsGuardSignal->GetStatus() & DSBSTATUS_PLAYING) // jeśli gada, to nie jedziemy
|
||||
return false;
|
||||
bool OK = true;
|
||||
if (iDrivigFlags & moveDoorOpened)
|
||||
if ((iDrivigFlags & moveDoorOpened)
|
||||
&&(mvOccupied->Vel > 0.1)) // added velocity threshold to prevent door shuffle on stop
|
||||
Doors(false); // zamykanie drzwi - tutaj wykonuje tylko AI (zmienia fActionTime)
|
||||
if (fActionTime < 0.0) // gdy jest nakaz poczekać z jazdą, to nie ruszać
|
||||
return false;
|
||||
@@ -4184,6 +4184,12 @@ bool TController::UpdateSituation(double dt)
|
||||
{ // komunikat od kierownika tu, bo musi być wolna droga i odczekany czas
|
||||
// stania
|
||||
iDrivigFlags &= ~moveGuardSignal; // tylko raz nadać
|
||||
|
||||
if( iDrivigFlags & moveDoorOpened ) // jeśli drzwi otwarte
|
||||
if( !mvOccupied
|
||||
->DoorOpenCtrl ) // jeśli drzwi niesterowane przez maszynistę
|
||||
Doors( false ); // a EZT zamknie dopiero po odegraniu komunikatu kierownika
|
||||
|
||||
tsGuardSignal->Stop();
|
||||
// w zasadzie to powinien mieć flagę, czy jest dźwiękiem radiowym, czy
|
||||
// bezpośrednim
|
||||
@@ -4207,11 +4213,6 @@ bool TController::UpdateSituation(double dt)
|
||||
1.0, 0, true,
|
||||
pVehicle->GetPosition()); // dźwięk niby przez radio
|
||||
}
|
||||
if (iDrivigFlags & moveDoorOpened) // jeśli drzwi otwarte
|
||||
if (!mvOccupied
|
||||
->DoorOpenCtrl) // jeśli drzwi niesterowane przez maszynistę
|
||||
Doors(false); // a EZT zamknie dopiero po odegraniu komunikatu
|
||||
// kierownika
|
||||
}
|
||||
if (mvOccupied->V == 0.0)
|
||||
AbsAccS = fAccGravity; // Ra 2014-03: jesli skład stoi, to działa na niego
|
||||
@@ -5238,19 +5239,24 @@ TCommandType TController::BackwardScan()
|
||||
|
||||
std::string TController::NextStop()
|
||||
{ // informacja o następnym zatrzymaniu, wyświetlane pod [F1]
|
||||
if (asNextStop.length() < 19)
|
||||
if (asNextStop == "[End of route]")
|
||||
return ""; // nie zawiera nazwy stacji, gdy dojechał do końca
|
||||
// dodać godzinę odjazdu
|
||||
if (!TrainParams)
|
||||
return ""; // tu nie powinno nigdy wejść
|
||||
std::string nextstop = asNextStop;
|
||||
TMTableLine *t = TrainParams->TimeTable + TrainParams->StationIndex;
|
||||
if (t->Dh >= 0) // jeśli jest godzina odjazdu
|
||||
return asNextStop.substr(19, 30) + " " + std::to_string(t->Dh) + ":" +
|
||||
std::to_string(t->Dm); // odjazd
|
||||
else if (t->Ah >= 0) // przyjazd
|
||||
return asNextStop.substr(19, 30) + " (" + std::to_string(t->Ah) + ":" +
|
||||
std::to_string(t->Am) + ")"; // przyjazd
|
||||
return "";
|
||||
if( t->Ah >= 0 ) {
|
||||
// przyjazd
|
||||
nextstop += " przyj." + std::to_string( t->Ah ) + ":"
|
||||
+ ( t->Am < 10 ? "0" : "" ) + std::to_string( t->Am );
|
||||
}
|
||||
if( t->Dh >= 0 ) {
|
||||
// jeśli jest godzina odjazdu
|
||||
nextstop += " odj." + std::to_string( t->Dh ) + ":"
|
||||
+ ( t->Dm < 10 ? "0" : "" ) + std::to_string( t->Dm );
|
||||
}
|
||||
return nextstop;
|
||||
};
|
||||
|
||||
//-----------koniec skanowania semaforow
|
||||
|
||||
2
Driver.h
2
Driver.h
@@ -387,7 +387,7 @@ class TController
|
||||
bool IsStop();
|
||||
bool Primary()
|
||||
{
|
||||
return this ? bool(iDrivigFlags & movePrimary) : false;
|
||||
return this ? ((iDrivigFlags & movePrimary) != 0) : false;
|
||||
};
|
||||
int inline DrivigFlags()
|
||||
{
|
||||
|
||||
47
DynObj.cpp
47
DynObj.cpp
@@ -1873,13 +1873,13 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424"
|
||||
{
|
||||
if (Cab == 0)
|
||||
MoverParameters->BrakeCtrlPos =
|
||||
floor(MoverParameters->Handle->GetPos(bh_NP));
|
||||
static_cast<int>( std::floor(MoverParameters->Handle->GetPos(bh_NP)) );
|
||||
else
|
||||
MoverParameters->BrakeCtrlPos = floor(MoverParameters->Handle->GetPos(bh_RP));
|
||||
MoverParameters->BrakeCtrlPos = static_cast<int>( std::floor(MoverParameters->Handle->GetPos(bh_RP)) );
|
||||
}
|
||||
else
|
||||
MoverParameters->BrakeCtrlPos =
|
||||
floor(MoverParameters->Handle->GetPos(bh_NP));
|
||||
static_cast<int>( std::floor(MoverParameters->Handle->GetPos(bh_NP)) );
|
||||
|
||||
MoverParameters->BrakeLevelSet(
|
||||
MoverParameters->BrakeCtrlPos); // poprawienie hamulca po ewentualnym
|
||||
@@ -2920,7 +2920,7 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
// 1. najpierw daj kazdemu tyle samo
|
||||
int i = 0;
|
||||
for (TDynamicObject *p = GetFirstDynamic(MoverParameters->ActiveCab < 0 ? 1 : 0, 4); p;
|
||||
(kier > 0 ? p = p->NextC(4) : p = p->PrevC(4)))
|
||||
p = (kier == true ? p->NextC(4) : p->PrevC(4)) )
|
||||
{
|
||||
float Nmax = ((p->MoverParameters->P2FTrans * p->MoverParameters->MaxBrakePress[0] -
|
||||
p->MoverParameters->BrakeCylSpring) *
|
||||
@@ -2948,7 +2948,7 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
i = 0;
|
||||
float przek = 0;
|
||||
for (TDynamicObject *p = GetFirstDynamic(MoverParameters->ActiveCab < 0 ? 1 : 0, 4); p;
|
||||
(kier > 0 ? p = p->NextC(4) : p = p->PrevC(4)))
|
||||
p = (kier == true ? p->NextC(4) : p->PrevC(4)) )
|
||||
{
|
||||
if ((FzEP[i] > 0.01) &&
|
||||
(FzEP[i] >
|
||||
@@ -3302,13 +3302,16 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
switch (i) // numer pantografu
|
||||
{ // trzeba usunąć to rozróżnienie
|
||||
case 0:
|
||||
if (Global::bLiveTraction ? false :
|
||||
!p->hvPowerWire) // jeśli nie ma drutu, może pooszukiwać
|
||||
if( ( Global::bLiveTraction == false )
|
||||
&& ( p->hvPowerWire == nullptr ) ) {
|
||||
// jeśli nie ma drutu, może pooszukiwać
|
||||
MoverParameters->PantFrontVolt =
|
||||
(p->PantWys >= 1.2) ? 0.95 * MoverParameters->EnginePowerSource.MaxVoltage :
|
||||
0.0;
|
||||
else if (MoverParameters->PantFrontUp ? (PantDiff < 0.01) :
|
||||
false) // tolerancja niedolegania
|
||||
( p->PantWys >= 1.2 ) ?
|
||||
0.95 * MoverParameters->EnginePowerSource.MaxVoltage :
|
||||
0.0;
|
||||
}
|
||||
else if( ( true == MoverParameters->PantFrontUp )
|
||||
&& ( PantDiff < 0.01 ) ) // tolerancja niedolegania
|
||||
{
|
||||
if ((MoverParameters->PantFrontVolt == 0.0) &&
|
||||
(MoverParameters->PantRearVolt == 0.0))
|
||||
@@ -3328,12 +3331,16 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
MoverParameters->PantFrontVolt = 0.0;
|
||||
break;
|
||||
case 1:
|
||||
if (Global::bLiveTraction ? false :
|
||||
!p->hvPowerWire) // jeśli nie ma drutu, może pooszukiwać
|
||||
if( ( false == Global::bLiveTraction )
|
||||
&& ( nullptr == p->hvPowerWire ) ) {
|
||||
// jeśli nie ma drutu, może pooszukiwać
|
||||
MoverParameters->PantRearVolt =
|
||||
(p->PantWys >= 1.2) ? 0.95 * MoverParameters->EnginePowerSource.MaxVoltage :
|
||||
0.0;
|
||||
else if (MoverParameters->PantRearUp ? (PantDiff < 0.01) : false)
|
||||
( p->PantWys >= 1.2 ) ?
|
||||
0.95 * MoverParameters->EnginePowerSource.MaxVoltage :
|
||||
0.0;
|
||||
}
|
||||
else if ( ( true == MoverParameters->PantRearUp )
|
||||
&& ( PantDiff < 0.01 ) )
|
||||
{
|
||||
if ((MoverParameters->PantRearVolt == 0.0) &&
|
||||
(MoverParameters->PantFrontVolt == 0.0))
|
||||
@@ -4372,7 +4379,6 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
||||
pants = NULL; // wskaźnik pierwszego obiektu animującego dla pantografów
|
||||
cParser parser( TypeName + ".mmd", cParser::buffer_FILE, BaseDir );
|
||||
std::string token;
|
||||
int i;
|
||||
do {
|
||||
token = "";
|
||||
parser.getTokens(); parser >> token;
|
||||
@@ -4387,7 +4393,8 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
||||
iMultiTex = 1;
|
||||
asModel.erase( asModel.length() - 1 );
|
||||
}
|
||||
if ((i = asModel.find(',')) != std::string::npos)
|
||||
std::size_t i = asModel.find( ',' );
|
||||
if ( i != std::string::npos )
|
||||
{ // Ra 2015-01: może szukać przecinka w
|
||||
// nazwie modelu, a po przecinku była by
|
||||
// liczba
|
||||
@@ -5910,7 +5917,7 @@ TDynamicObject::ConnectedEnginePowerSource( TDynamicObject const *Caller ) const
|
||||
// NOTE: the order should be reversed in flipped vehicles, but we ignore this out of laziness
|
||||
if( ( nullptr != NextConnected )
|
||||
&& ( NextConnected != Caller )
|
||||
&& ( MoverParameters->Couplers[1].CouplingFlag & ctrain_controll == ctrain_controll ) ) {
|
||||
&& ( ( MoverParameters->Couplers[1].CouplingFlag & ctrain_controll ) == ctrain_controll ) ) {
|
||||
|
||||
auto source = NextConnected->ConnectedEnginePowerSource( this );
|
||||
if( source != TPowerSource::NotDefined ) {
|
||||
@@ -5921,7 +5928,7 @@ TDynamicObject::ConnectedEnginePowerSource( TDynamicObject const *Caller ) const
|
||||
// ...then rear...
|
||||
if( ( nullptr != PrevConnected )
|
||||
&& ( PrevConnected != Caller )
|
||||
&& ( MoverParameters->Couplers[ 0 ].CouplingFlag & ctrain_controll == ctrain_controll ) ) {
|
||||
&& ( ( MoverParameters->Couplers[ 0 ].CouplingFlag & ctrain_controll ) == ctrain_controll ) ) {
|
||||
|
||||
auto source = PrevConnected->ConnectedEnginePowerSource( this );
|
||||
if( source != TPowerSource::NotDefined ) {
|
||||
|
||||
53
EU07.cpp
53
EU07.cpp
@@ -39,6 +39,7 @@ Stele, firleju, szociu, hunter, ZiomalCl, OLI_EU and others
|
||||
#pragma comment( lib, "winmm.lib" )
|
||||
#pragma comment( lib, "setupapi.lib" )
|
||||
#pragma comment( lib, "python27.lib" )
|
||||
#pragma comment (lib, "dbghelp.lib")
|
||||
|
||||
HDC hDC = NULL; // Private GDI Device Context
|
||||
HGLRC hRC = NULL; // Permanent Rendering Context
|
||||
@@ -567,6 +568,55 @@ LRESULT CALLBACK WndProc(HWND hWnd, // handle for this window
|
||||
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||
};
|
||||
|
||||
#ifdef _WINDOWS
|
||||
void make_minidump( ::EXCEPTION_POINTERS* e ) {
|
||||
|
||||
auto hDbgHelp = ::LoadLibraryA( "dbghelp" );
|
||||
if( hDbgHelp == nullptr )
|
||||
return;
|
||||
auto pMiniDumpWriteDump = (decltype( &MiniDumpWriteDump ))::GetProcAddress( hDbgHelp, "MiniDumpWriteDump" );
|
||||
if( pMiniDumpWriteDump == nullptr )
|
||||
return;
|
||||
|
||||
char name[ MAX_PATH ];
|
||||
{
|
||||
auto nameEnd = name + ::GetModuleFileNameA( ::GetModuleHandleA( 0 ), name, MAX_PATH );
|
||||
::SYSTEMTIME t;
|
||||
::GetSystemTime( &t );
|
||||
wsprintfA( nameEnd - strlen( ".exe" ),
|
||||
"_crashdump_%4d%02d%02d_%02d%02d%02d.dmp",
|
||||
t.wYear, t.wMonth, t.wDay, t.wHour, t.wMinute, t.wSecond );
|
||||
}
|
||||
|
||||
auto hFile = ::CreateFileA( name, GENERIC_WRITE, FILE_SHARE_READ, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0 );
|
||||
if( hFile == INVALID_HANDLE_VALUE )
|
||||
return;
|
||||
|
||||
::MINIDUMP_EXCEPTION_INFORMATION exceptionInfo;
|
||||
exceptionInfo.ThreadId = ::GetCurrentThreadId();
|
||||
exceptionInfo.ExceptionPointers = e;
|
||||
exceptionInfo.ClientPointers = FALSE;
|
||||
|
||||
auto dumped = pMiniDumpWriteDump(
|
||||
::GetCurrentProcess(),
|
||||
::GetCurrentProcessId(),
|
||||
hFile,
|
||||
::MINIDUMP_TYPE( ::MiniDumpWithIndirectlyReferencedMemory | ::MiniDumpScanMemory ),
|
||||
e ? &exceptionInfo : nullptr,
|
||||
nullptr,
|
||||
nullptr );
|
||||
|
||||
::CloseHandle( hFile );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
LONG CALLBACK unhandled_handler( ::EXCEPTION_POINTERS* e ) {
|
||||
make_minidump( e );
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
#endif
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hInstance, // instance
|
||||
HINSTANCE hPrevInstance, // previous instance
|
||||
LPSTR lpCmdLine, // command line parameters
|
||||
@@ -581,6 +631,9 @@ int WINAPI WinMain(HINSTANCE hInstance, // instance
|
||||
// this will turn on FPE for #IND and zerodiv
|
||||
state = _control87( state & ~( _EM_ZERODIVIDE | _EM_INVALID ), _MCW_EM );
|
||||
#endif
|
||||
#ifdef _WINDOWS
|
||||
::SetUnhandledExceptionFilter( unhandled_handler );
|
||||
#endif
|
||||
|
||||
MSG msg; // windows message structure
|
||||
BOOL done = FALSE; // bool variable to exit loop
|
||||
|
||||
@@ -316,7 +316,7 @@ void TEvent::Load(cParser *parser, vector3 *org)
|
||||
if (token.substr(0, 19) == "PassengerStopPoint:")
|
||||
{
|
||||
if (token.find('#') != std::string::npos)
|
||||
token = token.substr(0, token.find('#') - 1); // obcięcie unikatowości
|
||||
token.erase(token.find('#')); // obcięcie unikatowości
|
||||
bEnabled = false; // nie do kolejki (dla SetVelocity też, ale jak jest do toru
|
||||
// dowiązany)
|
||||
Params[6].asCommand = cm_PassengerStopPoint;
|
||||
|
||||
108
Ground.cpp
108
Ground.cpp
@@ -1308,8 +1308,9 @@ TGround::TGround()
|
||||
for( int i = 0; i < TP_LAST; ++i ) {
|
||||
nRootOfType[ i ] = nullptr; // zerowanie tablic wyszukiwania
|
||||
}
|
||||
#ifdef EU07_USE_OLD_TNAMES_CLASS
|
||||
sTracks = new TNames(); // nazwy torów - na razie tak
|
||||
|
||||
#endif
|
||||
::SecureZeroMemory( TempConnectionType, sizeof( TempConnectionType ) );
|
||||
::SecureZeroMemory( pRendered, sizeof( pRendered ) );
|
||||
}
|
||||
@@ -1348,7 +1349,9 @@ void TGround::Free()
|
||||
iNumNodes = 0;
|
||||
// RootNode=NULL;
|
||||
nRootDynamic = NULL;
|
||||
#ifdef EU07_USE_OLD_TNAMES_CLASS
|
||||
delete sTracks;
|
||||
#endif
|
||||
}
|
||||
|
||||
TGroundNode * TGround::DynamicFindAny(std::string asNameToFind)
|
||||
@@ -1381,7 +1384,38 @@ TGroundNode * TGround::FindGroundNode(std::string asNameToFind, TGroundNodeType
|
||||
{ // wyszukiwanie obiektu o podanej nazwie i konkretnym typie
|
||||
if ((iNodeType == TP_TRACK) || (iNodeType == TP_MEMCELL) || (iNodeType == TP_MODEL))
|
||||
{ // wyszukiwanie w drzewie binarnym
|
||||
#ifdef EU07_USE_OLD_TNAMES_CLASS
|
||||
return (TGroundNode *)sTracks->Find(iNodeType, asNameToFind.c_str());
|
||||
#else
|
||||
/*
|
||||
switch( iNodeType ) {
|
||||
|
||||
case TP_TRACK: {
|
||||
auto const lookup = m_trackmap.find( asNameToFind );
|
||||
return
|
||||
lookup != m_trackmap.end() ?
|
||||
lookup->second :
|
||||
nullptr;
|
||||
}
|
||||
case TP_MODEL: {
|
||||
auto const lookup = m_modelmap.find( asNameToFind );
|
||||
return
|
||||
lookup != m_modelmap.end() ?
|
||||
lookup->second :
|
||||
nullptr;
|
||||
}
|
||||
case TP_MEMCELL: {
|
||||
auto const lookup = m_memcellmap.find( asNameToFind );
|
||||
return
|
||||
lookup != m_memcellmap.end() ?
|
||||
lookup->second :
|
||||
nullptr;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
*/
|
||||
return m_trackmap.Find( iNodeType, asNameToFind );
|
||||
#endif
|
||||
}
|
||||
// standardowe wyszukiwanie liniowe
|
||||
TGroundNode *Current;
|
||||
@@ -1705,6 +1739,7 @@ TGroundNode * TGround::AddGroundNode(cParser *parser)
|
||||
tmp->MemCell->Load(parser);
|
||||
if (!tmp->asName.empty()) // jest pusta gdy "none"
|
||||
{ // dodanie do wyszukiwarki
|
||||
#ifdef EU07_USE_OLD_TNAMES_CLASS
|
||||
if (sTracks->Update(TP_MEMCELL, tmp->asName.c_str(),
|
||||
tmp)) // najpierw sprawdzić, czy już jest
|
||||
{ // przy zdublowaniu wskaźnik zostanie podmieniony w drzewku na późniejszy (zgodność
|
||||
@@ -1713,6 +1748,12 @@ TGroundNode * TGround::AddGroundNode(cParser *parser)
|
||||
}
|
||||
else
|
||||
sTracks->Add(TP_MEMCELL, tmp->asName.c_str(), tmp); // nazwa jest unikalna
|
||||
#else
|
||||
if( false == m_trackmap.Add( TP_MEMCELL, tmp->asName, tmp ) ) {
|
||||
// przy zdublowaniu wskaźnik zostanie podmieniony w drzewku na późniejszy (zgodność wsteczna)
|
||||
ErrorLog( "Duplicated memcell: " + tmp->asName ); // to zgłaszać duplikat
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case TP_EVLAUNCH:
|
||||
@@ -1732,6 +1773,7 @@ TGroundNode * TGround::AddGroundNode(cParser *parser)
|
||||
tmp->asName); // w nazwie może być nazwa odcinka izolowanego
|
||||
if (!tmp->asName.empty()) // jest pusta gdy "none"
|
||||
{ // dodanie do wyszukiwarki
|
||||
#ifdef EU07_USE_OLD_TNAMES_CLASS
|
||||
if (sTracks->Update(TP_TRACK, tmp->asName.c_str(),
|
||||
tmp)) // najpierw sprawdzić, czy już jest
|
||||
{ // przy zdublowaniu wskaźnik zostanie podmieniony w drzewku na późniejszy (zgodność
|
||||
@@ -1741,6 +1783,12 @@ TGroundNode * TGround::AddGroundNode(cParser *parser)
|
||||
}
|
||||
else
|
||||
sTracks->Add(TP_TRACK, tmp->asName.c_str(), tmp); // nazwa jest unikalna
|
||||
#else
|
||||
if( false == m_trackmap.Add( TP_TRACK, tmp->asName, tmp ) ) {
|
||||
// przy zdublowaniu wskaźnik zostanie podmieniony w drzewku na późniejszy (zgodność wsteczna)
|
||||
ErrorLog( "Duplicated track: " + tmp->asName ); // to zgłaszać duplikat
|
||||
}
|
||||
#endif
|
||||
}
|
||||
tmp->pCenter = (tmp->pTrack->CurrentSegment()->FastGetPoint_0() +
|
||||
tmp->pTrack->CurrentSegment()->FastGetPoint(0.5) +
|
||||
@@ -1981,6 +2029,7 @@ TGroundNode * TGround::AddGroundNode(cParser *parser)
|
||||
}
|
||||
else if (!tmp->asName.empty()) // jest pusta gdy "none"
|
||||
{ // dodanie do wyszukiwarki
|
||||
#ifdef EU07_USE_OLD_TNAMES_CLASS
|
||||
if (sTracks->Update(TP_MODEL, tmp->asName.c_str(),
|
||||
tmp)) // najpierw sprawdzić, czy już jest
|
||||
{ // przy zdublowaniu wskaźnik zostanie podmieniony w drzewku na późniejszy (zgodność
|
||||
@@ -1989,6 +2038,12 @@ TGroundNode * TGround::AddGroundNode(cParser *parser)
|
||||
}
|
||||
else
|
||||
sTracks->Add(TP_MODEL, tmp->asName.c_str(), tmp); // nazwa jest unikalna
|
||||
#else
|
||||
if( false == m_trackmap.Add( TP_MODEL, tmp->asName, tmp ) ) {
|
||||
// przy zdublowaniu wskaźnik zostanie podmieniony w drzewku na późniejszy (zgodność wsteczna)
|
||||
ErrorLog( "Duplicated model: " + tmp->asName ); // to zgłaszać duplikat
|
||||
}
|
||||
#endif
|
||||
}
|
||||
// str=Parser->GetNextSymbol().LowerCase();
|
||||
break;
|
||||
@@ -2268,7 +2323,15 @@ TSubRect * TGround::GetSubRect(int iCol, int iRow)
|
||||
|
||||
TEvent * TGround::FindEvent(const string &asEventName)
|
||||
{
|
||||
#ifdef EU07_USE_OLD_TNAMES_CLASS
|
||||
return (TEvent *)sTracks->Find(0, asEventName.c_str()); // wyszukiwanie w drzewie
|
||||
#else
|
||||
auto const lookup = m_eventmap.find( asEventName );
|
||||
return
|
||||
lookup != m_eventmap.end() ?
|
||||
lookup->second :
|
||||
nullptr;
|
||||
#endif
|
||||
/* //powolna wyszukiwarka
|
||||
for (TEvent *Current=RootEvent;Current;Current=Current->Next2)
|
||||
{
|
||||
@@ -2281,13 +2344,25 @@ TEvent * TGround::FindEvent(const string &asEventName)
|
||||
|
||||
TEvent * TGround::FindEventScan(const string &asEventName)
|
||||
{ // wyszukanie eventu z opcją utworzenia niejawnego dla komórek skanowanych
|
||||
TEvent *e = (TEvent *)sTracks->Find(0, asEventName.c_str()); // wyszukiwanie w drzewie eventów
|
||||
#ifdef EU07_USE_OLD_TNAMES_CLASS
|
||||
TEvent *e = (TEvent *)sTracks->Find( 0, asEventName.c_str() ); // wyszukiwanie w drzewie eventów
|
||||
#else
|
||||
auto const lookup = m_eventmap.find( asEventName );
|
||||
auto e =
|
||||
lookup != m_eventmap.end() ?
|
||||
lookup->second :
|
||||
nullptr;
|
||||
#endif
|
||||
if (e)
|
||||
return e; // jak istnieje, to w porządku
|
||||
if (asEventName.rfind(":scan") != std::string::npos) // jeszcze może być event niejawny
|
||||
{ // no to szukamy komórki pamięci o nazwie zawartej w evencie
|
||||
string n = asEventName.substr(0, asEventName.length() - 5); // do dwukropka
|
||||
if (sTracks->Find(TP_MEMCELL, n.c_str())) // jeśli jest takowa komórka pamięci
|
||||
#ifdef EU07_USE_OLD_TNAMES_CLASS
|
||||
if( sTracks->Find( TP_MEMCELL, n.c_str() ) ) // jeśli jest takowa komórka pamięci
|
||||
#else
|
||||
if( m_trackmap.Find( TP_MEMCELL, n ) != nullptr ) // jeśli jest takowa komórka pamięci
|
||||
#endif
|
||||
e = new TEvent(n); // utworzenie niejawnego eventu jej odczytu
|
||||
}
|
||||
return e; // utworzony albo się nie udało
|
||||
@@ -2626,7 +2701,11 @@ bool TGround::Init(std::string asFile, HDC hDC)
|
||||
if (RootEvent->asName.find(
|
||||
"onstart") != string::npos) // event uruchamiany automatycznie po starcie
|
||||
AddToQuery(RootEvent, NULL); // dodanie do kolejki
|
||||
#ifdef EU07_USE_OLD_TNAMES_CLASS
|
||||
sTracks->Add(0, tmp->asName.c_str(), tmp); // dodanie do wyszukiwarki
|
||||
#else
|
||||
m_eventmap.emplace( tmp->asName, tmp ); // dodanie do wyszukiwarki
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2905,10 +2984,12 @@ bool TGround::Init(std::string asFile, HDC hDC)
|
||||
parser >> token;
|
||||
}
|
||||
|
||||
#ifdef EU07_USE_OLD_TNAMES_CLASS
|
||||
sTracks->Sort(TP_TRACK); // finalne sortowanie drzewa torów
|
||||
sTracks->Sort(TP_MEMCELL); // finalne sortowanie drzewa komórek pamięci
|
||||
sTracks->Sort(TP_MODEL); // finalne sortowanie drzewa modeli
|
||||
sTracks->Sort(0); // finalne sortowanie drzewa eventów
|
||||
#endif
|
||||
if (!bInitDone)
|
||||
FirstInit(); // jeśli nie było w scenerii
|
||||
if (Global::pTerrainCompact)
|
||||
@@ -3375,7 +3456,11 @@ void TGround::InitTracks()
|
||||
Current = new TGroundNode(); // to nie musi mieć nazwy, nazwa w wyszukiwarce wystarczy
|
||||
// Current->asName=p->asName; //mazwa identyczna, jak nazwa odcinka izolowanego
|
||||
Current->MemCell = new TMemCell(NULL); // nowa komórka
|
||||
#ifdef EU07_USE_OLD_TNAMES_CLASS
|
||||
sTracks->Add(TP_MEMCELL, p->asName.c_str(), Current); // dodanie do wyszukiwarki
|
||||
#else
|
||||
m_trackmap.Add( TP_MEMCELL, p->asName, Current );
|
||||
#endif
|
||||
Current->nNext =
|
||||
nRootOfType[TP_MEMCELL]; // to nie powinno tutaj być, bo robi się śmietnik
|
||||
nRootOfType[TP_MEMCELL] = Current;
|
||||
@@ -4038,15 +4123,16 @@ bool TGround::CheckQuery()
|
||||
}
|
||||
#endif
|
||||
//if (DebugModeFlag)
|
||||
WriteLog("Type: UpdateValues & Track command - " +
|
||||
std::string(tmpEvent->Params[0].asText) + " " +
|
||||
std::to_string(tmpEvent->Params[1].asdouble) + " " +
|
||||
std::to_string(tmpEvent->Params[2].asdouble));
|
||||
WriteLog("Type: UpdateValues & Track command - " +
|
||||
tmpEvent->Params[5].asMemCell->Text() + " " +
|
||||
std::to_string( tmpEvent->Params[ 5 ].asMemCell->Value1() ) + " " +
|
||||
std::to_string( tmpEvent->Params[ 5 ].asMemCell->Value2() ) );
|
||||
}
|
||||
else //if (DebugModeFlag)
|
||||
WriteLog("Type: UpdateValues - " + std::string( tmpEvent->Params[0].asText ) +
|
||||
" " + std::to_string(tmpEvent->Params[1].asdouble) + " " +
|
||||
std::to_string(tmpEvent->Params[2].asdouble));
|
||||
else //if (DebugModeFlag)
|
||||
WriteLog("Type: UpdateValues - " +
|
||||
tmpEvent->Params[5].asMemCell->Text() + " " +
|
||||
std::to_string( tmpEvent->Params[ 5 ].asMemCell->Value1() ) + " " +
|
||||
std::to_string( tmpEvent->Params[ 5 ].asMemCell->Value2() ) );
|
||||
}
|
||||
break;
|
||||
case tp_GetValues:
|
||||
|
||||
9
Ground.h
9
Ground.h
@@ -15,6 +15,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "Classes.h"
|
||||
#include "ResourceManager.h"
|
||||
#include "dumb3d.h"
|
||||
#include "Names.h"
|
||||
|
||||
using namespace Math3D;
|
||||
|
||||
@@ -297,7 +298,15 @@ class TGround
|
||||
ssh = 0,
|
||||
ssm = 0; // ustawienia czasu
|
||||
// int tracks,tracksfar; //liczniki torów
|
||||
#ifdef EU07_USE_OLD_TNAMES_CLASS
|
||||
TNames *sTracks = nullptr; // posortowane nazwy torów i eventów
|
||||
#else
|
||||
typedef std::unordered_map<std::string, TEvent *> event_map;
|
||||
// typedef std::unordered_map<std::string, TGroundNode *> groundnode_map;
|
||||
event_map m_eventmap;
|
||||
// groundnode_map m_memcellmap, m_modelmap, m_trackmap;
|
||||
TNames<TGroundNode *> m_trackmap;
|
||||
#endif
|
||||
private: // metody prywatne
|
||||
bool EventConditon(TEvent *e);
|
||||
|
||||
|
||||
@@ -543,8 +543,6 @@ struct TTransmision
|
||||
|
||||
enum TCouplerType { NoCoupler, Articulated, Bare, Chain, Screw, Automatic };
|
||||
|
||||
//class TMoverParameters; // wyforwardowanie klasy coby typ byl widoczny w ponizszej strukturze
|
||||
|
||||
struct TCoupling {
|
||||
/*parametry*/
|
||||
double SpringKB = 1.0; /*stala sprezystosci zderzaka/sprzegu, %tlumiennosci */
|
||||
@@ -673,7 +671,7 @@ public:
|
||||
int MainCtrlPosNo = 0; /*ilosc pozycji nastawnika*/
|
||||
int ScndCtrlPosNo = 0;
|
||||
int LightsPosNo = 0; // NOTE: values higher than 0 seem to break the current code for light switches
|
||||
int LightsDefPos = 0;
|
||||
int LightsDefPos = 1;
|
||||
bool LightsWrap = false;
|
||||
int Lights[2][17]; // pozycje świateł, przód - tył, 1 .. 16
|
||||
bool ScndInMain = false; /*zaleznosc bocznika od nastawnika*/
|
||||
@@ -748,7 +746,7 @@ public:
|
||||
/*- dla lokomotyw z silnikami indukcyjnymi -*/
|
||||
double eimc[26];
|
||||
/*-dla wagonow*/
|
||||
long MaxLoad = 0.0; /*masa w T lub ilosc w sztukach - ladownosc*/
|
||||
double MaxLoad = 0.0; /*masa w T lub ilosc w sztukach - ladownosc*/
|
||||
std::string LoadAccepted; std::string LoadQuantity; /*co moze byc zaladowane, jednostki miary*/
|
||||
double OverLoadFactor = 0.0; /*ile razy moze byc przekroczona ladownosc*/
|
||||
double LoadSpeed = 0.0; double UnLoadSpeed = 0.0;/*szybkosc na- i rozladunku jednostki/s*/
|
||||
@@ -907,7 +905,7 @@ public:
|
||||
double eAngle = 1.5;
|
||||
|
||||
/*-dla wagonow*/
|
||||
long Load = 0.0; /*masa w T lub ilosc w sztukach - zaladowane*/
|
||||
double Load = 0.0; /*masa w T lub ilosc w sztukach - zaladowane*/
|
||||
std::string LoadType; /*co jest zaladowane*/
|
||||
int LoadStatus = 0; //+1=trwa rozladunek,+2=trwa zaladunek,+4=zakończono,0=zaktualizowany model
|
||||
double LastLoadChangeTime = 0.0; //raz (roz)ładowania
|
||||
@@ -1066,8 +1064,8 @@ public:
|
||||
bool FuseOn(void); //bezpiecznik nadamiary
|
||||
bool FuseFlagCheck(void); // sprawdzanie flagi nadmiarowego
|
||||
void FuseOff(void); // wylaczenie nadmiarowego
|
||||
int ShowCurrent(int AmpN); //pokazuje bezwgl. wartosc pradu na wybranym amperomierzu
|
||||
int ShowCurrentP(int AmpN); //pokazuje bezwgl. wartosc pradu w wybranym pojezdzie //Q 20160722
|
||||
double ShowCurrent( int AmpN ); //pokazuje bezwgl. wartosc pradu na wybranym amperomierzu
|
||||
double ShowCurrentP(int AmpN); //pokazuje bezwgl. wartosc pradu w wybranym pojezdzie //Q 20160722
|
||||
|
||||
/*!o pokazuje bezwgl. wartosc obrotow na obrotomierzu jednego z 3 pojazdow*/
|
||||
/*function ShowEngineRotation(VehN:int): integer; //Ra 2014-06: przeniesione do C++*/
|
||||
@@ -1107,27 +1105,46 @@ public:
|
||||
|
||||
/*funkcje ladujace pliki opisujace pojazd*/
|
||||
bool LoadFIZ(std::string chkpath); //Q 20160717 bool LoadChkFile(std::string chkpath);
|
||||
bool LoadFIZ_Doors( std::string const &line );
|
||||
void LoadFIZ_BuffCoupl( std::string const &line, int const Index );
|
||||
bool CheckLocomotiveParameters( bool ReadyFlag, int Dir );
|
||||
std::string EngineDescription( int what );
|
||||
private:
|
||||
void LoadFIZ_Param( std::string const &line );
|
||||
void LoadFIZ_Load( std::string const &line );
|
||||
void LoadFIZ_Dimensions( std::string const &line );
|
||||
void LoadFIZ_Wheels( std::string const &line );
|
||||
void LoadFIZ_Brake( std::string const &line );
|
||||
void LoadFIZ_Doors( std::string const &line );
|
||||
void LoadFIZ_BuffCoupl( std::string const &line, int const Index );
|
||||
void LoadFIZ_TurboPos( std::string const &line );
|
||||
void LoadFIZ_Cntrl( std::string const &line );
|
||||
void LoadFIZ_Light( std::string const &line );
|
||||
void LoadFIZ_Security( std::string const &line );
|
||||
void LoadFIZ_Clima( std::string const &line );
|
||||
void LoadFIZ_Power( std::string const &Line );
|
||||
void LoadFIZ_Engine( std::string const &Input );
|
||||
void LoadFIZ_Switches( std::string const &Input );
|
||||
void LoadFIZ_MotorParamTable( std::string const &Input );
|
||||
void LoadFIZ_Circuit( std::string const &Input );
|
||||
void LoadFIZ_RList( std::string const &Input );
|
||||
void LoadFIZ_DList( std::string const &Input );
|
||||
void LoadFIZ_LightsList( std::string const &Input );
|
||||
void LoadFIZ_PowerParamsDecode( TPowerParameters &Powerparameters, std::string const Prefix, std::string const &Input );
|
||||
TPowerType LoadFIZ_PowerDecode( std::string const &Power );
|
||||
TPowerSource LoadFIZ_SourceDecode( std::string const &Source );
|
||||
TEngineTypes LoadFIZ_EngineDecode( std::string const &Engine );
|
||||
bool readMPT0( std::string const &line );
|
||||
bool readMPT( std::string const &line ); //Q 20160717
|
||||
bool readMPTElectricSeries( std::string const &line );
|
||||
bool readMPTDieselElectric( std::string const &line );
|
||||
bool readMPTDieselEngine( std::string const &line );
|
||||
bool readRList(int const ln, std::string const &line); //Q 20160718
|
||||
bool readBPT(/*int const ln,*/ std::string const &line); //Q 20160721
|
||||
bool readRList( std::string const &Input );
|
||||
bool readDList( std::string const &line );
|
||||
bool readFFList( std::string const &line );
|
||||
bool readWWList( std::string const &line );
|
||||
void BrakeValveDecode( std::string s ); //Q 20160719
|
||||
bool readLightsList( std::string const &Input );
|
||||
void BrakeValveDecode( std::string const &s ); //Q 20160719
|
||||
void BrakeSubsystemDecode(); //Q 20160719
|
||||
void PowerParamDecode(std::string lines, std::string prefix, TPowerParameters &PowerParamDecode); //Q 20160719
|
||||
TPowerSource PowerSourceDecode(std::string s); //Q 20160719
|
||||
TPowerType PowerDecode(std::string s); //Q 20160719
|
||||
TEngineTypes EngineDecode(std::string s); //Q 20160721
|
||||
bool CheckLocomotiveParameters(bool ReadyFlag, int Dir);
|
||||
std::string EngineDescription(int what);
|
||||
};
|
||||
|
||||
extern double Distance(TLocation Loc1, TLocation Loc2, TDimension Dim1, TDimension Dim2);
|
||||
@@ -1135,16 +1152,7 @@ extern double Distance(TLocation Loc1, TLocation Loc2, TDimension Dim1, TDimensi
|
||||
template <typename _Type>
|
||||
bool getkeyval( _Type &Variable, std::string const &Key, std::string const &Input, std::string const &Default ) {
|
||||
|
||||
std::string value;
|
||||
auto lookup = Input.find( Key + "=" );
|
||||
if( lookup != std::string::npos ) {
|
||||
value = Input.substr( Input.find_first_not_of( ' ', lookup + Key.size() + 1 ) );
|
||||
lookup = value.find( ' ' );
|
||||
if( lookup != std::string::npos ) {
|
||||
// trim everything past the value
|
||||
value.erase( lookup );
|
||||
}
|
||||
}
|
||||
auto value = extract_value( Key, Input );
|
||||
if( false == value.empty() ) {
|
||||
// set the specified variable to retrieved value
|
||||
std::stringstream converter;
|
||||
@@ -1161,4 +1169,21 @@ bool getkeyval( _Type &Variable, std::string const &Key, std::string const &Inpu
|
||||
}
|
||||
return false; // supplied the default
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
std::string
|
||||
extract_value( std::string const &Key, std::string const &Input ) {
|
||||
|
||||
std::string value;
|
||||
auto lookup = Input.find( Key + "=" );
|
||||
if( lookup != std::string::npos ) {
|
||||
value = Input.substr( Input.find_first_not_of( ' ', lookup + Key.size() + 1 ) );
|
||||
lookup = value.find( ' ' );
|
||||
if( lookup != std::string::npos ) {
|
||||
// trim everything past the value
|
||||
value.erase( lookup );
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
3149
McZapkie/Mover.cpp
3149
McZapkie/Mover.cpp
File diff suppressed because it is too large
Load Diff
@@ -51,16 +51,16 @@ double PF_old(double P1, double P2, double S)
|
||||
|
||||
double PF(double P1, double P2, double S, double DP)
|
||||
{
|
||||
double PH = Max0R(P1, P2) + 1; // wyzsze cisnienie absolutne
|
||||
double PH = std::max(P1, P2) + 1; // wyzsze cisnienie absolutne
|
||||
double PL = P1 + P2 - PH + 2; // nizsze cisnienie absolutne
|
||||
double sg = PL / PH; // bezwymiarowy stosunek cisnien
|
||||
double FM = PH * 197 * S * Sign(P2 - P1); // najwyzszy mozliwy przeplyw, wraz z kierunkiem
|
||||
if ((sg > 0.5)) // jesli ponizej stosunku krytycznego
|
||||
if ((PH - PL) < DP) // niewielka roznica cisnien
|
||||
return (1 - sg) / DPL * FM * 2 * sqrt((DP) * (PH - DP));
|
||||
return (1 - sg) / DPL * FM * 2 * std::sqrt((DP) * (PH - DP));
|
||||
// return 1/DPL*(PH-PL)*fm*2*SQRT((sg)*(1-sg));
|
||||
else
|
||||
return FM * 2 * sqrt((sg) * (1 - sg));
|
||||
return FM * 2 * std::sqrt((sg) * (1 - sg));
|
||||
else // powyzej stosunku krytycznego
|
||||
return FM;
|
||||
}
|
||||
@@ -69,15 +69,15 @@ double PF1(double P1, double P2, double S)
|
||||
{
|
||||
static double const DPS = 0.001;
|
||||
|
||||
double PH = Max0R(P1, P2) + 1; // wyzsze cisnienie absolutne
|
||||
double PH = std::max(P1, P2) + 1; // wyzsze cisnienie absolutne
|
||||
double PL = P1 + P2 - PH + 2; // nizsze cisnienie absolutne
|
||||
double sg = PL / PH; // bezwymiarowy stosunek cisnien
|
||||
double FM = PH * 197 * S * Sign(P2 - P1); // najwyzszy mozliwy przeplyw, wraz z kierunkiem
|
||||
if ((sg > 0.5)) // jesli ponizej stosunku krytycznego
|
||||
if ((sg < DPS)) // niewielka roznica cisnien
|
||||
return (1 - sg) / DPS * FM * 2 * sqrt((DPS) * (1 - DPS));
|
||||
return (1 - sg) / DPS * FM * 2 * std::sqrt((DPS) * (1 - DPS));
|
||||
else
|
||||
return FM * 2 * sqrt((sg) * (1 - sg));
|
||||
return FM * 2 * std::sqrt((sg) * (1 - sg));
|
||||
else // powyzej stosunku krytycznego
|
||||
return FM;
|
||||
}
|
||||
@@ -96,9 +96,9 @@ double PFVa(double PH, double PL, double S, double LIM,
|
||||
FM = FM * (LIM - PL) / DP; // jesli jestesmy przy nastawieniu, to zawor sie przymyka
|
||||
if ((sg > 0.5)) // jesli ponizej stosunku krytycznego
|
||||
if ((PH - PL) < DPL) // niewielka roznica cisnien
|
||||
return (PH - PL) / DPL * FM * 2 * sqrt((sg) * (1 - sg)); // BUG: (1-sg) can be < 0, leading to sqrt(-x)
|
||||
return (PH - PL) / DPL * FM * 2 * std::sqrt((sg) * (1 - sg)); // BUG: (1-sg) can be < 0, leading to sqrt(-x)
|
||||
else
|
||||
return FM * 2 * sqrt( (sg) * ( 1 - sg ) ); // BUG: (1-sg) can be < 0, leading to sqrt(-x)
|
||||
return FM * 2 * std::sqrt( (sg) * ( 1 - sg ) ); // BUG: (1-sg) can be < 0, leading to sqrt(-x)
|
||||
else // powyzej stosunku krytycznego
|
||||
return FM;
|
||||
}
|
||||
@@ -120,9 +120,9 @@ double PFVd(double PH, double PL, double S, double LIM,
|
||||
FM = FM * (PH - LIM) / DP; // jesli jestesmy przy nastawieniu, to zawor sie przymyka
|
||||
if ((sg > 0.5)) // jesli ponizej stosunku krytycznego
|
||||
if ((PH - PL) < DPL) // niewielka roznica cisnien
|
||||
return (PH - PL) / DPL * FM * 2 * sqrt((sg) * (1 - sg));
|
||||
return (PH - PL) / DPL * FM * 2 * std::sqrt((sg) * (1 - sg));
|
||||
else
|
||||
return FM * 2 * sqrt((sg) * (1 - sg));
|
||||
return FM * 2 * std::sqrt((sg) * (1 - sg));
|
||||
else // powyzej stosunku krytycznego
|
||||
return FM;
|
||||
}
|
||||
@@ -2749,8 +2749,8 @@ double TFD1::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
|
||||
|
||||
// MaxBP:=4;
|
||||
// temp:=Min0R(i_bcp*MaxBP,Min0R(5.0,HP));
|
||||
temp = Min0R(i_bcp * MaxBP, HP); // 0011
|
||||
DP = 10 * Min0R(abs(temp - BP), 0.1) * PF(temp, BP, 0.0006 * (2 + int(temp > BP))) * dt * Speed;
|
||||
temp = std::min(i_bcp * MaxBP, HP); // 0011
|
||||
DP = 10.0 * std::min(std::abs(temp - BP), 0.1) * PF(temp, BP, 0.0006 * (temp > BP ? 3.0 : 2.0) ) * dt * Speed;
|
||||
BP = BP - DP;
|
||||
return -DP;
|
||||
}
|
||||
|
||||
61
Names.h
61
Names.h
@@ -1,3 +1,4 @@
|
||||
#pragma once
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
@@ -7,8 +8,64 @@ obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#ifndef NamesH
|
||||
#define NamesH
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
|
||||
template <typename _Pointer>
|
||||
class TNames {
|
||||
|
||||
public:
|
||||
// types:
|
||||
|
||||
// constructors:
|
||||
TNames() = default;
|
||||
|
||||
// destructor:
|
||||
|
||||
// methods:
|
||||
// dodanie obiektu z wskaźnikiem. updates data field if the object already exists. returns true for insertion, false for update
|
||||
bool
|
||||
Add( int const Type, std::string const &Name, _Pointer Data ) {
|
||||
|
||||
auto lookup = find_map( Type ).emplace( Name, Data );
|
||||
if( lookup.second == false ) {
|
||||
// record already exists, update it
|
||||
lookup.first->second = Data;
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
// new record inserted, bail out
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// returns pointer associated with provided label, or nullptr if there's no match
|
||||
_Pointer
|
||||
Find( int const Type, std::string const &Name ) {
|
||||
|
||||
auto const &map = find_map( Type );
|
||||
auto const lookup = map.find( Name );
|
||||
if( lookup != map.end() ) { return lookup->second; }
|
||||
else { return nullptr; }
|
||||
}
|
||||
|
||||
private:
|
||||
// types:
|
||||
typedef std::unordered_map<std::string, _Pointer> pointer_map;
|
||||
typedef std::unordered_map<int, pointer_map> pointermap_map;
|
||||
|
||||
// methods:
|
||||
// returns database stored with specified type key; creates new database if needed.
|
||||
pointer_map &
|
||||
find_map( int const Type ) {
|
||||
|
||||
return m_maps.emplace( Type, pointer_map() ).first->second;
|
||||
}
|
||||
|
||||
// members:
|
||||
pointermap_map m_maps; // list of pointer maps of types specified so far
|
||||
};
|
||||
|
||||
#ifdef EU07_USE_OLD_TNAMES_CLASS
|
||||
//---------------------------------------------------------------------------
|
||||
class ItemRecord
|
||||
{ // rekord opisujący obiekt; raz utworzony nie przemieszcza się
|
||||
|
||||
40
Spring.cpp
40
Spring.cpp
@@ -29,7 +29,7 @@ void TSpring::Init(double nrestLen, double nKs, double nKd)
|
||||
restLen = nrestLen;
|
||||
}
|
||||
|
||||
bool TSpring::ComputateForces(vector3 pPosition1, vector3 pPosition2)
|
||||
Math3D::vector3 TSpring::ComputateForces(vector3 const &pPosition1, vector3 const &pPosition2)
|
||||
{
|
||||
|
||||
double dist, Hterm, Dterm;
|
||||
@@ -41,31 +41,29 @@ bool TSpring::ComputateForces(vector3 pPosition1, vector3 pPosition2)
|
||||
// dist = VectorLength(&deltaP); // Magnitude of
|
||||
// deltaP
|
||||
dist = deltaP.Length();
|
||||
if (dist == 0)
|
||||
{
|
||||
vForce1 = vForce2 = vector3(0, 0, 0);
|
||||
return false;
|
||||
if (dist != 0.0 ) {
|
||||
|
||||
// Hterm = (dist - spring->restLen) * spring->Ks; // Ks * (dist - rest)
|
||||
Hterm = ( dist - restLen ) * Ks; // Ks * (dist - rest)
|
||||
|
||||
// VectorDifference(&p1->v,&p2->v,&deltaV); // Delta Velocity Vector
|
||||
deltaV = pPosition1 - pPosition2;
|
||||
|
||||
// Dterm = (DotProduct(&deltaV,&deltaP) * spring->Kd) / dist; // Damping Term
|
||||
// Dterm = (DotProduct(deltaV,deltaP) * Kd) / dist;
|
||||
Dterm = 0;
|
||||
|
||||
// ScaleVector(&deltaP,1.0f / dist, &springForce); // Normalize Distance Vector
|
||||
// ScaleVector(&springForce,-(Hterm + Dterm),&springForce); // Calc Force
|
||||
springForce = deltaP / dist * ( -( Hterm + Dterm ) );
|
||||
// VectorSum(&p1->f,&springForce,&p1->f); // Apply to Particle 1
|
||||
// VectorDifference(&p2->f,&springForce,&p2->f); // - Force on Particle 2
|
||||
}
|
||||
|
||||
// Hterm = (dist - spring->restLen) * spring->Ks; // Ks * (dist - rest)
|
||||
Hterm = (dist - restLen) * Ks; // Ks * (dist - rest)
|
||||
|
||||
// VectorDifference(&p1->v,&p2->v,&deltaV); // Delta Velocity Vector
|
||||
deltaV = pPosition1 - pPosition2;
|
||||
|
||||
// Dterm = (DotProduct(&deltaV,&deltaP) * spring->Kd) / dist; // Damping Term
|
||||
// Dterm = (DotProduct(deltaV,deltaP) * Kd) / dist;
|
||||
Dterm = 0;
|
||||
|
||||
// ScaleVector(&deltaP,1.0f / dist, &springForce); // Normalize Distance Vector
|
||||
// ScaleVector(&springForce,-(Hterm + Dterm),&springForce); // Calc Force
|
||||
springForce = deltaP / dist * (-(Hterm + Dterm));
|
||||
// VectorSum(&p1->f,&springForce,&p1->f); // Apply to Particle 1
|
||||
// VectorDifference(&p2->f,&springForce,&p2->f); // - Force on Particle 2
|
||||
vForce1 = springForce;
|
||||
vForce2 = springForce;
|
||||
|
||||
return true;
|
||||
return springForce;
|
||||
}
|
||||
|
||||
void TSpring::Render()
|
||||
|
||||
2
Spring.h
2
Spring.h
@@ -31,7 +31,7 @@ class TSpring
|
||||
// void Init(TParticnp1, TParticle *np2, double nKs= 0.5f, double nKd= 0.002f,
|
||||
// double nrestLen= -1.0f);
|
||||
void Init(double nrestLen, double nKs = 0.5f, double nKd = 0.002f);
|
||||
bool ComputateForces(vector3 pPosition1, vector3 pPosition2);
|
||||
Math3D::vector3 ComputateForces(vector3 const &pPosition1, vector3 const &pPosition2);
|
||||
void Render();
|
||||
vector3 vForce1, vForce2;
|
||||
double restLen; // LENGTH OF SPRING AT REST
|
||||
|
||||
64
Train.cpp
64
Train.cpp
@@ -217,13 +217,13 @@ bool TTrain::Init(TDynamicObject *NewDynamicObject, bool e3d)
|
||||
}
|
||||
}
|
||||
*/
|
||||
MechSpring.Init(0, 500);
|
||||
MechSpring.Init(0.015, 250);
|
||||
vMechVelocity = vector3(0, 0, 0);
|
||||
pMechOffset = vector3(-0.4, 3.3, 5.5);
|
||||
fMechCroach = 0.5;
|
||||
fMechSpringX = 1;
|
||||
fMechSpringY = 0.1;
|
||||
fMechSpringZ = 0.1;
|
||||
fMechSpringY = 0.5;
|
||||
fMechSpringZ = 0.5;
|
||||
fMechMaxSpring = 0.15;
|
||||
fMechRoll = 0.05;
|
||||
fMechPitch = 0.1;
|
||||
@@ -2545,36 +2545,40 @@ void TTrain::UpdateMechPosition(double dt)
|
||||
// - przy szybkiej jeździe kabina prosto, horyzont pochylony
|
||||
|
||||
vector3 pNewMechPosition;
|
||||
Math3D::vector3 shake;
|
||||
// McZapkie: najpierw policzę pozycję w/m kabiny
|
||||
|
||||
// ABu: rzucamy kabina tylko przy duzym FPS!
|
||||
// Mala histereza, zeby bez przerwy nie przelaczalo przy FPS~17
|
||||
// Granice mozna ustalic doswiadczalnie. Ja proponuje 14:20
|
||||
double r1, r2, r3;
|
||||
int iVel = DynamicObject->GetVelocity();
|
||||
if (iVel > 150)
|
||||
iVel = 150;
|
||||
double const iVel = std::min(DynamicObject->GetVelocity(), 150.0);
|
||||
|
||||
if (!Global::iSlowMotion // musi być pełna prędkość
|
||||
&& (pMechOffset.y < 4.0)) // Ra 15-01: przy oglądaniu pantografu bujanie przeszkadza
|
||||
{
|
||||
if (!(Random((GetFPS() + 1) / 15) > 0))
|
||||
{
|
||||
if ((iVel > 0) && (Random(155 - iVel) < 16))
|
||||
{
|
||||
r1 = (double(Random(iVel * 2) - iVel) / ((iVel * 2) * 4)) * fMechSpringX;
|
||||
r2 = (double(Random(iVel * 2) - iVel) / ((iVel * 2) * 4)) * fMechSpringY;
|
||||
r3 = (double(Random(iVel * 2) - iVel) / ((iVel * 2) * 4)) * fMechSpringZ;
|
||||
MechSpring.ComputateForces(vector3(r1, r2, r3), pMechShake);
|
||||
// MechSpring.ComputateForces(vector3(double(random(200)-100)/200,double(random(200)-100)/200,double(random(200)-100)/500),pMechShake);
|
||||
if( iVel > 0.0 ) {
|
||||
// acceleration-driven base shake
|
||||
shake += 1.25 * MechSpring.ComputateForces(
|
||||
vector3(
|
||||
-mvControlled->AccN * dt * 5.0, // highlight side sway
|
||||
mvControlled->AccV * dt,
|
||||
-mvControlled->AccS * dt * 1.25 ), // accent acceleration/deceleration
|
||||
pMechShake );
|
||||
|
||||
if( Random( iVel ) > 25.0 ) {
|
||||
// extra shake at increased velocity
|
||||
shake += MechSpring.ComputateForces(
|
||||
vector3(
|
||||
( Random( iVel * 2 ) - iVel ) / ( ( iVel * 2 ) * 4 ) * fMechSpringX,
|
||||
( Random( iVel * 2 ) - iVel ) / ( ( iVel * 2 ) * 4 ) * fMechSpringY,
|
||||
( Random( iVel * 2 ) - iVel ) / ( ( iVel * 2 ) * 4 ) * fMechSpringZ ),
|
||||
pMechShake );
|
||||
// * (( 200 - DynamicObject->MyTrack->iQualityFlag ) * 0.0075 ); // scale to 75-150% based on track quality
|
||||
}
|
||||
else
|
||||
MechSpring.ComputateForces(vector3(-mvControlled->AccN * dt,
|
||||
mvControlled->AccV * dt * 10,
|
||||
-mvControlled->AccS * dt),
|
||||
pMechShake);
|
||||
// shake *= 1.25;
|
||||
}
|
||||
vMechVelocity -= (MechSpring.vForce2 + vMechVelocity * 100) *
|
||||
(fMechSpringX + fMechSpringY + fMechSpringZ) / (200);
|
||||
vMechVelocity -= (shake + vMechVelocity * 100) * (fMechSpringX + fMechSpringY + fMechSpringZ) / (200);
|
||||
// shake *= 0.95 * dt; // shake damping
|
||||
|
||||
// McZapkie:
|
||||
pMechShake += vMechVelocity * dt;
|
||||
@@ -2583,14 +2587,12 @@ void TTrain::UpdateMechPosition(double dt)
|
||||
if ((pMechShake.y > fMechMaxSpring) || (pMechShake.y < -fMechMaxSpring))
|
||||
vMechVelocity.y = -vMechVelocity.y;
|
||||
// ABu011104: 5*pMechShake.y, zeby ladnie pudlem rzucalo :)
|
||||
pNewMechPosition = pMechOffset + vector3(pMechShake.x, 5 * pMechShake.y, pMechShake.z);
|
||||
pNewMechPosition = pMechOffset + vector3(1.5 * pMechShake.x, 2.0 * pMechShake.y, 1.5 * pMechShake.z);
|
||||
vMechMovement = 0.5 * vMechMovement;
|
||||
}
|
||||
else
|
||||
{ // hamowanie rzucania przy spadku FPS
|
||||
pMechShake -= pMechShake * Min0R(dt, 1); // po tym chyba potrafią zostać
|
||||
// jakieś ułamki, które powodują
|
||||
// zjazd
|
||||
pMechShake -= pMechShake * std::min(dt, 1.0); // po tym chyba potrafią zostać jakieś ułamki, które powodują zjazd
|
||||
pMechOffset += vMechMovement * dt;
|
||||
vMechVelocity.y = 0.5 * vMechVelocity.y;
|
||||
pNewMechPosition = pMechOffset + vector3(pMechShake.x, 5 * pMechShake.y, pMechShake.z);
|
||||
@@ -5067,6 +5069,8 @@ bool TTrain::LoadMMediaFile(std::string const &asFileName)
|
||||
{
|
||||
double dSDist;
|
||||
cParser parser(asFileName, cParser::buffer_FILE);
|
||||
// NOTE: yaml-style comments are disabled until conflict in use of # is resolved
|
||||
// parser.addCommentStyle( "#", "\n" );
|
||||
//Wartości domyślne by nie wysypywało przy wybrakowanych mmd @240816 Stele
|
||||
dsbPneumaticSwitch = TSoundsManager::GetFromName("silence1.wav", true);
|
||||
dsbBufferClamp = TSoundsManager::GetFromName("en57_bufferclamp.wav", true);
|
||||
@@ -5312,7 +5316,7 @@ bool TTrain::LoadMMediaFile(std::string const &asFileName)
|
||||
double ks, kd;
|
||||
parser.getTokens(2, false);
|
||||
parser >> ks >> kd;
|
||||
MechSpring.Init(0, ks, kd);
|
||||
MechSpring.Init(MechSpring.restLen, ks, kd);
|
||||
parser.getTokens(6, false);
|
||||
parser >> fMechSpringX >> fMechSpringY >> fMechSpringZ >> fMechMaxSpring >>
|
||||
fMechRoll >> fMechPitch;
|
||||
@@ -5388,6 +5392,8 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
|
||||
std::string cabstr("cab" + std::to_string(cabindex) + "definition:");
|
||||
|
||||
std::shared_ptr<cParser> parser = std::make_shared<cParser>(asFileName, cParser::buffer_FILE);
|
||||
// NOTE: yaml-style comments are disabled until conflict in use of # is resolved
|
||||
// parser.addCommentStyle( "#", "\n" );
|
||||
std::string token;
|
||||
do
|
||||
{
|
||||
@@ -5404,6 +5410,8 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
|
||||
cabstr = "cab1definition:";
|
||||
// crude way to start parsing from beginning
|
||||
parser = std::make_shared<cParser>(asFileName, cParser::buffer_FILE);
|
||||
// NOTE: yaml-style comments are disabled until conflict in use of # is resolved
|
||||
// parser.addCommentStyle( "#", "\n" );
|
||||
do
|
||||
{
|
||||
token = "";
|
||||
|
||||
15
World.cpp
15
World.cpp
@@ -1930,16 +1930,11 @@ TWorld::Render_UI() {
|
||||
if( Global::iTextMode == VK_F1 ) { // tekst pokazywany po wciśnięciu [F1]
|
||||
// Global::iViewMode=VK_F1;
|
||||
glColor3f( 1.0f, 1.0f, 1.0f ); // a, damy białym
|
||||
OutText1 = "Time: " + to_string( (int)GlobalTime->hh ) + ":";
|
||||
int i = GlobalTime->mm; // bo inaczej potrafi zrobić "hh:010"
|
||||
if( i < 10 )
|
||||
OutText1 += "0";
|
||||
OutText1 += to_string( i ); // minuty
|
||||
OutText1 += ":";
|
||||
i = floor( GlobalTime->mr ); // bo inaczej potrafi zrobić "hh:mm:010"
|
||||
if( i < 10 )
|
||||
OutText1 += "0";
|
||||
OutText1 += to_string( i );
|
||||
OutText1 =
|
||||
"Time: "
|
||||
+ to_string( (int)GlobalTime->hh ) + ":"
|
||||
+ ( GlobalTime->mm < 10 ? "0" : "" ) + to_string( GlobalTime->mm ) + ":"
|
||||
+ ( GlobalTime->mr < 10 ? "0" : "" ) + to_string( std::floor( GlobalTime->mr ) );
|
||||
if( Global::iPause )
|
||||
OutText1 += " - paused";
|
||||
if( Controlled )
|
||||
|
||||
@@ -114,7 +114,6 @@
|
||||
<ClCompile Include="MemCell.cpp" />
|
||||
<ClCompile Include="Model3d.cpp" />
|
||||
<ClCompile Include="mtable.cpp" />
|
||||
<ClCompile Include="Names.cpp" />
|
||||
<ClCompile Include="opengl\ARB_Multisample.cpp" />
|
||||
<ClCompile Include="parser.cpp" />
|
||||
<ClCompile Include="PyInt.cpp" />
|
||||
|
||||
@@ -99,9 +99,6 @@
|
||||
<ClCompile Include="mtable.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Names.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="parser.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
||||
13
mtable.cpp
13
mtable.cpp
@@ -59,7 +59,7 @@ double TTrainParameters::WatchMTable(double DistCounter)
|
||||
std::string TTrainParameters::NextStop()
|
||||
{ // pobranie nazwy następnego miejsca zatrzymania
|
||||
if (StationIndex <= StationCount)
|
||||
return "PassengerStopPoint:" + NextStationName; // nazwa następnego przystanku;
|
||||
return NextStationName; // nazwa następnego przystanku;
|
||||
else
|
||||
return "[End of route]"; //że niby koniec
|
||||
}
|
||||
@@ -401,11 +401,14 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
|
||||
}
|
||||
while (s.find("|") == std::string::npos)
|
||||
fin >> s;
|
||||
fin >> record->StationWare;
|
||||
do
|
||||
{
|
||||
// stationware. added fix for empty entry
|
||||
fin >> s;
|
||||
while( false == ( ( s == "1" )
|
||||
|| ( s == "2" )
|
||||
|| fin.bad() ) ) {
|
||||
record->StationWare += s;
|
||||
fin >> s;
|
||||
} while (!((s == "1") || (s == "2") || fin.bad()));
|
||||
}
|
||||
record->TrackNo = atoi(s.c_str());
|
||||
fin >> s;
|
||||
if (s != "|")
|
||||
|
||||
@@ -21,9 +21,9 @@ http://mozilla.org/MPL/2.0/.
|
||||
// cParser -- generic class for parsing text data.
|
||||
|
||||
// constructors
|
||||
cParser::cParser(std::string const Stream, buffertype Type, std::string Path, bool tr)
|
||||
cParser::cParser( std::string const &Stream, buffertype const Type, std::string Path, bool const Loadtraction )
|
||||
{
|
||||
LoadTraction = tr;
|
||||
LoadTraction = Loadtraction;
|
||||
// build comments map
|
||||
mComments.insert(commentmap::value_type("/*", "*/"));
|
||||
mComments.insert(commentmap::value_type("//", "\n"));
|
||||
@@ -236,3 +236,8 @@ int cParser::getProgress() const
|
||||
{
|
||||
return static_cast<int>( mStream->rdbuf()->pubseekoff(0, std::ios_base::cur) * 100 / mSize );
|
||||
}
|
||||
|
||||
void cParser::addCommentStyle( std::string const &Commentstart, std::string const &Commentend ) {
|
||||
|
||||
mComments.insert( commentmap::value_type(Commentstart, Commentend) );
|
||||
}
|
||||
|
||||
15
parser.h
15
parser.h
@@ -28,8 +28,7 @@ class cParser //: public std::stringstream
|
||||
buffer_TEXT
|
||||
};
|
||||
// constructors:
|
||||
cParser(std::string Stream, buffertype Type = buffer_TEXT, std::string Path = "",
|
||||
bool tr = true);
|
||||
cParser(std::string const &Stream, buffertype const Type = buffer_TEXT, std::string Path = "", bool const Loadtraction = true );
|
||||
// destructor:
|
||||
virtual ~cParser();
|
||||
// methods:
|
||||
@@ -79,9 +78,10 @@ class cParser //: public std::stringstream
|
||||
return !mStream->fail();
|
||||
};
|
||||
bool getTokens(int Count = 1, bool ToLower = true, const char *Break = "\n\t ;");
|
||||
int getProgress() const; // percentage of file processed.
|
||||
// load traction?
|
||||
bool LoadTraction;
|
||||
// returns percentage of file processed so far
|
||||
int getProgress() const;
|
||||
// add custom definition of text which should be ignored when retrieving tokens
|
||||
void addCommentStyle( std::string const &Commentstart, std::string const &Commentend );
|
||||
|
||||
private:
|
||||
// methods:
|
||||
@@ -92,6 +92,7 @@ class cParser //: public std::stringstream
|
||||
bool findQuotes( std::string &String );
|
||||
bool trimComments( std::string &String );
|
||||
// members:
|
||||
bool LoadTraction; // load traction?
|
||||
std::istream *mStream; // relevant kind of buffer is attached on creation.
|
||||
std::string mPath; // path to open stream, for relative path lookups.
|
||||
std::streamoff mSize; // size of open stream, for progress report.
|
||||
@@ -133,7 +134,9 @@ cParser::operator>>( bool &Right ) {
|
||||
|
||||
if( true == this->tokens.empty() ) { return *this; }
|
||||
|
||||
Right = ( this->tokens.front() == "true" );
|
||||
Right = ( ( this->tokens.front() == "true" )
|
||||
|| ( this->tokens.front() == "yes" )
|
||||
|| ( this->tokens.front() == "1" ) );
|
||||
this->tokens.pop_front();
|
||||
|
||||
return *this;
|
||||
|
||||
Reference in New Issue
Block a user