mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
build 200914. articulated coupler parameters change, driver aid logic tweak, sound overrides support, combined rain sound support
This commit is contained in:
31
Driver.cpp
31
Driver.cpp
@@ -976,6 +976,18 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
|
||||
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 = (
|
||||
( sSpeedTable[ i ].fDist <= passengerstopmaxdistance )
|
||||
// Ra 2F1I: odległość plus długość pociągu musi być mniejsza od długości
|
||||
@@ -1234,8 +1246,8 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
|
||||
}
|
||||
}
|
||||
if( ( SemNextStopIndex == -1 )
|
||||
|| ( ( sSpeedTable[ SemNextStopIndex ].fVelNext != 0 )
|
||||
&& ( sSpeedTable[ i ].fVelNext == 0 ) ) ) {
|
||||
|| ( ( sSpeedTable[ SemNextStopIndex ].fVelNext != 0 )
|
||||
&& ( sSpeedTable[ i ].fVelNext == 0 ) ) ) {
|
||||
SemNextStopIndex = i;
|
||||
}
|
||||
}
|
||||
@@ -1296,8 +1308,19 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
|
||||
}
|
||||
else if (sSpeedTable[i].IsProperSemaphor(OrderCurrentGet()))
|
||||
{ // to semaphor
|
||||
if (sSpeedTable[i].fDist < 0)
|
||||
VelSignalLast = sSpeedTable[i].fVelNext; //minięty daje prędkość obowiązującą
|
||||
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ą
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
iDrivigFlags |= moveSemaphorFound; //jeśli z przodu to dajemy falgę, że jest
|
||||
|
||||
@@ -18,6 +18,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include "simulation.h"
|
||||
#include "simulationtime.h"
|
||||
#include "simulationsounds.h"
|
||||
#include "messaging.h"
|
||||
#include "Globals.h"
|
||||
#include "MemCell.h"
|
||||
|
||||
@@ -9904,7 +9904,7 @@ void TMoverParameters::LoadFIZ_BuffCoupl( std::string const &line, int const Ind
|
||||
coupler->beta = 0.3;
|
||||
}
|
||||
else if( coupler->CouplerType == TCouplerType::Articulated ) {
|
||||
|
||||
/*
|
||||
coupler->SpringKC = 60.0 * Mass + 1000;
|
||||
coupler->DmaxC = 0.05;
|
||||
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->FmaxB = 4000000.0 + 2.0 * Ftmax;
|
||||
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 ) {
|
||||
|
||||
@@ -15,6 +15,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include "Globals.h"
|
||||
#include "simulation.h"
|
||||
#include "simulationsounds.h"
|
||||
#include "Train.h"
|
||||
#include "dictionary.h"
|
||||
#include "sceneeditor.h"
|
||||
@@ -868,6 +869,7 @@ eu07_application::init_data() {
|
||||
weightpair.first.erase( weightpair.first.end() - 1 ); // trim trailing ':' from the key
|
||||
simulation::Weights.emplace( weightpair.first, weightpair.second );
|
||||
}
|
||||
deserialize_map( simulation::Sound_overrides, cParser( "data/sound_overrides.txt", cParser::buffer_FILE ) );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -309,6 +309,7 @@
|
||||
<ClCompile Include="scenarioloadermode.cpp" />
|
||||
<ClCompile Include="scenenodegroups.cpp" />
|
||||
<ClCompile Include="simulationenvironment.cpp" />
|
||||
<ClCompile Include="simulationsounds.cpp" />
|
||||
<ClCompile Include="simulationstateserializer.cpp" />
|
||||
<ClCompile Include="scene.cpp" />
|
||||
<ClCompile Include="sceneeditor.cpp" />
|
||||
@@ -444,6 +445,7 @@
|
||||
<ClInclude Include="scenarioloaderuilayer.h" />
|
||||
<ClInclude Include="scenenodegroups.h" />
|
||||
<ClInclude Include="simulationenvironment.h" />
|
||||
<ClInclude Include="simulationsounds.h" />
|
||||
<ClInclude Include="simulationstateserializer.h" />
|
||||
<ClInclude Include="scene.h" />
|
||||
<ClInclude Include="sceneeditor.h" />
|
||||
|
||||
@@ -468,6 +468,9 @@
|
||||
<ClCompile Include="ladderlogic.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="simulationsounds.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Globals.h">
|
||||
@@ -857,6 +860,9 @@
|
||||
<ClInclude Include="ladderlogic.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="simulationsounds.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="maszyna.rc">
|
||||
|
||||
@@ -36,7 +36,6 @@ memory_table Memory;
|
||||
path_table Paths;
|
||||
traction_table Traction;
|
||||
powergridsource_table Powergrid;
|
||||
sound_table Sounds;
|
||||
instance_table Instances;
|
||||
vehicle_table Vehicles;
|
||||
train_table Trains;
|
||||
|
||||
@@ -69,7 +69,6 @@ extern memory_table Memory;
|
||||
extern path_table Paths;
|
||||
extern traction_table Traction;
|
||||
extern powergridsource_table Powergrid;
|
||||
extern sound_table Sounds;
|
||||
extern instance_table Instances;
|
||||
extern vehicle_table Vehicles;
|
||||
extern train_table Trains;
|
||||
|
||||
@@ -10,6 +10,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "stdafx.h"
|
||||
#include "simulationenvironment.h"
|
||||
|
||||
#include "simulationsounds.h"
|
||||
#include "Globals.h"
|
||||
#include "Timer.h"
|
||||
|
||||
@@ -78,7 +79,14 @@ world_environment::init() {
|
||||
m_stars.init();
|
||||
m_clouds.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{
|
||||
static_cast<float>( Random( 0, 360 ) ),
|
||||
static_cast<float>( Random( -5, 5 ) ),
|
||||
@@ -181,10 +189,13 @@ world_environment::update() {
|
||||
|
||||
if( ( true == ( FreeFlyModeFlag || Global.CabWindowOpen ) )
|
||||
&& ( 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 {
|
||||
m_precipitationsound.stop();
|
||||
m_rainsound.stop();
|
||||
}
|
||||
|
||||
update_wind();
|
||||
|
||||
@@ -83,7 +83,7 @@ private:
|
||||
float m_lightintensity { 1.f };
|
||||
TSky m_clouds;
|
||||
basic_precipitation m_precipitation;
|
||||
sound_source m_precipitationsound { sound_placement::external, -1 };
|
||||
sound_source m_rainsound { sound_placement::external, -1 };
|
||||
basic_wind m_wind;
|
||||
};
|
||||
|
||||
|
||||
22
simulationsounds.cpp
Normal file
22
simulationsounds.cpp
Normal 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
23
simulationsounds.h
Normal 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
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -15,6 +15,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "Globals.h"
|
||||
#include "simulation.h"
|
||||
#include "simulationtime.h"
|
||||
#include "simulationsounds.h"
|
||||
#include "simulationenvironment.h"
|
||||
#include "scenenodegroups.h"
|
||||
#include "particles.h"
|
||||
|
||||
13
utilities.h
13
utilities.h
@@ -353,6 +353,19 @@ deserialize_random_set( cParser &Input, char const *Break = "\n\r\t ;" );
|
||||
|
||||
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 {
|
||||
|
||||
// simple POD pairing of a data item and a mutex
|
||||
|
||||
Reference in New Issue
Block a user