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

build 170520. compressor activation for multi-unit engines, gamepad support toggle, local brake logic fix for multi-unit engines

This commit is contained in:
tmj-fstate
2017-05-20 21:09:03 +02:00
parent c38511978d
commit e805533f54
10 changed files with 182 additions and 122 deletions

View File

@@ -2246,76 +2246,79 @@ bool TController::ReleaseEngine()
bool TController::IncBrake()
{ // zwiększenie hamowania
bool OK = false;
switch (mvOccupied->BrakeSystem)
{
case Individual:
if (mvOccupied->LocalBrake == ManualBrake)
OK = mvOccupied->IncManualBrakeLevel( 1 + static_cast<int>( std::floor( 0.5 + std::fabs(AccDesired))) );
else
OK = mvOccupied->IncLocalBrakeLevel( std::floor( 1.5 + std::abs( AccDesired ) ) );
break;
case Pneumatic:
// NOTE: can't perform just test whether connected vehicle == nullptr, due to virtual couplers formed with nearby vehicles
if ((mvOccupied->Couplers[0].CouplingFlag == 0) &&
(mvOccupied->Couplers[1].CouplingFlag == 0))
OK = mvOccupied->IncLocalBrakeLevel(
1 + static_cast<int>( std::floor( 0.5 + std::fabs(AccDesired))) ); // hamowanie lokalnym bo luzem jedzie
else
{
if (mvOccupied->BrakeCtrlPos + 1 == mvOccupied->BrakeCtrlPosNo)
{
if (AccDesired < -1.5) // hamowanie nagle
OK = mvOccupied->IncBrakeLevel();
else
OK = false;
switch( mvOccupied->BrakeSystem ) {
case Individual: {
if( mvOccupied->LocalBrake == ManualBrake ) {
OK = mvOccupied->IncManualBrakeLevel( 1 + static_cast<int>( std::floor( 0.5 + std::fabs( AccDesired ) ) ) );
}
else {
OK = mvOccupied->IncLocalBrakeLevel( std::floor( 1.5 + std::abs( AccDesired ) ) );
}
break;
}
case Pneumatic: {
// NOTE: can't perform just test whether connected vehicle == nullptr, due to virtual couplers formed with nearby vehicles
bool standalone{ true };
if( ( mvOccupied->TrainType == dt_ET41 )
|| ( mvOccupied->TrainType == dt_ET42 ) ) {
// NOTE: we're doing simplified checks full of presuptions here.
// they'll break if someone does strange thing like turning around the second unit
if( ( mvOccupied->Couplers[ 1 ].CouplingFlag & coupling::permanent )
&& ( mvOccupied->Couplers[ 1 ].Connected->Couplers[ 1 ].CouplingFlag > 0 ) ) {
standalone = false;
}
if( ( mvOccupied->Couplers[ 0 ].CouplingFlag & coupling::permanent )
&& ( mvOccupied->Couplers[ 0 ].Connected->Couplers[ 0 ].CouplingFlag > 0 ) ) {
standalone = false;
}
}
else {
standalone =
( ( mvOccupied->Couplers[ 0 ].CouplingFlag == 0 )
&& ( mvOccupied->Couplers[ 1 ].CouplingFlag == 0 ) );
}
if( true == standalone ) {
OK = mvOccupied->IncLocalBrakeLevel(
1 + static_cast<int>( std::floor( 0.5 + std::fabs( AccDesired ) ) ) ); // hamowanie lokalnym bo luzem jedzie
}
else {
if( mvOccupied->BrakeCtrlPos + 1 == mvOccupied->BrakeCtrlPosNo ) {
if( AccDesired < -1.5 ) // hamowanie nagle
OK = mvOccupied->IncBrakeLevel();
else
OK = false;
}
else {
// dodane dla towarowego
if( mvOccupied->BrakeDelayFlag == bdelay_G ?
-AccDesired * 6.6 > std::min( 2, mvOccupied->BrakeCtrlPos ) :
true ) {
OK = mvOccupied->IncBrakeLevel();
}
else
OK = false;
}
}
if( mvOccupied->BrakeCtrlPos > 0 ) {
mvOccupied->BrakeReleaser( 0 );
}
break;
}
case ElectroPneumatic: {
if( mvOccupied->EngineType == ElectricInductionMotor ) {
OK = mvOccupied->IncLocalBrakeLevel( 1 );
}
else if( mvOccupied->fBrakeCtrlPos != mvOccupied->Handle->GetPos( bh_EPB ) ) {
mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_EPB ) );
if( mvOccupied->Handle->GetPos( bh_EPR ) - mvOccupied->Handle->GetPos( bh_EPN ) < 0.1 )
mvOccupied->SwitchEPBrake( 1 ); // to nie chce działać
OK = true;
}
else
{
/*
if (AccDesired>-0.2) and ((Vel<20) or (Vel-VelNext<10)))
begin
if BrakeCtrlPos>0)
OK:=IncBrakeLevel
else;
OK:=IncLocalBrakeLevel(1); //finezyjne hamowanie lokalnym
end
else
*/
// dodane dla towarowego
if (mvOccupied->BrakeDelayFlag == bdelay_G ?
-AccDesired * 6.6 > std::min(2, mvOccupied->BrakeCtrlPos) :
true)
{
OK = mvOccupied->IncBrakeLevel();
}
else
OK = false;
}
OK = false;
break;
}
if (mvOccupied->BrakeCtrlPos > 0)
mvOccupied->BrakeReleaser(0);
break;
case ElectroPneumatic:
if (mvOccupied->EngineType == ElectricInductionMotor)
{
OK = mvOccupied->IncLocalBrakeLevel(1);
}
else if (mvOccupied->fBrakeCtrlPos != mvOccupied->Handle->GetPos(bh_EPB))
{
mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_EPB));
if (mvOccupied->Handle->GetPos(bh_EPR) - mvOccupied->Handle->GetPos(bh_EPN) < 0.1)
mvOccupied->SwitchEPBrake(1); // to nie chce działać
OK = true;
}
else
OK = false;
// if (mvOccupied->BrakeCtrlPos<mvOccupied->BrakeCtrlPosNo)
// if
// (mvOccupied->BrakePressureTable[mvOccupied->BrakeCtrlPos+1+2].BrakeType==ElectroPneumatic)
// //+2 to indeks Pascala
// OK=mvOccupied->IncBrakeLevel();
// else
// OK=false;
default: { break; }
}
return OK;
}

View File

@@ -1879,8 +1879,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424"
{ // McZapkie-040602: jeśli coś siedzi w pojeździe
if (Name == Global::asHumanCtrlVehicle) // jeśli pojazd wybrany do prowadzenia
{
if (DebugModeFlag ? false : MoverParameters->EngineType !=
Dumb) // jak nie Debugmode i nie jest dumbem
if ( MoverParameters->EngineType != Dumb)
Controller = Humandriver; // wsadzamy tam sterującego
else // w przeciwnym razie trzeba włączyć pokazywanie kabiny
bDisplayCab = true;

View File

@@ -411,7 +411,9 @@ int main(int argc, char *argv[])
&& GfxRenderer.Render())
{
glfwPollEvents();
input::Gamepad.poll();
if( true == Global::InputGamepad ) {
input::Gamepad.poll();
}
}
Console::Off(); // wyłączenie konsoli (komunikacji zwrotnej)
}

View File

@@ -110,6 +110,7 @@ int Global::iWindowHeight = 600;
float Global::fDistanceFactor = Global::ScreenHeight / 768.0; // baza do przeliczania odległości dla LoD
int Global::iFeedbackMode = 1; // tryb pracy informacji zwrotnej
int Global::iFeedbackPort = 0; // dodatkowy adres dla informacji zwrotnych
bool Global::InputGamepad{ true };
bool Global::bFreeFly = false;
bool Global::bFullScreen = false;
bool Global::VSync{ false };
@@ -801,6 +802,11 @@ void Global::ConfigParse(cParser &Parser)
>> Global::Background[1] // g
>> Global::Background[2]; // b
}
else if( token == "input.gamepad" ) {
// czy grupować eventy o tych samych nazwach
Parser.getTokens();
Parser >> Global::InputGamepad;
}
// maciek001: ustawienia MWD
else if (token == "mwdmasterenable") { // główne włączenie maszyny!
Parser.getTokens();

View File

@@ -255,6 +255,7 @@ class Global
static std::string LastGLError;
static int iFeedbackMode; // tryb pracy informacji zwrotnej
static int iFeedbackPort; // dodatkowy adres dla informacji zwrotnych
static bool InputGamepad; // whether gamepad support is enabled
static double fLuminance; // jasność światła do automatycznego zapalania
static float SunAngle; // angle of the sun relative to horizon
static int iMultiplayer; // blokada działania niektórych eventów na rzecz kominikacji
@@ -287,7 +288,6 @@ class Global
static int iKeyLast; // ostatnio naciśnięty klawisz w celu logowania
static int iPause; // globalna pauza ruchu: b0=start,b1=klawisz,b2=tło,b3=lagi,b4=wczytywanie
static bool bActive; // czy jest aktywnym oknem
static void BindTexture(GLuint t);
static int iConvertModels; // tworzenie plików binarnych
static int iErorrCounter; // licznik sprawdzań do śledzenia błędów OpenGL
static bool bInactivePause; // automatyczna pauza, gdy okno nieaktywne

View File

@@ -3063,56 +3063,104 @@ void TMoverParameters::CompressorCheck(double dt)
CompressorFlag = false; // bez tamtego członu nie zadziała
}
else
CompressorFlag = (CompressorAllow) &&
((ConverterFlag) || (CompressorPower == 0)) && (Mains);
CompressorFlag =
( ( CompressorAllow )
&& ( Mains )
&& ( ( ConverterFlag )
|| ( CompressorPower == 0 ) ) );
if( Compressor > MaxCompressor ) {
// wyłącznik ciśnieniowy jest niezależny od sposobu zasilania
CompressorFlag = false;
CompressorGovernorLock = true; // prevent manual activation until the pressure goes below cut-in level
}
}
else // jeśli nie załączona
if( ( ( Compressor < MinCompressor )
|| ( ( Compressor < MaxCompressor )
&& ( false == CompressorGovernorLock ) ) )
&& (LastSwitchingTime > CtrlDelay) ) {
// załączenie przy małym ciśnieniu
// jeśli nie załączona, a ciśnienie za małe
// or if the switch is on and the pressure isn't maxed
if( CompressorPower == 5 ) // jeśli zasilanie z następnego członu
{ // zasilanie sprężarki w członie ra z członu silnikowego (sprzęg 1)
if (Couplers[1].Connected != NULL)
CompressorFlag =
(Couplers[1].Connected->CompressorAllow &&
Couplers[1].Connected->ConverterFlag && Couplers[1].Connected->Mains);
else
CompressorFlag = false; // bez tamtego członu nie zadziała
}
else if (CompressorPower == 4) // jeśli zasilanie z poprzedniego członu
{ // zasilanie sprężarki w członie ra z członu silnikowego (sprzęg 1)
if (Couplers[0].Connected != NULL)
CompressorFlag =
(Couplers[0].Connected->CompressorAllow &&
Couplers[0].Connected->ConverterFlag && Couplers[0].Connected->Mains);
else
CompressorFlag = false; // bez tamtego członu nie zadziała
}
else
CompressorFlag = (CompressorAllow) &&
((ConverterFlag) || (CompressorPower == 0)) && (Mains);
if( CompressorFlag ) {
// jeśli została załączona
LastSwitchingTime = 0; // to trzeba ograniczyć ponowne włączenie
if( Compressor < MinCompressor ) {
// if the activation took place at pressure below the cut-in level, we can reset compressor governor
CompressorGovernorLock = false;
if( ( TrainType == dt_ET41 )
|| ( TrainType == dt_ET42 ) ) {
// for these multi-unit engines compressors turn off whenever any of them was affected by the governor
// NOTE: this is crude implementation, TODO: re-implement when a more elegant/flexible system is in place
if( ( Couplers[ 1 ].Connected != nullptr )
&& ( true == TestFlag( Couplers[ 1 ].CouplingFlag, coupling::permanent ) ) ) {
// the first unit isn't allowed to start its compressor until second unit can start its own as well
CompressorFlag &= ( Couplers[ 1 ].Connected->CompressorGovernorLock == false );
}
if( ( Couplers[ 0 ].Connected != nullptr )
&& ( true == TestFlag( Couplers[ 0 ].CouplingFlag, coupling::permanent ) ) ) {
// the second unit isn't allowed to start its compressor until first unit can start its own as well
CompressorFlag &= ( Couplers[ 0 ].Connected->CompressorGovernorLock == false );
}
}
}
// for b:=0 to 1 do //z Megapacka
// with Couplers[b] do
// if TestFlag(CouplingFlag,ctrain_scndpneumatic) then
// Connected.CompressorFlag:=CompressorFlag;
else {
// jeśli nie załączona
if( Compressor < MinCompressor ) {
// if the pressure drops below the cut-in level, we can reset compressor governor
CompressorGovernorLock = false;
}
if( ( ( Compressor < MinCompressor )
|| ( ( Compressor < MaxCompressor )
&& ( false == CompressorGovernorLock ) ) )
&& ( LastSwitchingTime > CtrlDelay ) ) {
// załączenie przy małym ciśnieniu
// jeśli nie załączona, a ciśnienie za małe
// or if the switch is on and the pressure isn't maxed
if( CompressorPower == 5 ) // jeśli zasilanie z następnego członu
{ // zasilanie sprężarki w członie ra z członu silnikowego (sprzęg 1)
if( Couplers[ 1 ].Connected != nullptr ) {
CompressorFlag =
( Couplers[ 1 ].Connected->CompressorAllow
&& Couplers[ 1 ].Connected->ConverterFlag
&& Couplers[ 1 ].Connected->Mains );
}
else {
CompressorFlag = false; // bez tamtego członu nie zadziała
}
}
else if( CompressorPower == 4 ) // jeśli zasilanie z poprzedniego członu
{ // zasilanie sprężarki w członie ra z członu silnikowego (sprzęg 1)
if( Couplers[ 0 ].Connected != nullptr ) {
CompressorFlag =
( Couplers[ 0 ].Connected->CompressorAllow
&& Couplers[ 0 ].Connected->ConverterFlag
&& Couplers[ 0 ].Connected->Mains );
}
else {
CompressorFlag = false; // bez tamtego członu nie zadziała
}
}
else {
CompressorFlag =
( ( CompressorAllow )
&& ( Mains )
&& ( ( ConverterFlag )
|| ( CompressorPower == 0 ) ) );
}
// NOTE: crude way to enforce simultaneous activation of compressors in multi-unit setups
// TODO: replace this with a more universal activation system down the road
if( ( TrainType == dt_ET41 )
|| ( TrainType == dt_ET42 ) ) {
if( ( Couplers[1].Connected != nullptr )
&& ( true == TestFlag( Couplers[ 1 ].CouplingFlag, coupling::permanent ) ) ) {
// the first unit isn't allowed to start its compressor until second unit can start its own as well
CompressorFlag &= ( Couplers[ 1 ].Connected->CompressorGovernorLock == false );
}
if( ( Couplers[ 0 ].Connected != nullptr )
&& ( true == TestFlag( Couplers[ 0 ].CouplingFlag, coupling::permanent ) ) ) {
// the second unit isn't allowed to start its compressor until first unit can start its own as well
CompressorFlag &= ( Couplers[ 0 ].Connected->CompressorGovernorLock == false );
}
}
if( CompressorFlag ) {
// jeśli została załączona
LastSwitchingTime = 0; // to trzeba ograniczyć ponowne włączenie
}
}
}
if (CompressorFlag)
if ((EngineType == DieselElectric) && (CompressorPower > 0))
CompressedVolume += dt * CompressorSpeed * (2.0 * MaxCompressor - Compressor) /

View File

@@ -114,7 +114,10 @@ bool TSegment::Init(vector3 &NewPoint1, vector3 NewCPointOut, vector3 NewCPointI
{
ErrorLog( "Bad geometry (zero length) for spline \"" + pOwner->NameGet() + "\" at " + Where( Point1 ) );
// MessageBox(0,"Length<=0","TSegment::Init",MB_OK);
fLength = 0.01; // crude workaround TODO: fix this properly
/*
return false; // zerowe nie mogą być
*/
}
if( ( pOwner->eType == tt_Switch )

View File

@@ -532,7 +532,7 @@ void TTrack::Load(cParser *parser, vector3 pOrigin, std::string name)
// na przechyłce doliczyć jeszcze pół przechyłki
}
if( fRadius != 0 ) // gdy podany promień
segsize = clamp( 0.2 + fabs( fRadius ) * 0.02, 2.5, 10.0 );
segsize = clamp( 0.2 + std::fabs( fRadius ) * 0.02, 2.0, 10.0 );
else
segsize = 10.0; // for straights, 10m per segment works good enough
@@ -595,7 +595,7 @@ void TTrack::Load(cParser *parser, vector3 pOrigin, std::string name)
// na przechyłce doliczyć jeszcze pół przechyłki?
}
if (fRadiusTable[0] > 0)
segsize = clamp( 0.2 + fRadiusTable[0] * 0.02, 2.5, 5.0 );
segsize = clamp( 0.2 + fRadiusTable[0] * 0.02, 2.0, 5.0 );
else if (eType != tt_Cross) // dla skrzyżowań muszą być podane kontrolne
{ // jak promień zerowy, to przeliczamy punkty kontrolne
cp1 = (p1 + p1 + p2) / 3.0 - p1; // jak jest prosty, to się zoptymalizuje
@@ -625,7 +625,7 @@ void TTrack::Load(cParser *parser, vector3 pOrigin, std::string name)
}
if (fRadiusTable[1] > 0)
segsize = clamp( 0.2 + fRadiusTable[ 1 ] * 0.02, 2.5, 5.0 );
segsize = clamp( 0.2 + fRadiusTable[ 1 ] * 0.02, 2.0, 5.0 );
else if (eType != tt_Cross) // dla skrzyżowań muszą być podane kontrolne
{ // jak promień zerowy, to przeliczamy punkty kontrolne

View File

@@ -375,11 +375,12 @@ bool TWorld::Init( GLFWwindow *Window ) {
WriteLog( "Load time: " +
std::to_string( std::chrono::duration_cast<std::chrono::seconds>(( std::chrono::system_clock::now() - timestart )).count() )
+ " seconds");
/*
if (DebugModeFlag) // w Debugmode automatyczne włączenie AI
if (Train)
if (Train->Dynamic()->Mechanik)
Train->Dynamic()->Mechanik->TakeControl(true);
*/
UILayer.set_progress();
UILayer.set_background( "" );
UILayer.clear_texts();
@@ -1748,11 +1749,9 @@ TWorld::Update_UI() {
Global::Bezogonkow( "| " + station + " | " + arrival + " | " + departure + " | " + vmax + " | " + tableline->StationWare, true ),
( ( owner->iStationStart < table->StationIndex )
&& ( i < table->StationIndex )
&& ( time.wHour >= tableline->Dh )
&& ( time.wMinute >= tableline->Dm ) ?
&& ( ( time.wHour * 60 + time.wMinute ) >= ( tableline->Dh * 60 + tableline->Dm ) ) ?
float4( 0.0f, 1.0f, 0.0f, 1.0f ) :// czas minął i odjazd był, to nazwa stacji będzie na zielono
Global::UITextColor )
);
Global::UITextColor ) );
// divider/footer
UITable->text_lines.emplace_back( "+----------------------------+-------+-------+-----+", Global::UITextColor );
}

View File

@@ -1,5 +1,5 @@
#pragma once
#define VERSION_MAJOR 17
#define VERSION_MINOR 519
#define VERSION_MINOR 520
#define VERSION_REVISION 0