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

build 190906. alternative vehicle takeover mode, collision system tweaks, security system activation tweaks, gfx card selection exports, potential render crash fixe for amd gfx cards

This commit is contained in:
tmj-fstate
2019-09-07 14:54:57 +02:00
parent 68a45db21a
commit bda879bdca
15 changed files with 141 additions and 82 deletions

View File

@@ -2110,12 +2110,18 @@ bool TController::CheckVehicles(TOrders user)
{ // sprawdzanie, czy jest głównym sterującym, żeby nie było konfliktu { // sprawdzanie, czy jest głównym sterującym, żeby nie było konfliktu
if (p->Mechanik) // jeśli ma obsadę if (p->Mechanik) // jeśli ma obsadę
if (p->Mechanik != this) // ale chodzi o inny pojazd, niż aktualnie sprawdzający if (p->Mechanik != this) // ale chodzi o inny pojazd, niż aktualnie sprawdzający
if (p->Mechanik->iDrivigFlags & movePrimary) // a tamten ma priorytet if( p->Mechanik->iDrivigFlags & movePrimary ) {
if ((iDrivigFlags & movePrimary) && (mvOccupied->DirAbsolute) && // a tamten ma priorytet
(mvOccupied->BrakeCtrlPos >= -1)) // jeśli rządzi i ma kierunek if( ( iDrivigFlags & movePrimary )
p->Mechanik->iDrivigFlags &= ~movePrimary; // dezaktywuje tamtego && ( mvOccupied->DirAbsolute )
else && ( mvOccupied->BrakeCtrlPos >= -1 ) ) {
// jeśli rządzi i ma kierunek
p->Mechanik->primary( false ); // dezaktywuje tamtego
}
else {
main = false; // nici z rządzenia main = false; // nici z rządzenia
}
}
++iVehicles; // jest jeden pojazd więcej ++iVehicles; // jest jeden pojazd więcej
pVehicles[1] = p; // zapamiętanie ostatniego pVehicles[1] = p; // zapamiętanie ostatniego
fLength += p->MoverParameters->Dim.L; // dodanie długości pojazdu fLength += p->MoverParameters->Dim.L; // dodanie długości pojazdu
@@ -4763,7 +4769,7 @@ TController::UpdateSituation(double dt) {
// rozpoznaj komende bo lokomotywa jej nie rozpoznaje // rozpoznaj komende bo lokomotywa jej nie rozpoznaje
RecognizeCommand(); // samo czyta komendę wstawioną do pojazdu? RecognizeCommand(); // samo czyta komendę wstawioną do pojazdu?
} }
if( mvOccupied->SecuritySystem.Status > 1 ) { if( mvOccupied->SecuritySystem.Status != s_off ) {
// jak zadziałało CA/SHP // jak zadziałało CA/SHP
if( !mvOccupied->SecuritySystemReset() ) { // to skasuj if( !mvOccupied->SecuritySystemReset() ) { // to skasuj
if( ( /*mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition == 0 ) if( ( /*mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition == 0 )
@@ -6759,43 +6765,56 @@ void TController::UpdateDelayFlag() {
//-----------koniec skanowania semaforow //-----------koniec skanowania semaforow
void TController::TakeControl(bool yes) void TController::TakeControl( bool const Aidriver, bool const Forcevehiclecheck )
{ // przejęcie kontroli przez AI albo oddanie { // przejęcie kontroli przez AI albo oddanie
if (AIControllFlag == yes) if (AIControllFlag == Aidriver)
return; // już jest jak ma być return; // już jest jak ma być
if (yes) //żeby nie wykonywać dwa razy if (Aidriver) //żeby nie wykonywać dwa razy
{ // teraz AI prowadzi { // teraz AI prowadzi
AIControllFlag = AIdriver; AIControllFlag = AIdriver;
pVehicle->Controller = AIdriver; pVehicle->Controller = AIdriver;
iDirection = 0; // kierunek jazdy trzeba dopiero zgadnąć iDirection = 0; // kierunek jazdy trzeba dopiero zgadnąć
// gdy zgaszone światła, flaga podjeżdżania pod semafory pozostaje bez zmiany
// conditional below disabled to get around the situation where the AI train does nothing ever
// because it is waiting for orders which don't come until the engine is engaged, i.e. effectively never
if (OrderCurrentGet()) // jeśli coś robi
PrepareEngine(); // niech sprawdzi stan silnika
else // jeśli nic nie robi
if (pVehicle->iLights[ ( mvOccupied->CabNo < 0 ?
end::rear :
end::front ) ]
& (light::headlight_left | light::headlight_right | light::headlight_upper)) // któreś ze świateł zapalone?
{ // od wersji 357 oczekujemy podania komend dla AI przez scenerię
OrderNext(Prepare_engine);
if (pVehicle->iLights[mvOccupied->CabNo < 0 ? end::rear : end::front] & light::headlight_upper) // górne światło zapalone
OrderNext(Obey_train); // jazda pociągowa
else
OrderNext(Shunt); // jazda manewrowa
if (mvOccupied->Vel >= 1.0) // jeśli jedzie (dla 0.1 ma stać)
iDrivigFlags &= ~moveStopHere; // to ma nie czekać na sygnał, tylko jechać
else
iDrivigFlags |= moveStopHere; // a jak stoi, to niech czeka
}
CheckVehicles(); // ustawienie świateł
TableClear(); // ponowne utworzenie tabelki, bo człowiek mógł pojechać niezgodnie z sygnałami TableClear(); // ponowne utworzenie tabelki, bo człowiek mógł pojechać niezgodnie z sygnałami
if( action() != TAction::actSleep ) {
// gdy zgaszone światła, flaga podjeżdżania pod semafory pozostaje bez zmiany
// conditional below disabled to get around the situation where the AI train does nothing ever
// because it is waiting for orders which don't come until the engine is engaged, i.e. effectively never
if( OrderCurrentGet() ) {
// jeśli coś robi
PrepareEngine(); // niech sprawdzi stan silnika
}
else {
// jeśli nic nie robi
if( pVehicle->iLights[ ( mvOccupied->CabNo < 0 ?
end::rear :
end::front ) ]
& ( light::headlight_left | light::headlight_right | light::headlight_upper ) ) // któreś ze świateł zapalone?
{ // od wersji 357 oczekujemy podania komend dla AI przez scenerię
OrderNext( Prepare_engine );
if( pVehicle->iLights[ mvOccupied->CabNo < 0 ? end::rear : end::front ] & light::headlight_upper ) // górne światło zapalone
OrderNext( Obey_train ); // jazda pociągowa
else
OrderNext( Shunt ); // jazda manewrowa
if( mvOccupied->Vel >= 1.0 ) // jeśli jedzie (dla 0.1 ma stać)
iDrivigFlags &= ~moveStopHere; // to ma nie czekać na sygnał, tylko jechać
else
iDrivigFlags |= moveStopHere; // a jak stoi, to niech czeka
}
}
CheckVehicles(); // ustawienie świateł
}
} }
else else
{ // a teraz użytkownik { // a teraz użytkownik
AIControllFlag = Humandriver; AIControllFlag = Humandriver;
pVehicle->Controller = Humandriver; pVehicle->Controller = Humandriver;
if( eAction == TAction::actSleep ) {
eAction = TAction::actUnknown;
}
if( Forcevehiclecheck ) {
// update consist ownership and other consist data
CheckVehicles();
}
} }
}; };

View File

@@ -194,9 +194,13 @@ public:
public: public:
void UpdateSituation(double dt); // uruchamiac przynajmniej raz na sekundę void UpdateSituation(double dt); // uruchamiac przynajmniej raz na sekundę
void MoveTo(TDynamicObject *to); void MoveTo(TDynamicObject *to);
void TakeControl(bool yes); void TakeControl(bool const Aidriver, bool const Forcevehiclecheck = false);
inline inline
bool Primary() const { bool primary( bool const Primary ) {
SetFlag( iDrivigFlags, ( Primary ? movePrimary : -movePrimary ) );
return primary(); }
inline
bool primary() const {
return ( ( iDrivigFlags & movePrimary ) != 0 ); }; return ( ( iDrivigFlags & movePrimary ) != 0 ); };
inline inline
TMoverParameters const *Controlling() const { TMoverParameters const *Controlling() const {
@@ -211,7 +215,10 @@ public:
int Direction() const { int Direction() const {
return iDirection; } return iDirection; }
inline inline
TAction GetAction() { TAction & action() {
return eAction; }
inline
TAction const & action() const {
return eAction; } return eAction; }
private: private:
void Activation(); // umieszczenie obsady w odpowiednim członie void Activation(); // umieszczenie obsady w odpowiednim członie

View File

@@ -980,8 +980,8 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist)
if( ( false == bDisplayCab ) // edge case, lowpoly may act as a stand-in for the hi-fi cab, so make sure not to show the driver when inside if( ( false == bDisplayCab ) // edge case, lowpoly may act as a stand-in for the hi-fi cab, so make sure not to show the driver when inside
&& ( Mechanik != nullptr ) && ( Mechanik != nullptr )
&& ( ( Mechanik->GetAction() != TAction::actSleep ) && ( ( Mechanik->action() != TAction::actSleep )
|| ( MoverParameters->Battery ) ) ) { /* || ( MoverParameters->Battery ) */ ) ) {
// rysowanie figurki mechanika // rysowanie figurki mechanika
btMechanik1.Turn( MoverParameters->ActiveCab > 0 ); btMechanik1.Turn( MoverParameters->ActiveCab > 0 );
btMechanik2.Turn( MoverParameters->ActiveCab < 0 ); btMechanik2.Turn( MoverParameters->ActiveCab < 0 );
@@ -2762,14 +2762,14 @@ bool TDynamicObject::Update(double dt, double dt1)
if (Mechanik) if (Mechanik)
{ // Ra 2F3F: do Driver.cpp to przenieść? { // Ra 2F3F: do Driver.cpp to przenieść?
MoverParameters->EqvtPipePress = GetEPP(); // srednie cisnienie w PG MoverParameters->EqvtPipePress = GetEPP(); // srednie cisnienie w PG
if ((Mechanik->Primary()) if ((Mechanik->primary())
&& (MoverParameters->EngineType == TEngineType::DieselEngine) && (MoverParameters->EngineType == TEngineType::DieselEngine)
&& (MoverParameters->EIMCtrlType > 0)) { && (MoverParameters->EIMCtrlType > 0)) {
MoverParameters->CheckEIMIC(dt1); MoverParameters->CheckEIMIC(dt1);
MoverParameters->eimic_real = MoverParameters->eimic; MoverParameters->eimic_real = MoverParameters->eimic;
MoverParameters->SendCtrlToNext("EIMIC", MoverParameters->eimic, MoverParameters->CabNo); MoverParameters->SendCtrlToNext("EIMIC", MoverParameters->eimic, MoverParameters->CabNo);
} }
if( ( Mechanik->Primary() ) if( ( Mechanik->primary() )
&& ( MoverParameters->EngineType == TEngineType::ElectricInductionMotor ) ) { && ( MoverParameters->EngineType == TEngineType::ElectricInductionMotor ) ) {
// jesli glowny i z asynchronami, to niech steruje hamulcem i napedem lacznie dla calego pociagu/ezt // jesli glowny i z asynchronami, to niech steruje hamulcem i napedem lacznie dla calego pociagu/ezt
auto const kier = (DirectionGet() * MoverParameters->ActiveCab > 0); auto const kier = (DirectionGet() * MoverParameters->ActiveCab > 0);

View File

@@ -897,7 +897,7 @@ whois_event::run_() {
// jeśli typ pojazdu // jeśli typ pojazdu
// TODO: define and recognize individual request types // TODO: define and recognize individual request types
auto const owner { ( auto const owner { (
( ( m_activator->Mechanik != nullptr ) && ( m_activator->Mechanik->Primary() ) ) ? ( ( m_activator->Mechanik != nullptr ) && ( m_activator->Mechanik->primary() ) ) ?
m_activator->Mechanik : m_activator->Mechanik :
m_activator->ctOwner ) }; m_activator->ctOwner ) };
auto const consistbrakelevel { ( auto const consistbrakelevel { (
@@ -952,7 +952,7 @@ whois_event::run_() {
} }
// +0 // +0
else if( m_activator->Mechanik ) { else if( m_activator->Mechanik ) {
if( m_activator->Mechanik->Primary() ) { // tylko jeśli ktoś tam siedzi - nie powinno dotyczyć pasażera! if( m_activator->Mechanik->primary() ) { // tylko jeśli ktoś tam siedzi - nie powinno dotyczyć pasażera!
targetcell->UpdateValues( targetcell->UpdateValues(
m_activator->Mechanik->TrainName(), m_activator->Mechanik->TrainName(),
m_activator->Mechanik->StationCount() - m_activator->Mechanik->StationIndex(), // ile przystanków do końca m_activator->Mechanik->StationCount() - m_activator->Mechanik->StationIndex(), // ile przystanków do końca

View File

@@ -204,6 +204,7 @@ static int const dbrake_automatic = 8;
/*status czuwaka/SHP*/ /*status czuwaka/SHP*/
//hunter-091012: rozdzielenie alarmow, dodanie testu czuwaka //hunter-091012: rozdzielenie alarmow, dodanie testu czuwaka
static int const s_off = 0; //disabled
static int const s_waiting = 1; //działa static int const s_waiting = 1; //działa
static int const s_aware = 2; //czuwak miga static int const s_aware = 2; //czuwak miga
static int const s_active = 4; //SHP świeci static int const s_active = 4; //SHP świeci

View File

@@ -1051,7 +1051,10 @@ void TMoverParameters::CollisionDetect(int const End, double const dt)
if( velocitydifference > safevelocitylimit ) { if( velocitydifference > safevelocitylimit ) {
// HACK: crude estimation for potential derail, will take place with velocity difference > 15 km/h adjusted for vehicle mass ratio // HACK: crude estimation for potential derail, will take place with velocity difference > 15 km/h adjusted for vehicle mass ratio
WriteLog( "Bad driving: " + Name + " and " + othervehicle->Name + " collided with velocity " + to_string( velocitydifference, 0 ) + " km/h" ); if( ( false == TestFlag( DamageFlag, dtrain_out ) )
|| ( false == TestFlag( othervehicle->DamageFlag, dtrain_out ) ) ) {
WriteLog( "Bad driving: " + Name + " and " + othervehicle->Name + " collided with velocity " + to_string( velocitydifference, 0 ) + " km/h" );
}
if( velocitydifference > safevelocitylimit * ( TotalMass / othervehicle->TotalMass ) ) { if( velocitydifference > safevelocitylimit * ( TotalMass / othervehicle->TotalMass ) ) {
derail( 5 ); derail( 5 );
@@ -1084,12 +1087,14 @@ void TMoverParameters::CollisionDetect(int const End, double const dt)
void void
TMoverParameters::damage_coupler( int const End ) { TMoverParameters::damage_coupler( int const End ) {
auto &coupler{ Couplers[ End ] };
if( coupler.CouplerType == TCouplerType::Articulated ) { return; } // HACK: don't break articulated couplings no matter what
if( SetFlag( DamageFlag, dtrain_coupling ) ) if( SetFlag( DamageFlag, dtrain_coupling ) )
EventFlag = true; EventFlag = true;
auto &coupler { Couplers[ End ] }; if( ( coupler.CouplingFlag & coupling::brakehose ) == coupling::brakehose ) {
if( ( coupler.CouplingFlag & ctrain_pneumatic ) == ctrain_pneumatic ) {
// hamowanie nagle - zerwanie przewodow hamulcowych // hamowanie nagle - zerwanie przewodow hamulcowych
AlarmChainFlag = true; AlarmChainFlag = true;
} }
@@ -1100,11 +1105,11 @@ TMoverParameters::damage_coupler( int const End ) {
switch( End ) { switch( End ) {
// break connection with other vehicle, if there's any // break connection with other vehicle, if there's any
case 0: { case 0: {
coupler.Connected->Couplers[ end::rear ].CouplingFlag = 0; coupler.Connected->Couplers[ end::rear ].CouplingFlag = coupling::faux;
break; break;
} }
case 1: { case 1: {
coupler.Connected->Couplers[ end::front ].CouplingFlag = 0; coupler.Connected->Couplers[ end::front ].CouplingFlag = coupling::faux;
break; break;
} }
default: { default: {
@@ -2301,7 +2306,7 @@ bool TMoverParameters::CabDeactivisation(void)
CabNo = 0; CabNo = 0;
DirAbsolute = ActiveDir * CabNo; DirAbsolute = ActiveDir * CabNo;
DepartureSignal = false; // nie buczeć z nieaktywnej kabiny DepartureSignal = false; // nie buczeć z nieaktywnej kabiny
SecuritySystem.Status = 0; // deactivate alerter TODO: make it part of control based cab selection SecuritySystem.Status = s_off; // deactivate alerter TODO: make it part of control based cab selection
SendCtrlToNext("CabActivisation", 0, ActiveCab); // CabNo==0! SendCtrlToNext("CabActivisation", 0, ActiveCab); // CabNo==0!
} }
@@ -2446,7 +2451,7 @@ void TMoverParameters::SecuritySystemCheck(double dt)
RadiostopSwitch(false); RadiostopSwitch(false);
if ((SecuritySystem.SystemType > 0) if ((SecuritySystem.SystemType > 0)
&& (SecuritySystem.Status > 0) && (SecuritySystem.Status != s_off)
&& (Battery)) // Ra: EZT ma teraz czuwak w rozrządczym && (Battery)) // Ra: EZT ma teraz czuwak w rozrządczym
{ {
// CA // CA
@@ -2537,8 +2542,8 @@ bool TMoverParameters::BatterySwitch(bool State)
SendCtrlToNext("BatterySwitch", 0, CabNo); SendCtrlToNext("BatterySwitch", 0, CabNo);
BS = true; BS = true;
if ((Battery) && (ActiveCab != 0)) /*|| (TrainType==dt_EZT)*/ if ((Battery) && (ActiveCab != 0))
SecuritySystem.Status = (SecuritySystem.Status | s_waiting); // aktywacja czuwaka SecuritySystem.Status |= s_waiting; // aktywacja czuwaka
else else
SecuritySystem.Status = 0; // wyłączenie czuwaka SecuritySystem.Status = 0; // wyłączenie czuwaka
@@ -10397,10 +10402,13 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C
Battery = true; Battery = true;
else if ((CValue1 == 0)) else if ((CValue1 == 0))
Battery = false; Battery = false;
if ((Battery) && (ActiveCab != 0) /*or (TrainType=dt_EZT)*/) /*
// TBD: makes no sense to activate alerters in entire consist
if ((Battery) && (ActiveCab != 0) )
SecuritySystem.Status = SecuritySystem.Status | s_waiting; // aktywacja czuwaka SecuritySystem.Status = SecuritySystem.Status | s_waiting; // aktywacja czuwaka
else else
SecuritySystem.Status = 0; // wyłączenie czuwaka SecuritySystem.Status = 0; // wyłączenie czuwaka
*/
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
} }
// else if command='EpFuseSwitch' then {NBMX} // else if command='EpFuseSwitch' then {NBMX}

View File

@@ -5667,7 +5667,7 @@ bool TTrain::Update( double const Deltatime )
} }
} }
// McZapkie-141102: SHP i czuwak, TODO: sygnalizacja kabinowa // McZapkie-141102: SHP i czuwak, TODO: sygnalizacja kabinowa
if( mvOccupied->SecuritySystem.Status > 0 ) { if( mvOccupied->SecuritySystem.Status != s_off ) {
if( fBlinkTimer > fCzuwakBlink ) if( fBlinkTimer > fCzuwakBlink )
fBlinkTimer = -fCzuwakBlink; fBlinkTimer = -fCzuwakBlink;
else else
@@ -5695,7 +5695,7 @@ bool TTrain::Update( double const Deltatime )
false ) ); false ) );
btLampkaWylSzybkiOff.Turn( btLampkaWylSzybkiOff.Turn(
( ( ( mvControlled->MainsInitTimeCountdown > 0.0 ) ( ( ( mvControlled->MainsInitTimeCountdown > 0.0 )
|| ( fHVoltage == 0.0 ) // || ( fHVoltage == 0.0 )
|| ( m_linebreakerstate == 2 ) || ( m_linebreakerstate == 2 )
|| ( true == mvControlled->Mains ) ) ? || ( true == mvControlled->Mains ) ) ?
false : false :
@@ -5928,7 +5928,10 @@ bool TTrain::Update( double const Deltatime )
auto const *mover { tmp->MoverParameters }; auto const *mover { tmp->MoverParameters };
btLampkaWylSzybkiB.Turn( mover->Mains ); btLampkaWylSzybkiB.Turn( mover->Mains );
btLampkaWylSzybkiBOff.Turn( ( false == mover->Mains ) && ( mover->MainsInitTimeCountdown <= 0.0 ) && ( fHVoltage != 0.0 ) ); btLampkaWylSzybkiBOff.Turn(
( false == mover->Mains )
&& ( mover->MainsInitTimeCountdown <= 0.0 )
/*&& ( fHVoltage != 0.0 )*/ );
btLampkaOporyB.Turn(mover->ResistorsFlagCheck()); btLampkaOporyB.Turn(mover->ResistorsFlagCheck());
btLampkaBezoporowaB.Turn( btLampkaBezoporowaB.Turn(
@@ -6528,7 +6531,7 @@ TTrain::update_sounds( double const Deltatime ) {
} }
// McZapkie-141102: SHP i czuwak, TODO: sygnalizacja kabinowa // McZapkie-141102: SHP i czuwak, TODO: sygnalizacja kabinowa
if (mvOccupied->SecuritySystem.Status > 0) { if (mvOccupied->SecuritySystem.Status != s_off ) {
// hunter-091012: rozdzielenie alarmow // hunter-091012: rozdzielenie alarmow
if( TestFlag( mvOccupied->SecuritySystem.Status, s_CAalarm ) if( TestFlag( mvOccupied->SecuritySystem.Status, s_CAalarm )
|| TestFlag( mvOccupied->SecuritySystem.Status, s_SHPalarm ) ) { || TestFlag( mvOccupied->SecuritySystem.Status, s_SHPalarm ) ) {

View File

@@ -116,7 +116,7 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
if( false == ismoving ) { if( false == ismoving ) {
//McZapkie-140602: wyzwalanie zdarzenia gdy pojazd stoi //McZapkie-140602: wyzwalanie zdarzenia gdy pojazd stoi
if( ( Owner->Mechanik != nullptr ) if( ( Owner->Mechanik != nullptr )
&& ( Owner->Mechanik->Primary() ) ) { && ( Owner->Mechanik->primary() ) ) {
// tylko dla jednego członu // tylko dla jednego członu
pCurrentTrack->QueueEvents( pCurrentTrack->m_events0, Owner ); pCurrentTrack->QueueEvents( pCurrentTrack->m_events0, Owner );
} }
@@ -127,7 +127,7 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
if( SetFlag( iEventFlag, -1 ) ) { if( SetFlag( iEventFlag, -1 ) ) {
// zawsze zeruje flagę sprawdzenia, jak mechanik dosiądzie, to się nie wykona // zawsze zeruje flagę sprawdzenia, jak mechanik dosiądzie, to się nie wykona
if( ( Owner->Mechanik != nullptr ) if( ( Owner->Mechanik != nullptr )
&& ( Owner->Mechanik->Primary() ) ) { && ( Owner->Mechanik->primary() ) ) {
// tylko dla jednego członu // tylko dla jednego członu
// McZapkie-280503: wyzwalanie event tylko dla pojazdow z obsada // McZapkie-280503: wyzwalanie event tylko dla pojazdow z obsada
pCurrentTrack->QueueEvents( pCurrentTrack->m_events1, Owner ); pCurrentTrack->QueueEvents( pCurrentTrack->m_events1, Owner );
@@ -143,7 +143,7 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
if( SetFlag( iEventFlag, -2 ) ) { if( SetFlag( iEventFlag, -2 ) ) {
// zawsze ustawia flagę sprawdzenia, jak mechanik dosiądzie, to się nie wykona // zawsze ustawia flagę sprawdzenia, jak mechanik dosiądzie, to się nie wykona
if( ( Owner->Mechanik != nullptr ) if( ( Owner->Mechanik != nullptr )
&& ( Owner->Mechanik->Primary() ) ) { && ( Owner->Mechanik->primary() ) ) {
// tylko dla jednego członu // tylko dla jednego członu
pCurrentTrack->QueueEvents( pCurrentTrack->m_events2, Owner ); pCurrentTrack->QueueEvents( pCurrentTrack->m_events2, Owner );
} }

View File

@@ -43,6 +43,9 @@ http://mozilla.org/MPL/2.0/.
#pragma comment (lib, "dbghelp.lib") #pragma comment (lib, "dbghelp.lib")
#pragma comment (lib, "version.lib") #pragma comment (lib, "version.lib")
extern "C" { _declspec( dllexport ) DWORD AmdPowerXpressRequestHighPerformance = 0x00000001; }
extern "C" { _declspec( dllexport ) DWORD NvOptimusEnablement = 0x00000001; }
eu07_application Application; eu07_application Application;
ui_layer uilayerstaticinitializer; ui_layer uilayerstaticinitializer;

View File

@@ -723,20 +723,36 @@ driver_mode::OnKeyDown(int cKey) {
if( tmp != nullptr ) { if( tmp != nullptr ) {
if( simulation::Train ) {// jeśli mielismy pojazd
if( simulation::Train->Dynamic()->Mechanik ) { // na skutek jakiegoś błędu może czasem zniknąć
simulation::Train->Dynamic()->Mechanik->TakeControl( true ); // oddajemy dotychczasowy AI
}
}
if( ( true == DebugModeFlag ) if( ( true == DebugModeFlag )
|| ( tmp->MoverParameters->Vel <= 5.0 ) ) { || ( tmp->MoverParameters->Vel <= 5.0 ) ) {
// works always in debug mode, or for stopped/slow moving vehicles otherwise // works always in debug mode, or for stopped/slow moving vehicles otherwise
if( simulation::Train ) { // jeśli mielismy pojazd
if( simulation::Train->Dynamic()->Mechanik ) { // na skutek jakiegoś błędu może czasem zniknąć
if( ( tmp->ctOwner == simulation::Train->Dynamic()->Mechanik )
&& ( true == Global.ctrlState ) ) {
// if the vehicle we left to the ai controlled the vehicle we're about to take over
// put the ai we left in charge of our old vehicle to sleep
// TODO: remove ctrl key mode once manual cab (de)activation is in place
simulation::Train->Dynamic()->Mechanik->primary( false );
simulation::Train->Dynamic()->Mechanik->action() = TAction::actSleep;
simulation::Train->Dynamic()->MoverParameters->CabDeactivisation();
}
simulation::Train->Dynamic()->Mechanik->TakeControl( true ); // oddajemy dotychczasowy AI
}
}
if( simulation::Train == nullptr ) { if( simulation::Train == nullptr ) {
simulation::Train = new TTrain(); // jeśli niczym jeszcze nie jeździlismy simulation::Train = new TTrain(); // jeśli niczym jeszcze nie jeździlismy
} }
if( simulation::Train->Init( tmp ) ) { // przejmujemy sterowanie if( simulation::Train->Init( tmp ) ) {
simulation::Train->Dynamic()->Mechanik->TakeControl( false ); // przejmujemy sterowanie
if( true == Global.ctrlState ) {
// make sure we can take over the consist
// TODO: remove ctrl key mode once manual cab (de)activation is in place
simulation::Train->Dynamic()->Mechanik->primary( true );
simulation::Train->Dynamic()->MoverParameters->CabActivisation();
}
simulation::Train->Dynamic()->Mechanik->TakeControl( false, true );
} }
else { else {
SafeDelete( simulation::Train ); // i nie ma czym sterować SafeDelete( simulation::Train ); // i nie ma czym sterować

View File

@@ -170,7 +170,7 @@ scenario_panel::update() {
std::get<TDynamicObject *>( simulation::Region->find_vehicle( camera.Pos, 20, false, false ) ) ); // w trybie latania lokalizujemy wg mapy std::get<TDynamicObject *>( simulation::Region->find_vehicle( camera.Pos, 20, false, false ) ) ); // w trybie latania lokalizujemy wg mapy
if( m_nearest == nullptr ) { return; } if( m_nearest == nullptr ) { return; }
auto const *owner { ( auto const *owner { (
( ( m_nearest->Mechanik != nullptr ) && ( m_nearest->Mechanik->Primary() ) ) ? ( ( m_nearest->Mechanik != nullptr ) && ( m_nearest->Mechanik->primary() ) ) ?
m_nearest->Mechanik : m_nearest->Mechanik :
m_nearest->ctOwner ) }; m_nearest->ctOwner ) };
if( owner == nullptr ) { return; } if( owner == nullptr ) { return; }
@@ -208,7 +208,7 @@ scenario_panel::render() {
if( true == ImGui::Begin( panelname.c_str(), &is_open, flags ) ) { if( true == ImGui::Begin( panelname.c_str(), &is_open, flags ) ) {
// potential assignment section // potential assignment section
auto const *owner { ( auto const *owner { (
( ( m_nearest->Mechanik != nullptr ) && ( m_nearest->Mechanik->Primary() ) ) ? ( ( m_nearest->Mechanik != nullptr ) && ( m_nearest->Mechanik->primary() ) ) ?
m_nearest->Mechanik : m_nearest->Mechanik :
m_nearest->ctOwner ) }; m_nearest->ctOwner ) };
if( owner != nullptr ) { if( owner != nullptr ) {
@@ -261,7 +261,7 @@ timetable_panel::update() {
if( vehicle == nullptr ) { return; } if( vehicle == nullptr ) { return; }
// if the nearest located vehicle doesn't have a direct driver, try to query its owner // if the nearest located vehicle doesn't have a direct driver, try to query its owner
auto const *owner = ( auto const *owner = (
( ( vehicle->Mechanik != nullptr ) && ( vehicle->Mechanik->Primary() ) ) ? ( ( vehicle->Mechanik != nullptr ) && ( vehicle->Mechanik->primary() ) ) ?
vehicle->Mechanik : vehicle->Mechanik :
vehicle->ctOwner ); vehicle->ctOwner );
if( owner == nullptr ) { return; } if( owner == nullptr ) { return; }
@@ -553,7 +553,7 @@ debug_panel::update_section_vehicle( std::vector<text_line> &Output ) {
auto const &vehicle { *m_input.vehicle }; auto const &vehicle { *m_input.vehicle };
auto const &mover { *m_input.mover }; auto const &mover { *m_input.mover };
auto const isowned { ( vehicle.Mechanik == nullptr ) && ( vehicle.ctOwner != nullptr ) }; auto const isowned { /* ( vehicle.Mechanik == nullptr ) && */ ( vehicle.ctOwner != nullptr ) && ( vehicle.ctOwner->Vehicle() != m_input.vehicle ) };
auto const isplayervehicle { ( m_input.train != nullptr ) && ( m_input.train->Dynamic() == m_input.vehicle ) }; auto const isplayervehicle { ( m_input.train != nullptr ) && ( m_input.train->Dynamic() == m_input.vehicle ) };
auto const isdieselenginepowered { ( mover.EngineType == TEngineType::DieselElectric ) || ( mover.EngineType == TEngineType::DieselEngine ) }; auto const isdieselenginepowered { ( mover.EngineType == TEngineType::DieselElectric ) || ( mover.EngineType == TEngineType::DieselEngine ) };
auto const isdieselinshuntmode { mover.ShuntMode && mover.EngineType == TEngineType::DieselElectric }; auto const isdieselinshuntmode { mover.ShuntMode && mover.EngineType == TEngineType::DieselElectric };

View File

@@ -370,7 +370,7 @@ WyslijObsadzone()
r.fPar[ 16 * i + 4 ] = vehicle->GetPosition().x; r.fPar[ 16 * i + 4 ] = vehicle->GetPosition().x;
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->GetAction() ); 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()->IsolatedName().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++;

View File

@@ -179,16 +179,17 @@ opengl_particles::update( opengl_camera const &Camera ) {
if( m_buffercapacity < m_particlevertices.size() ) { if( m_buffercapacity < m_particlevertices.size() ) {
// allocate gpu side buffer big enough to hold the data // allocate gpu side buffer big enough to hold the data
m_buffercapacity = 0; m_buffercapacity = 0;
if( m_buffer != -1 ) { if( m_buffer != (GLuint)-1 ) {
// get rid of the old buffer // get rid of the old buffer
::glDeleteBuffers( 1, &m_buffer ); ::glDeleteBuffers( 1, &m_buffer );
m_buffer = (GLuint)-1;
} }
::glGenBuffers( 1, &m_buffer ); ::glGenBuffers( 1, &m_buffer );
::glBindBuffer( GL_ARRAY_BUFFER, m_buffer ); if( ( m_buffer > 0 ) && ( m_buffer != (GLuint)-1 ) ) {
if( m_buffer > 0 ) {
// if we didn't get a buffer we'll try again during the next draw call // if we didn't get a buffer we'll try again during the next draw call
// NOTE: we match capacity instead of current size to reduce number of re-allocations // NOTE: we match capacity instead of current size to reduce number of re-allocations
auto const particlecount { m_particlevertices.capacity() }; auto const particlecount { m_particlevertices.capacity() };
::glBindBuffer( GL_ARRAY_BUFFER, m_buffer );
::glBufferData( ::glBufferData(
GL_ARRAY_BUFFER, GL_ARRAY_BUFFER,
particlecount * sizeof( particle_vertex ), particlecount * sizeof( particle_vertex ),
@@ -198,7 +199,7 @@ opengl_particles::update( opengl_camera const &Camera ) {
// TBD: throw a bad_alloc? // TBD: throw a bad_alloc?
ErrorLog( "openGL error: out of memory; failed to create a geometry buffer" ); ErrorLog( "openGL error: out of memory; failed to create a geometry buffer" );
::glDeleteBuffers( 1, &m_buffer ); ::glDeleteBuffers( 1, &m_buffer );
m_buffer = -1; m_buffer = (GLuint)-1;
} }
else { else {
m_buffercapacity = particlecount; m_buffercapacity = particlecount;
@@ -206,7 +207,7 @@ opengl_particles::update( opengl_camera const &Camera ) {
} }
} }
// ...send the data... // ...send the data...
if( m_buffer > 0 ) { if( ( m_buffer > 0 ) && ( m_buffer != (GLuint)-1 ) ) {
// if the buffer exists at this point it's guaranteed to be big enough to hold our data // if the buffer exists at this point it's guaranteed to be big enough to hold our data
::glBindBuffer( GL_ARRAY_BUFFER, m_buffer ); ::glBindBuffer( GL_ARRAY_BUFFER, m_buffer );
::glBufferSubData( ::glBufferSubData(
@@ -225,6 +226,7 @@ opengl_particles::render( int const Textureunit ) {
if( false == Global.Smoke ) { return; } if( false == Global.Smoke ) { return; }
if( m_buffercapacity == 0 ) { return; } if( m_buffercapacity == 0 ) { return; }
if( m_particlevertices.empty() ) { return; } if( m_particlevertices.empty() ) { return; }
if( ( m_buffer == 0 ) || ( m_buffer == (GLuint)-1 ) ) { return; }
// setup... // setup...
::glPushClientAttrib( GL_CLIENT_VERTEX_ARRAY_BIT ); ::glPushClientAttrib( GL_CLIENT_VERTEX_ARRAY_BIT );
@@ -239,6 +241,10 @@ opengl_particles::render( int const Textureunit ) {
// ...draw... // ...draw...
::glDrawArrays( GL_QUADS, 0, m_particlevertices.size() ); ::glDrawArrays( GL_QUADS, 0, m_particlevertices.size() );
// ...and cleanup // ...and cleanup
::glBindBuffer( GL_ARRAY_BUFFER, 0 );
if( Global.bUseVBO ) {
gfx::opengl_vbogeometrybank::reset();
}
::glPopClientAttrib(); ::glPopClientAttrib();
} }
@@ -3163,10 +3169,6 @@ opengl_renderer::Render_particles() {
Bind_Texture( m_smoketexture ); Bind_Texture( m_smoketexture );
m_particlerenderer.render( m_diffusetextureunit ); m_particlerenderer.render( m_diffusetextureunit );
if( Global.bUseVBO ) {
// shouldn't be strictly necessary but, eh
gfx::opengl_vbogeometrybank::reset();
}
::glDepthMask( GL_TRUE ); ::glDepthMask( GL_TRUE );
::glEnable( GL_LIGHTING ); ::glEnable( GL_LIGHTING );

View File

@@ -672,7 +672,7 @@ state_serializer::deserialize_endtrainset( cParser &Input, scene::scratch_data &
for( auto *vehicle : Scratchpad.trainset.vehicles ) { for( auto *vehicle : Scratchpad.trainset.vehicles ) {
// go through list of vehicles in the trainset, coupling them together and checking for potential driver // go through list of vehicles in the trainset, coupling them together and checking for potential driver
if( ( vehicle->Mechanik != nullptr ) if( ( vehicle->Mechanik != nullptr )
&& ( vehicle->Mechanik->Primary() ) ) { && ( vehicle->Mechanik->primary() ) ) {
// primary driver will receive the timetable for this trainset // primary driver will receive the timetable for this trainset
Scratchpad.trainset.driver = vehicle; Scratchpad.trainset.driver = vehicle;
// they'll also receive assignment data if there's any // they'll also receive assignment data if there's any

View File

@@ -1,5 +1,5 @@
#pragma once #pragma once
#define VERSION_MAJOR 19 #define VERSION_MAJOR 19
#define VERSION_MINOR 902 #define VERSION_MINOR 906
#define VERSION_REVISION 0 #define VERSION_REVISION 0