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

build 200914. articulated coupler parameters change, driver aid logic tweak, sound overrides support, combined rain sound support

This commit is contained in:
tmj-fstate
2020-09-20 17:22:04 +02:00
parent ac1253826f
commit 4da87e98d9
15 changed files with 122 additions and 12 deletions

View File

@@ -976,6 +976,18 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
sSpeedTable[i].iFlags = 0; sSpeedTable[i].iFlags = 0;
} }
} }
// for human-driven vehicles discard the stop point if they leave it far enough behind
if( ( false == AIControllFlag )
&& ( sSpeedTable[ i ].fDist < -1 * std::max( fLength + 100, 250.0 ) ) ) {
sSpeedTable[ i ].iFlags = 0; // nie liczy się już zupełnie (nie wyśle SetVelocity)
sSpeedTable[ i ].fVelNext = -1; // można jechać za W4
if( ( sSpeedTable[ i ].fDist <= 0.0 ) && ( eSignNext == sSpeedTable[ i ].evEvent ) ) {
// sanity check, if we're held by this stop point, let us go
VelSignalLast = -1;
}
continue;
}
IsAtPassengerStop = ( IsAtPassengerStop = (
( sSpeedTable[ i ].fDist <= passengerstopmaxdistance ) ( sSpeedTable[ i ].fDist <= passengerstopmaxdistance )
// Ra 2F1I: odległość plus długość pociągu musi być mniejsza od długości // Ra 2F1I: odległość plus długość pociągu musi być mniejsza od długości
@@ -1296,8 +1308,19 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
} }
else if (sSpeedTable[i].IsProperSemaphor(OrderCurrentGet())) else if (sSpeedTable[i].IsProperSemaphor(OrderCurrentGet()))
{ // to semaphor { // to semaphor
if (sSpeedTable[i].fDist < 0) if( sSpeedTable[ i ].fDist < 0 ) {
if( ( false == AIControllFlag )
&& ( sSpeedTable[ i ].fDist < -1 * std::max( fLength + 100, 250.0 ) ) ) {
// for human-driven vehicles ignore the signal if it was passed by sufficient distance
sSpeedTable[ i ].iFlags &= ~spEnabled;
VelSignal = -1.0;
continue;
}
else {
// for ai-driven vehicles always play by the rules
VelSignalLast = sSpeedTable[ i ].fVelNext; //minięty daje prędkość obowiązującą VelSignalLast = sSpeedTable[ i ].fVelNext; //minięty daje prędkość obowiązującą
}
}
else else
{ {
iDrivigFlags |= moveSemaphorFound; //jeśli z przodu to dajemy falgę, że jest iDrivigFlags |= moveSemaphorFound; //jeśli z przodu to dajemy falgę, że jest

View File

@@ -18,6 +18,7 @@ http://mozilla.org/MPL/2.0/.
#include "simulation.h" #include "simulation.h"
#include "simulationtime.h" #include "simulationtime.h"
#include "simulationsounds.h"
#include "messaging.h" #include "messaging.h"
#include "Globals.h" #include "Globals.h"
#include "MemCell.h" #include "MemCell.h"

View File

@@ -9904,7 +9904,7 @@ void TMoverParameters::LoadFIZ_BuffCoupl( std::string const &line, int const Ind
coupler->beta = 0.3; coupler->beta = 0.3;
} }
else if( coupler->CouplerType == TCouplerType::Articulated ) { else if( coupler->CouplerType == TCouplerType::Articulated ) {
/*
coupler->SpringKC = 60.0 * Mass + 1000; coupler->SpringKC = 60.0 * Mass + 1000;
coupler->DmaxC = 0.05; coupler->DmaxC = 0.05;
coupler->FmaxC = 20000000.0 + 2.0 * Ftmax; coupler->FmaxC = 20000000.0 + 2.0 * Ftmax;
@@ -9912,6 +9912,14 @@ void TMoverParameters::LoadFIZ_BuffCoupl( std::string const &line, int const Ind
coupler->DmaxB = 0.05; coupler->DmaxB = 0.05;
coupler->FmaxB = 4000000.0 + 2.0 * Ftmax; coupler->FmaxB = 4000000.0 + 2.0 * Ftmax;
coupler->beta = 0.55; coupler->beta = 0.55;
*/
coupler->SpringKC = 4500 * 1000;
coupler->DmaxC = 0.05;
coupler->FmaxC = 850 * 1000;
coupler->SpringKB = 9200 * 1000;
coupler->DmaxB = 0.05;
coupler->FmaxB = 320 * 1000;
coupler->beta = 0.55;
} }
if( Index == 0 ) { if( Index == 0 ) {

View File

@@ -15,6 +15,7 @@ http://mozilla.org/MPL/2.0/.
#include "Globals.h" #include "Globals.h"
#include "simulation.h" #include "simulation.h"
#include "simulationsounds.h"
#include "Train.h" #include "Train.h"
#include "dictionary.h" #include "dictionary.h"
#include "sceneeditor.h" #include "sceneeditor.h"
@@ -868,6 +869,7 @@ eu07_application::init_data() {
weightpair.first.erase( weightpair.first.end() - 1 ); // trim trailing ':' from the key weightpair.first.erase( weightpair.first.end() - 1 ); // trim trailing ':' from the key
simulation::Weights.emplace( weightpair.first, weightpair.second ); simulation::Weights.emplace( weightpair.first, weightpair.second );
} }
deserialize_map( simulation::Sound_overrides, cParser( "data/sound_overrides.txt", cParser::buffer_FILE ) );
return 0; return 0;
} }

View File

@@ -309,6 +309,7 @@
<ClCompile Include="scenarioloadermode.cpp" /> <ClCompile Include="scenarioloadermode.cpp" />
<ClCompile Include="scenenodegroups.cpp" /> <ClCompile Include="scenenodegroups.cpp" />
<ClCompile Include="simulationenvironment.cpp" /> <ClCompile Include="simulationenvironment.cpp" />
<ClCompile Include="simulationsounds.cpp" />
<ClCompile Include="simulationstateserializer.cpp" /> <ClCompile Include="simulationstateserializer.cpp" />
<ClCompile Include="scene.cpp" /> <ClCompile Include="scene.cpp" />
<ClCompile Include="sceneeditor.cpp" /> <ClCompile Include="sceneeditor.cpp" />
@@ -444,6 +445,7 @@
<ClInclude Include="scenarioloaderuilayer.h" /> <ClInclude Include="scenarioloaderuilayer.h" />
<ClInclude Include="scenenodegroups.h" /> <ClInclude Include="scenenodegroups.h" />
<ClInclude Include="simulationenvironment.h" /> <ClInclude Include="simulationenvironment.h" />
<ClInclude Include="simulationsounds.h" />
<ClInclude Include="simulationstateserializer.h" /> <ClInclude Include="simulationstateserializer.h" />
<ClInclude Include="scene.h" /> <ClInclude Include="scene.h" />
<ClInclude Include="sceneeditor.h" /> <ClInclude Include="sceneeditor.h" />

View File

@@ -468,6 +468,9 @@
<ClCompile Include="ladderlogic.cpp"> <ClCompile Include="ladderlogic.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="simulationsounds.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="Globals.h"> <ClInclude Include="Globals.h">
@@ -857,6 +860,9 @@
<ClInclude Include="ladderlogic.h"> <ClInclude Include="ladderlogic.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="simulationsounds.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="maszyna.rc"> <ResourceCompile Include="maszyna.rc">

View File

@@ -36,7 +36,6 @@ memory_table Memory;
path_table Paths; path_table Paths;
traction_table Traction; traction_table Traction;
powergridsource_table Powergrid; powergridsource_table Powergrid;
sound_table Sounds;
instance_table Instances; instance_table Instances;
vehicle_table Vehicles; vehicle_table Vehicles;
train_table Trains; train_table Trains;

View File

@@ -69,7 +69,6 @@ extern memory_table Memory;
extern path_table Paths; extern path_table Paths;
extern traction_table Traction; extern traction_table Traction;
extern powergridsource_table Powergrid; extern powergridsource_table Powergrid;
extern sound_table Sounds;
extern instance_table Instances; extern instance_table Instances;
extern vehicle_table Vehicles; extern vehicle_table Vehicles;
extern train_table Trains; extern train_table Trains;

View File

@@ -10,6 +10,7 @@ http://mozilla.org/MPL/2.0/.
#include "stdafx.h" #include "stdafx.h"
#include "simulationenvironment.h" #include "simulationenvironment.h"
#include "simulationsounds.h"
#include "Globals.h" #include "Globals.h"
#include "Timer.h" #include "Timer.h"
@@ -78,7 +79,14 @@ world_environment::init() {
m_stars.init(); m_stars.init();
m_clouds.Init(); m_clouds.Init();
m_precipitation.init(); m_precipitation.init();
m_precipitationsound.deserialize( "rain-sound-loop", sound_type::single ); {
auto const rainsoundoverride { simulation::Sound_overrides.find( "weather.rainsound:" ) };
m_rainsound.deserialize(
( rainsoundoverride != simulation::Sound_overrides.end() ?
rainsoundoverride->second :
"rain-sound-loop" ),
sound_type::single );
}
m_wind = basic_wind{ m_wind = basic_wind{
static_cast<float>( Random( 0, 360 ) ), static_cast<float>( Random( 0, 360 ) ),
static_cast<float>( Random( -5, 5 ) ), static_cast<float>( Random( -5, 5 ) ),
@@ -181,10 +189,13 @@ world_environment::update() {
if( ( true == ( FreeFlyModeFlag || Global.CabWindowOpen ) ) if( ( true == ( FreeFlyModeFlag || Global.CabWindowOpen ) )
&& ( Global.Weather == "rain:" ) ) { && ( Global.Weather == "rain:" ) ) {
m_precipitationsound.play( sound_flags::exclusive | sound_flags::looping ); if( m_rainsound.is_combined() ) {
m_rainsound.pitch( Global.Overcast - 1.0 );
}
m_rainsound.play( sound_flags::exclusive | sound_flags::looping );
} }
else { else {
m_precipitationsound.stop(); m_rainsound.stop();
} }
update_wind(); update_wind();

View File

@@ -83,7 +83,7 @@ private:
float m_lightintensity { 1.f }; float m_lightintensity { 1.f };
TSky m_clouds; TSky m_clouds;
basic_precipitation m_precipitation; basic_precipitation m_precipitation;
sound_source m_precipitationsound { sound_placement::external, -1 }; sound_source m_rainsound { sound_placement::external, -1 };
basic_wind m_wind; basic_wind m_wind;
}; };

22
simulationsounds.cpp Normal file
View File

@@ -0,0 +1,22 @@
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#include "stdafx.h"
#include "simulationsounds.h"
#include "utilities.h"
namespace simulation {
sound_overridemap Sound_overrides;
sound_table Sounds;
} // simulation
//---------------------------------------------------------------------------

23
simulationsounds.h Normal file
View File

@@ -0,0 +1,23 @@
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "sound.h"
namespace simulation {
using sound_overridemap = std::unordered_map<std::string, std::string>;
extern sound_overridemap Sound_overrides;
extern sound_table Sounds;
} // simulation
//---------------------------------------------------------------------------

View File

@@ -15,6 +15,7 @@ http://mozilla.org/MPL/2.0/.
#include "Globals.h" #include "Globals.h"
#include "simulation.h" #include "simulation.h"
#include "simulationtime.h" #include "simulationtime.h"
#include "simulationsounds.h"
#include "simulationenvironment.h" #include "simulationenvironment.h"
#include "scenenodegroups.h" #include "scenenodegroups.h"
#include "particles.h" #include "particles.h"

View File

@@ -353,6 +353,19 @@ deserialize_random_set( cParser &Input, char const *Break = "\n\r\t ;" );
int count_trailing_zeros( uint32_t val ); int count_trailing_zeros( uint32_t val );
// extracts a group of <key, value> pairs from provided data stream
// NOTE: expects no more than single pair per line
template <typename MapType_>
void
deserialize_map( MapType_ &Map, cParser &Input ) {
while( Input.ok() && !Input.eof() ) {
auto const key { Input.getToken<typename MapType_::key_type>( false ) };
auto const value { Input.getToken<typename MapType_::mapped_type>( false, "\n" ) };
Map.emplace( key, value );
}
}
namespace threading { namespace threading {
// simple POD pairing of a data item and a mutex // simple POD pairing of a data item and a mutex

View File

@@ -1,5 +1,5 @@
#pragma once #pragma once
#define VERSION_MAJOR 20 #define VERSION_MAJOR 20
#define VERSION_MINOR 913 #define VERSION_MINOR 914
#define VERSION_REVISION 0 #define VERSION_REVISION 0