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

Merge with TMJ

This commit is contained in:
Królik Uszasty
2019-04-27 14:43:00 +02:00
9 changed files with 54 additions and 19 deletions

View File

@@ -456,7 +456,7 @@ bool TController::TableAddNew()
return true; // false gdy się nałoży return true; // false gdy się nałoży
}; };
bool TController::TableNotFound(basic_event const *Event) const bool TController::TableNotFound(basic_event const *Event, double const Distance ) const
{ // sprawdzenie, czy nie został już dodany do tabelki (np. podwójne W4 robi problemy) { // sprawdzenie, czy nie został już dodany do tabelki (np. podwójne W4 robi problemy)
auto lookup = auto lookup =
std::find_if( std::find_if(
@@ -471,7 +471,11 @@ bool TController::TableNotFound(basic_event const *Event) const
WriteLog( "Speed table for " + OwnerName() + " already contains event " + lookup->evEvent->m_name ); WriteLog( "Speed table for " + OwnerName() + " already contains event " + lookup->evEvent->m_name );
} }
return lookup == sSpeedTable.end(); // ignore duplicates which seem to be reasonably apart from each other, on account of looping tracks
// NOTE: since supplied distance is only rough approximation of distance to the event, we're using large safety margin
return (
( lookup == sSpeedTable.end() )
|| ( Distance - lookup->fDist > 100.0 ) );
}; };
void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle) void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle)
@@ -575,7 +579,7 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle)
for( auto *pEvent : events ) { for( auto *pEvent : events ) {
if( pEvent != nullptr ) // jeśli jest semafor na tym torze if( pEvent != nullptr ) // jeśli jest semafor na tym torze
{ // trzeba sprawdzić tabelkę, bo dodawanie drugi raz tego samego przystanku nie jest korzystne { // trzeba sprawdzić tabelkę, bo dodawanie drugi raz tego samego przystanku nie jest korzystne
if (TableNotFound(pEvent)) // jeśli nie ma if (TableNotFound(pEvent, fCurrentDistance)) // jeśli nie ma
{ {
TableAddNew(); // zawsze jest true TableAddNew(); // zawsze jest true
@@ -2989,6 +2993,7 @@ bool TController::IncSpeed()
// if it generates enough traction force // if it generates enough traction force
// to build up speed to 30/40 km/h for passenger/cargo train (10 km/h less if going uphill) // to build up speed to 30/40 km/h for passenger/cargo train (10 km/h less if going uphill)
auto const sufficienttractionforce { std::abs( mvControlling->Ft ) > ( IsHeavyCargoTrain ? 125 : 100 ) * 1000.0 }; auto const sufficienttractionforce { std::abs( mvControlling->Ft ) > ( IsHeavyCargoTrain ? 125 : 100 ) * 1000.0 };
auto const sufficientacceleration { AbsAccS_pub >= ( IsHeavyCargoTrain ? 0.02 : 0.04 ) };
auto const seriesmodefieldshunting { ( mvControlling->ScndCtrlPos > 0 ) && ( mvControlling->RList[ mvControlling->MainCtrlPos ].Bn == 1 ) }; auto const seriesmodefieldshunting { ( mvControlling->ScndCtrlPos > 0 ) && ( mvControlling->RList[ mvControlling->MainCtrlPos ].Bn == 1 ) };
auto const parallelmodefieldshunting { ( mvControlling->ScndCtrlPos > 0 ) && ( mvControlling->RList[ mvControlling->MainCtrlPos ].Bn > 1 ) }; auto const parallelmodefieldshunting { ( mvControlling->ScndCtrlPos > 0 ) && ( mvControlling->RList[ mvControlling->MainCtrlPos ].Bn > 1 ) };
auto const useseriesmodevoltage { auto const useseriesmodevoltage {
@@ -3000,6 +3005,7 @@ bool TController::IncSpeed()
( mvControlling->Imax > mvControlling->ImaxLo ) ( mvControlling->Imax > mvControlling->ImaxLo )
|| ( fVoltage < useseriesmodevoltage ) || ( fVoltage < useseriesmodevoltage )
|| ( ( true == sufficienttractionforce ) || ( ( true == sufficienttractionforce )
&& ( true == sufficientacceleration )
&& ( mvOccupied->Vel <= ( IsCargoTrain ? 35 : 25 ) + ( seriesmodefieldshunting ? 5 : 0 ) - ( ( fAccGravity < -0.025 ) ? 10 : 0 ) ) ) ); && ( mvOccupied->Vel <= ( IsCargoTrain ? 35 : 25 ) + ( seriesmodefieldshunting ? 5 : 0 ) - ( ( fAccGravity < -0.025 ) ? 10 : 0 ) ) ) );
// when not in series mode use the first available parallel mode configuration until 50/60 km/h for passenger/cargo train // when not in series mode use the first available parallel mode configuration until 50/60 km/h for passenger/cargo train
// (if there's only one parallel mode configuration it'll be used regardless of current speed) // (if there's only one parallel mode configuration it'll be used regardless of current speed)
@@ -3009,6 +3015,7 @@ bool TController::IncSpeed()
&& ( useseriesmode ? && ( useseriesmode ?
mvControlling->RList[ mvControlling->MainCtrlPos ].Bn == 1 : mvControlling->RList[ mvControlling->MainCtrlPos ].Bn == 1 :
( ( true == sufficienttractionforce ) ( ( true == sufficienttractionforce )
&& ( true == sufficientacceleration )
&& ( mvOccupied->Vel <= ( IsCargoTrain ? 55 : 45 ) + ( parallelmodefieldshunting ? 5 : 0 ) ) ? && ( mvOccupied->Vel <= ( IsCargoTrain ? 55 : 45 ) + ( parallelmodefieldshunting ? 5 : 0 ) ) ?
mvControlling->RList[ mvControlling->MainCtrlPos ].Bn > 1 : mvControlling->RList[ mvControlling->MainCtrlPos ].Bn > 1 :
mvControlling->MainCtrlPos == mvControlling->MainCtrlPosNo ) ) ); mvControlling->MainCtrlPos == mvControlling->MainCtrlPosNo ) ) );
@@ -6630,14 +6637,16 @@ void TController::DirectionForward(bool forward)
// do przodu w obecnej kabinie // do przodu w obecnej kabinie
while( ( mvOccupied->ActiveDir <= 0 ) while( ( mvOccupied->ActiveDir <= 0 )
&& ( mvOccupied->DirectionForward() ) ) { && ( mvOccupied->DirectionForward() ) ) {
; // all work is done in the header // force scan table update
iTableDirection = 0;
} }
} }
else { else {
// do tyłu w obecnej kabinie // do tyłu w obecnej kabinie
while( ( mvOccupied->ActiveDir >= 0 ) while( ( mvOccupied->ActiveDir >= 0 )
&& ( mvOccupied->DirectionBackward() ) ) { && ( mvOccupied->DirectionBackward() ) ) {
; // all work is done in the header // force scan table update
iTableDirection = 0;
} }
} }
if( mvOccupied->TrainType == dt_SN61 ) { if( mvOccupied->TrainType == dt_SN61 ) {

View File

@@ -363,7 +363,7 @@ private:
// Ra: metody obsługujące skanowanie toru // Ra: metody obsługujące skanowanie toru
std::vector<basic_event *> CheckTrackEvent( TTrack *Track, double const fDirection ) const; std::vector<basic_event *> CheckTrackEvent( TTrack *Track, double const fDirection ) const;
bool TableAddNew(); bool TableAddNew();
bool TableNotFound( basic_event const *Event ) const; bool TableNotFound( basic_event const *Event, double const Distance ) const;
void TableTraceRoute( double fDistance, TDynamicObject *pVehicle ); void TableTraceRoute( double fDistance, TDynamicObject *pVehicle );
void TableCheck( double fDistance ); void TableCheck( double fDistance );
TCommandType TableUpdate( double &fVelDes, double &fDist, double &fNext, double &fAcc ); TCommandType TableUpdate( double &fVelDes, double &fDist, double &fNext, double &fAcc );

View File

@@ -2319,7 +2319,9 @@ void TDynamicObject::AttachPrev(TDynamicObject *Object, int iType)
{ // Ra: doczepia Object na końcu składu (nazwa funkcji może być myląca) { // Ra: doczepia Object na końcu składu (nazwa funkcji może być myląca)
// Ra: używane tylko przy wczytywaniu scenerii // Ra: używane tylko przy wczytywaniu scenerii
MoverParameters->Attach( iDirection, Object->iDirection ^ 1, Object->MoverParameters, iType, true, false ); MoverParameters->Attach( iDirection, Object->iDirection ^ 1, Object->MoverParameters, iType, true, false );
// update neighbour data for both affected vehicles
update_neighbours(); update_neighbours();
Object->update_neighbours();
} }
bool TDynamicObject::UpdateForce(double dt) bool TDynamicObject::UpdateForce(double dt)
@@ -4343,10 +4345,6 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
m_materialdata.textures_alpha |= 0x08080008; m_materialdata.textures_alpha |= 0x08080008;
} }
} }
if( false == MoverParameters->LoadAttributes.empty() ) {
// Ra: tu wczytywanie modelu ładunku jest w porządku
mdLoad = LoadMMediaFile_mdload( MoverParameters->LoadType.name );
}
Global.asCurrentTexturePath = szTexturePath; // z powrotem defaultowa sciezka do tekstur Global.asCurrentTexturePath = szTexturePath; // z powrotem defaultowa sciezka do tekstur
do { do {
token = ""; token = "";
@@ -4927,6 +4925,11 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
} while( ( token != "" ) } while( ( token != "" )
&& ( token != "endmodels" ) ); && ( token != "endmodels" ) );
if( false == MoverParameters->LoadAttributes.empty() ) {
// Ra: tu wczytywanie modelu ładunku jest w porządku
mdLoad = LoadMMediaFile_mdload( MoverParameters->LoadType.name );
}
} // models } // models
else if( token == "sounds:" ) { else if( token == "sounds:" ) {

View File

@@ -127,7 +127,13 @@ global_settings::ConfigParse(cParser &Parser) {
// selected device for audio renderer // selected device for audio renderer
Parser.getTokens(); Parser.getTokens();
Parser >> AudioVolume; Parser >> AudioVolume;
AudioVolume = clamp( AudioVolume, 0.0f, 2.f ); AudioVolume = clamp( AudioVolume, 0.f, 2.f );
}
else if( token == "sound.volume.radio" ) {
// selected device for audio renderer
Parser.getTokens();
Parser >> RadioVolume;
RadioVolume = clamp( RadioVolume, 0.f, 1.f );
} }
// else if (str==AnsiString("renderalpha")) //McZapkie-1312302 - dwuprzebiegowe renderowanie // else if (str==AnsiString("renderalpha")) //McZapkie-1312302 - dwuprzebiegowe renderowanie
// bRenderAlpha=(GetNextSymbol().LowerCase()==AnsiString("yes")); // bRenderAlpha=(GetNextSymbol().LowerCase()==AnsiString("yes"));

View File

@@ -133,7 +133,8 @@ struct global_settings {
double fFpsMax{ 65.0 }; // górna granica FPS, przy której promień scenerii będzie zwiększany double fFpsMax{ 65.0 }; // górna granica FPS, przy której promień scenerii będzie zwiększany
// audio // audio
bool bSoundEnabled{ true }; bool bSoundEnabled{ true };
float AudioVolume{ 1.25f }; float AudioVolume{ 1.f };
float RadioVolume{ 0.75f };
std::string AudioRenderer; std::string AudioRenderer;
// input // input
float fMouseXScale{ 1.5f }; float fMouseXScale{ 1.5f };

View File

@@ -3891,7 +3891,18 @@ void TMoverParameters::ComputeConstans(void)
} }
Ff = TotalMassxg * (BearingF + RollF * V * V / 10.0) / 1000.0; Ff = TotalMassxg * (BearingF + RollF * V * V / 10.0) / 1000.0;
// dorobic liczenie temperatury lozyska! // dorobic liczenie temperatury lozyska!
FrictConst1 = ((TotalMassxg * RollF) / 10000.0) + (Cx * Dim.W * Dim.H); FrictConst1 = ( TotalMassxg * RollF ) / 10000.0;
// drag calculation
{
// NOTE: draft effect of previous vehicle is simplified and doesn't have much to do with reality
auto const *previousvehicle { Couplers[ ( V >= 0.0 ? end::front : end::rear ) ].Connected };
auto dragarea { Dim.W * Dim.H };
if( previousvehicle ) {
dragarea = std::max( 0.0, dragarea - ( 0.85 * previousvehicle->Dim.W * previousvehicle->Dim.H ) );
}
FrictConst1 += Cx * dragarea;
}
Curvature = abs(RunningShape.R); // zero oznacza nieskończony promień Curvature = abs(RunningShape.R); // zero oznacza nieskończony promień
if (Curvature > 0.0) if (Curvature > 0.0)
Curvature = 1.0 / Curvature; Curvature = 1.0 / Curvature;
@@ -4406,7 +4417,7 @@ double TMoverParameters::TractionForce( double dt ) {
if( enrot != tmp ) { if( enrot != tmp ) {
enrot = clamp( enrot = clamp(
enrot + ( dt / 1.25 ) * ( // TODO: equivalent of dizel_aim instead of fixed inertia enrot + ( dt / dizel_AIM ) * (
enrot < tmp ? enrot < tmp ?
1.0 : 1.0 :
-2.0 ), // NOTE: revolutions drop faster than they rise, maybe? TBD: maybe not -2.0 ), // NOTE: revolutions drop faster than they rise, maybe? TBD: maybe not
@@ -6080,7 +6091,11 @@ void TMoverParameters::CheckEIMIC(double dt)
eimic += clamp(UniCtrlList[MainCtrlPos].SetCtrlVal - eimic, 0.0, dt * UniCtrlList[MainCtrlPos].SpeedUp); //dodawaj do X eimic += clamp(UniCtrlList[MainCtrlPos].SetCtrlVal - eimic, 0.0, dt * UniCtrlList[MainCtrlPos].SpeedUp); //dodawaj do X
eimic = clamp(eimic, UniCtrlList[MainCtrlPos].MinCtrlVal, UniCtrlList[MainCtrlPos].MaxCtrlVal); eimic = clamp(eimic, UniCtrlList[MainCtrlPos].MinCtrlVal, UniCtrlList[MainCtrlPos].MaxCtrlVal);
} }
eimic = clamp(eimic, -1.0, Mains ? 1.0 : 0.0); auto const eimicpowerenabled {
( ( true == Mains ) || ( Power == 0.0 ) )
&& ( ( Doors.instances[ side::left ].open_permit == false )
&& ( Doors.instances[ side::right ].open_permit == false ) ) };
eimic = clamp(eimic, -1.0, eimicpowerenabled ? 1.0 : 0.0);
} }
void TMoverParameters::CheckSpeedCtrl() void TMoverParameters::CheckSpeedCtrl()
@@ -8945,6 +8960,7 @@ void TMoverParameters::LoadFIZ_Engine( std::string const &Input ) {
ImaxLo = 1; ImaxLo = 1;
} }
extract_value( EngineHeatingRPM, "HeatingRPM", Input, "" ); extract_value( EngineHeatingRPM, "HeatingRPM", Input, "" );
extract_value( dizel_AIM, "AIM", Input, "1.25" );
break; break;
} }
case TEngineType::ElectricInductionMotor: { case TEngineType::ElectricInductionMotor: {

View File

@@ -5221,7 +5221,7 @@ bool TTrain::Update( double const Deltatime )
} }
bool kier = (DynamicObject->DirectionGet() * mvOccupied->ActiveCab > 0); bool kier = (DynamicObject->DirectionGet() * mvOccupied->ActiveCab > 0);
TDynamicObject *p = DynamicObject->GetFirstDynamic(mvOccupied->ActiveCab < 0 ? 1 : 0, 4); TDynamicObject *p = DynamicObject->GetFirstDynamic(mvOccupied->ActiveCab < 0 ? end::rear : end::front, 4);
int in = 0; int in = 0;
fEIMParams[0][6] = 0; fEIMParams[0][6] = 0;
iCarNo = 0; iCarNo = 0;
@@ -6537,7 +6537,7 @@ void TTrain::update_sounds_radio() {
auto const volume { auto const volume {
( true == radioenabled ) ( true == radioenabled )
&& ( message.first == iRadioChannel ) ? && ( message.first == iRadioChannel ) ?
1.0 : Global.RadioVolume :
0.0 }; 0.0 };
message.second->gain( volume ); message.second->gain( volume );
} }

View File

@@ -178,7 +178,7 @@ state_serializer::deserialize_atmo( cParser &Input, scene::scratch_data &Scratch
Global.fFogEnd = Global.fFogEnd =
clamp( clamp(
Random( fograngestart, fograngeend ), Random( std::min( fograngestart, fograngeend ), std::max( fograngestart, fograngeend ) ),
100.0, 2000.0 ); 100.0, 2000.0 );
} }

View File

@@ -1,5 +1,5 @@
#pragma once #pragma once
#define VERSION_MAJOR 19 #define VERSION_MAJOR 19
#define VERSION_MINOR 406 #define VERSION_MINOR 419
#define VERSION_REVISION 0 #define VERSION_REVISION 0