mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-23 08:39:18 +02:00
build 210330. minor bug fixes
This commit is contained in:
75
Driver.cpp
75
Driver.cpp
@@ -2064,10 +2064,6 @@ void TController::Activation()
|
||||
}
|
||||
if (pVehicle != initialvehicle)
|
||||
{ // jeśli zmieniony został pojazd prowadzony
|
||||
auto *train { simulation::Trains.find( initialvehicle->name() ) };
|
||||
if( train ) {
|
||||
train->MoveToVehicle( pVehicle );
|
||||
}
|
||||
ControllingSet(); // utworzenie połączenia do sterowanego pojazdu (może się zmienić) - silnikowy dla EZT
|
||||
if( ( mvOccupied->BrakeCtrlPosNo > 0 )
|
||||
&& ( ( mvOccupied->BrakeSystem == TBrakeSystem::Pneumatic )
|
||||
@@ -2089,13 +2085,20 @@ void TController::Activation()
|
||||
mvOccupied->CabOccupied = iDirection; // aktywacja kabiny w prowadzonym pojeżdzie (silnikowy może być odwrotnie?)
|
||||
mvOccupied->CabActivisation(); // uruchomienie kabin w członach
|
||||
DirectionForward(true); // nawrotnik do przodu
|
||||
mvOccupied->SpringBrakeActivate( initialspringbrakestate );
|
||||
/*
|
||||
// NOTE: this won't restore local brake if the vehicle has integrated local brake control
|
||||
// TBD, TODO: fix or let the ai activate the brake again as part of its standard logic?
|
||||
if (initiallocalbrakelevel > 0.0) // hamowanie tylko jeśli był wcześniej zahamowany (bo możliwe, że jedzie!)
|
||||
mvOccupied->LocalBrakePosA = initiallocalbrakelevel; // zahamuj jak wcześniej
|
||||
*/
|
||||
mvOccupied->SpringBrakeActivate( initialspringbrakestate );
|
||||
if( pVehicle != initialvehicle ) {
|
||||
auto *train { simulation::Trains.find( initialvehicle->name() ) };
|
||||
if( train ) {
|
||||
train->MoveToVehicle( pVehicle );
|
||||
}
|
||||
}
|
||||
|
||||
CheckVehicles(); // sprawdzenie składu, AI zapali światła
|
||||
TableClear(); // resetowanie tabelki skanowania torów
|
||||
}
|
||||
@@ -6745,10 +6748,42 @@ TController::UpdateConnect() {
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
TController::unit_count( int const Threshold ) const {
|
||||
|
||||
auto *vehicle { pVehicle };
|
||||
auto unitcount { 1 };
|
||||
do {
|
||||
auto const decoupledend{ ( vehicle->DirectionGet() > 0 ? // numer sprzęgu od strony czoła składu
|
||||
end::rear :
|
||||
end::front ) };
|
||||
auto const coupling { vehicle->MoverParameters->Couplers[ decoupledend ].CouplingFlag };
|
||||
if( coupling == coupling::faux ) {
|
||||
break;
|
||||
}
|
||||
// jeżeli sprzęg zablokowany to liczymy człony jako jeden
|
||||
if( ( coupling & coupling::permanent ) == 0 ) {
|
||||
++unitcount;
|
||||
}
|
||||
vehicle = vehicle->Next();
|
||||
} while( unitcount < Threshold );
|
||||
|
||||
return unitcount;
|
||||
}
|
||||
|
||||
void
|
||||
TController::UpdateDisconnect() {
|
||||
|
||||
if( iVehicleCount >= 0 ) {
|
||||
// early test for human drivers, who might disregard the proper procedure, or perform it before they receive the order to
|
||||
if( false == AIControllFlag ) {
|
||||
// iVehicleCount = 0 means the consist should be reduced to (1) leading unit, thus we increase our test values by 1
|
||||
if( unit_count( iVehicleCount + 2 ) <= iVehicleCount + 1 ) {
|
||||
iVehicleCount = -2; // odczepiono, co było do odczepienia
|
||||
return; // we'll wrap up the procedure on the next update beat
|
||||
}
|
||||
}
|
||||
// regular uncoupling procedure, performed by ai and naively expected from the human drivers
|
||||
// 3rd stage: change direction, compress buffers and uncouple
|
||||
if( iDirection != iDirectionOrder ) {
|
||||
cue_action( locale::string::driver_hint_mastercontrollersetreverserunlock );
|
||||
@@ -6814,6 +6849,10 @@ TController::UpdateDisconnect() {
|
||||
}
|
||||
// 2nd stage: apply consist brakes and change direction
|
||||
if( ( iDrivigFlags & movePress ) == 0 ) {
|
||||
// store initial consist direction
|
||||
if( !iDirectionBackup ) {
|
||||
iDirectionBackup = iDirection;
|
||||
}
|
||||
if( false == IsConsistBraked ) {
|
||||
WriteLog( "Uncoupling [" + mvOccupied->Name + "]: applying consist brakes..." );
|
||||
cue_action( locale::string::driver_hint_trainbrakeapply );
|
||||
@@ -6834,19 +6873,23 @@ TController::UpdateDisconnect() {
|
||||
} // odczepianie
|
||||
if( iVehicleCount < 0 ) {
|
||||
// 4th stage: restore initial direction
|
||||
if( ( iDrivigFlags & movePress ) != 0 ) {
|
||||
if( eStopReason == stopNone ) { // HACK: use current speed limit to discern whether we're entering this stage for the first time
|
||||
WriteLog( "Uncoupling [" + mvOccupied->Name + "]: second direction change" );
|
||||
iDirectionOrder = -iDirection;
|
||||
cue_action( locale::string::driver_hint_mastercontrollersetreverserunlock );
|
||||
cue_action( locale::string::driver_hint_directionother ); // zmiana kierunku jazdy na właściwy
|
||||
}
|
||||
if( iDirection == iDirectionOrder ) {
|
||||
iDrivigFlags &= ~movePress; // koniec dociskania
|
||||
if( iDirectionBackup ) {
|
||||
iDirectionOrder = iDirectionBackup.value();
|
||||
iDirectionBackup.reset();
|
||||
}
|
||||
if( iDirection != iDirectionOrder ) {
|
||||
WriteLog( "Uncoupling [" + mvOccupied->Name + "]: second direction change" );
|
||||
cue_action( locale::string::driver_hint_mastercontrollersetreverserunlock );
|
||||
cue_action( locale::string::driver_hint_directionother ); // zmiana kierunku jazdy na właściwy
|
||||
}
|
||||
// 5th stage: clean up and move on to next order
|
||||
if( iDirection == iDirectionOrder ) {
|
||||
iDrivigFlags &= ~movePress; // koniec dociskania
|
||||
while( ( OrderCurrentGet() & Disconnect ) != 0 ) {
|
||||
JumpToNextOrder(); // zmieni światła
|
||||
TableClear(); // skanowanie od nowa
|
||||
iDrivigFlags &= ~moveStartHorn; // bez trąbienia przed ruszeniem
|
||||
}
|
||||
TableClear(); // skanowanie od nowa
|
||||
iDrivigFlags &= ~moveStartHorn; // bez trąbienia przed ruszeniem
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
2
Driver.h
2
Driver.h
@@ -317,6 +317,7 @@ private:
|
||||
void check_departure();
|
||||
void UpdateConnect();
|
||||
void UpdateDisconnect();
|
||||
int unit_count( int const Threshold ) const;
|
||||
void UpdateChangeDirection();
|
||||
void UpdateLooseShunt();
|
||||
void UpdateObeyTrain();
|
||||
@@ -381,6 +382,7 @@ private:
|
||||
double SwitchClearDist { 0.0 }; // distance to point after farthest detected switch
|
||||
int iDirection = 0; // kierunek jazdy względem sprzęgów pojazdu, w którym siedzi AI (1=przód,-1=tył)
|
||||
int iDirectionOrder = 0; //żadany kierunek jazdy (służy do zmiany kierunku)
|
||||
std::optional<int> iDirectionBackup; // consist direction to be restored after coupling/uncoupling and similar direction-changing operations
|
||||
int iVehicleCount = -2; // wartość neutralna // ilość pojazdów do odłączenia albo zabrania ze składu (-1=wszystkie)
|
||||
int iCoupler = 0; // maska sprzęgu, jaką należy użyć przy łączeniu (po osiągnięciu trybu Connect), 0 gdy jazda bez łączenia
|
||||
int iDriverFailCount = 0; // licznik błędów AI
|
||||
|
||||
@@ -178,7 +178,7 @@ global_settings::ConfigParse(cParser &Parser) {
|
||||
// selected device for audio renderer
|
||||
Parser.getTokens();
|
||||
Parser >> PausedVolume;
|
||||
EnvironmentAmbientVolume = clamp( EnvironmentAmbientVolume, 0.f, 1.f );
|
||||
PausedVolume = clamp( PausedVolume, 0.f, 1.f );
|
||||
}
|
||||
// else if (str==AnsiString("renderalpha")) //McZapkie-1312302 - dwuprzebiegowe renderowanie
|
||||
// bRenderAlpha=(GetNextSymbol().LowerCase()==AnsiString("yes"));
|
||||
|
||||
@@ -235,6 +235,9 @@ struct global_settings {
|
||||
std::optional<std::pair<std::string, std::string>> network_client;
|
||||
double desync = 0.0;
|
||||
|
||||
float m_skysaturationcorrection{ 1.65f };
|
||||
float m_skyhuecorrection{ 0.5f };
|
||||
|
||||
// methods
|
||||
void LoadIniFile( std::string asFileName );
|
||||
void ConfigParse( cParser &parser );
|
||||
|
||||
25
Train.cpp
25
Train.cpp
@@ -1152,7 +1152,7 @@ void TTrain::OnCommand_tempomattoggle( TTrain *Train, command_data const &Comman
|
||||
|
||||
if( Command.action == GLFW_REPEAT ) { return; }
|
||||
|
||||
if( Train->ggScndCtrlButton.type() == TGaugeType::push ) {
|
||||
if( Train->ggScndCtrlButton.is_push() ) {
|
||||
// impulse switch
|
||||
if( Command.action == GLFW_RELEASE ) {
|
||||
// just move the button(s) back to default position
|
||||
@@ -2565,8 +2565,8 @@ void TTrain::change_pantograph_selection( int const Change ) {
|
||||
auto const preset { presets[ selection ] - '0' };
|
||||
auto const swapends { cab_to_end() != end::front };
|
||||
// check desired states for both pantographs; value: whether the pantograph should be raised
|
||||
auto const frontstate { preset & ( swapends ? 1 : 2 ) };
|
||||
auto const rearstate { preset & ( swapends ? 2 : 1 ) };
|
||||
auto const frontstate { preset & ( swapends ? 2 : 1 ) };
|
||||
auto const rearstate { preset & ( swapends ? 1 : 2 ) };
|
||||
// potentially adjust pantograph valves
|
||||
mvOccupied->OperatePantographValve( end::front, ( frontstate ? operation_t::enable : operation_t::disable ) );
|
||||
mvOccupied->OperatePantographValve( end::rear, ( rearstate ? operation_t::enable : operation_t::disable ) );
|
||||
@@ -7027,6 +7027,11 @@ bool TTrain::Update( double const Deltatime )
|
||||
dsbNastawnikBocz );
|
||||
ggScndCtrl.Update();
|
||||
}
|
||||
if( ggScndCtrlButton.is_toggle() ) {
|
||||
ggScndCtrlButton.UpdateValue(
|
||||
( ( mvControlled->ScndCtrlPos > 0 ) ? 1.f : 0.f ),
|
||||
dsbSwitch );
|
||||
}
|
||||
ggScndCtrlButton.Update( lowvoltagepower );
|
||||
ggScndCtrlOffButton.Update( lowvoltagepower );
|
||||
ggDistanceCounterButton.Update();
|
||||
@@ -8393,20 +8398,18 @@ TTrain::MoveToVehicle(TDynamicObject *target) {
|
||||
|
||||
if( Dynamic()->Mechanik ) {
|
||||
Dynamic()->Mechanik->MoveTo( target );
|
||||
}
|
||||
|
||||
DynamicSet(target);
|
||||
|
||||
Occupied()->LimPipePress = Occupied()->PipePress;
|
||||
Occupied()->CabActivisation( true ); // załączenie rozrządu (wirtualne kabiny)
|
||||
Dynamic()->MechInside = true;
|
||||
if( Dynamic()->Mechanik ) {
|
||||
Dynamic()->Controller = Dynamic()->Mechanik->AIControllFlag;
|
||||
Dynamic()->Mechanik->DirectionChange();
|
||||
}
|
||||
else {
|
||||
Dynamic()->Controller = Humandriver;
|
||||
}
|
||||
Dynamic()->MechInside = true;
|
||||
|
||||
DynamicSet(target);
|
||||
|
||||
Occupied()->LimPipePress = Occupied()->PipePress;
|
||||
Occupied()->CabActivisation( true ); // załączenie rozrządu (wirtualne kabiny)
|
||||
} else {
|
||||
Dynamic()->bDisplayCab = false;
|
||||
Dynamic()->ABuSetModelShake( {} );
|
||||
|
||||
@@ -1010,7 +1010,7 @@ TController::cue_action( locale::string const Action, float const Actionparamete
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
return ( ( mvOccupied->Doors.has_warning == false ) || ( mvOccupied->DepartureSignal == true ) || mvOccupied->Vel > 5.0 ); } );
|
||||
return ( ( mvOccupied->Doors.has_warning == false ) || ( mvOccupied->Doors.has_autowarning == true ) || ( mvOccupied->DepartureSignal == true ) || mvOccupied->Vel > 5.0 ); } );
|
||||
break;
|
||||
}
|
||||
case locale::string::driver_hint_departuresignaloff: {
|
||||
@@ -1021,7 +1021,7 @@ TController::cue_action( locale::string const Action, float const Actionparamete
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
return ( ( mvOccupied->Doors.has_warning == false ) || ( mvOccupied->DepartureSignal == false ) ); } );
|
||||
return ( ( mvOccupied->Doors.has_warning == false ) || ( mvOccupied->Doors.has_autowarning == true ) || ( mvOccupied->DepartureSignal == false ) ); } );
|
||||
break;
|
||||
}
|
||||
// consist doors
|
||||
|
||||
@@ -527,6 +527,9 @@ drivermouse_input::default_bindings() {
|
||||
{ "tempomat_sw:", {
|
||||
user_command::tempomattoggle,
|
||||
user_command::none } },
|
||||
{ "tempomatoff_sw:", {
|
||||
user_command::tempomattoggle,
|
||||
user_command::none } },
|
||||
{ "dirkey:", {
|
||||
user_command::reverserincrease,
|
||||
user_command::reverserdecrease } },
|
||||
|
||||
@@ -1420,6 +1420,17 @@ debug_panel::render_section_settings() {
|
||||
ImGui::PopStyleColor();
|
||||
// reflection fidelity
|
||||
ImGui::SliderInt( ( to_string( Global.reflectiontune.fidelity ) + "###reflectionfidelity" ).c_str(), &Global.reflectiontune.fidelity, 0, 2, "Reflection fidelity" );
|
||||
if( DebugModeFlag ) {
|
||||
// sky sliders
|
||||
{
|
||||
ImGui::SliderFloat(
|
||||
( to_string( Global.m_skysaturationcorrection, 2, 5 ) + "###skysaturation" ).c_str(), &Global.m_skysaturationcorrection, 0.0f, 3.0f, "Sky saturation" );
|
||||
}
|
||||
{
|
||||
ImGui::SliderFloat(
|
||||
( to_string( Global.m_skyhuecorrection, 2, 5 ) + "###skyhue" ).c_str(), &Global.m_skyhuecorrection, 0.0f, 1.0f, "Sky hue correction" );
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::PushStyleColor( ImGuiCol_Text, { Global.UITextColor.r, Global.UITextColor.g, Global.UITextColor.b, Global.UITextColor.a } );
|
||||
ImGui::TextUnformatted( "Sound" );
|
||||
|
||||
@@ -401,7 +401,12 @@ bool opengl33_renderer::init_viewport(viewport_config &vp)
|
||||
vp.main_texv = std::make_unique<opengl_texture>();
|
||||
vp.main_texv->alloc_rendertarget(Global.gfx_postfx_motionblur_format, GL_RG, vp.width, vp.height);
|
||||
vp.main_fb->attach(*vp.main_texv, GL_COLOR_ATTACHMENT1);
|
||||
vp.main_fb->setup_drawing(2);
|
||||
|
||||
vp.main_texd = std::make_unique<opengl_texture>();
|
||||
vp.main_texd->alloc_rendertarget( Global.gfx_format_depth, GL_DEPTH_COMPONENT, vp.width, vp.height, 1, 1, GL_CLAMP_TO_EDGE );
|
||||
vp.main_fb->attach( *vp.main_texd, GL_DEPTH_ATTACHMENT );
|
||||
|
||||
vp.main_fb->setup_drawing(1);
|
||||
|
||||
WriteLog("motion blur enabled");
|
||||
}
|
||||
@@ -782,15 +787,18 @@ void opengl33_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
|
||||
if (Global.gfx_postfx_motionblur_enabled)
|
||||
{
|
||||
gl::program::unbind();
|
||||
|
||||
vp.main_fb->clear(GL_COLOR_BUFFER_BIT);
|
||||
vp.msaa_fb->blit_to(vp.main_fb.get(), vp.width, vp.height, GL_COLOR_BUFFER_BIT, GL_COLOR_ATTACHMENT0);
|
||||
vp.msaa_fb->blit_to(vp.main_fb.get(), vp.width, vp.height, GL_COLOR_BUFFER_BIT, GL_COLOR_ATTACHMENT1);
|
||||
vp.msaa_fb->blit_to(vp.main_fb.get(), vp.width, vp.height, GL_DEPTH_BUFFER_BIT, GL_DEPTH_ATTACHMENT);
|
||||
|
||||
vp.main_fb->setup_drawing(1); // restore draw buffers after blit operation
|
||||
|
||||
model_ubs.param[0].x = m_framerate / (1.0 / Global.gfx_postfx_motionblur_shutter);
|
||||
model_ubo->update(model_ubs);
|
||||
m_pfx_motionblur->apply({vp.main_tex.get(), vp.main_texv.get()}, vp.main2_fb.get());
|
||||
|
||||
vp.main_fb->setup_drawing(1); // restore draw buffers after blit operation
|
||||
m_pfx_motionblur->apply({vp.main_tex.get(), vp.main_texv.get(), vp.main_texd.get()}, vp.main2_fb.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -804,7 +812,6 @@ void opengl33_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
|
||||
glViewport(0, 0, target_size.x, target_size.y);
|
||||
|
||||
if( Global.gfx_postfx_chromaticaberration_enabled ) {
|
||||
// NOTE: for some unexplained reason need this setup_drawing() call here for the tonemapping effects to show up on the main_tex?
|
||||
m_pfx_tonemapping->apply( *vp.main2_tex, vp.main_fb.get() );
|
||||
m_pfx_chromaticaberration->apply( *vp.main_tex, nullptr );
|
||||
}
|
||||
|
||||
@@ -208,6 +208,7 @@ class opengl33_renderer : public gfx_renderer {
|
||||
std::unique_ptr<gl::framebuffer> main_fb;
|
||||
std::unique_ptr<opengl_texture> main_texv;
|
||||
std::unique_ptr<opengl_texture> main_tex;
|
||||
std::unique_ptr<opengl_texture> main_texd;
|
||||
|
||||
std::unique_ptr<gl::framebuffer> main2_fb;
|
||||
std::unique_ptr<opengl_texture> main2_tex;
|
||||
|
||||
@@ -174,7 +174,7 @@ world_environment::update() {
|
||||
// update the fog. setting it to match the average colour of the sky dome is cheap
|
||||
// but quite effective way to make the distant items blend with background better
|
||||
Global.FogColor =
|
||||
interpolate( m_skydome.GetAverageColor(), m_skydome.GetAverageHorizonColor(), 0.33f )
|
||||
interpolate( m_skydome.GetAverageColor(), m_skydome.GetAverageHorizonColor(), 0.25f )
|
||||
* clamp<float>( Global.fLuminance, 0.25f, 1.f );
|
||||
|
||||
// weather-related simulation factors
|
||||
|
||||
20
skydome.cpp
20
skydome.cpp
@@ -268,10 +268,10 @@ void CSkyDome::RebuildColors() {
|
||||
colorconverter.z = 0.85f + ( colorconverter.z - 0.85f ) * 0.35f;
|
||||
}
|
||||
|
||||
colorconverter.y = clamp( colorconverter.y * 1.15f, 0.0f, 1.0f );
|
||||
colorconverter.y = clamp( colorconverter.y * Global.m_skysaturationcorrection, 0.0f, 1.0f );
|
||||
// desaturate sky colour, based on overcast level
|
||||
if( colorconverter.y > 0.0f ) {
|
||||
colorconverter.y *= ( 1.0f - m_overcast );
|
||||
colorconverter.y *= ( 1.0f - 0.5f * m_overcast );
|
||||
}
|
||||
|
||||
// override the hue, based on sun height above the horizon. crude way to deal with model shortcomings
|
||||
@@ -288,13 +288,8 @@ void CSkyDome::RebuildColors() {
|
||||
|
||||
color = colors::HSVtoRGB(colorconverter);
|
||||
|
||||
color = interpolate( color, shiftedcolor, shiftfactor );
|
||||
/*
|
||||
// gamma control
|
||||
color.x = std::pow( color.x, m_gammacorrection );
|
||||
color.x = std::pow( color.y, m_gammacorrection );
|
||||
color.x = std::pow( color.z, m_gammacorrection );
|
||||
*/
|
||||
color = interpolate( color, shiftedcolor, shiftfactor * Global.m_skyhuecorrection );
|
||||
|
||||
// crude correction for the times where the model breaks (late night)
|
||||
// TODO: use proper night sky calculation for these times instead
|
||||
if( ( color.x <= 0.05f )
|
||||
@@ -304,14 +299,17 @@ void CSkyDome::RebuildColors() {
|
||||
color.z = 0.75f * std::max( color.z + m_sundirection.y, 0.075f );
|
||||
color.x = 0.20f * color.z;
|
||||
color.y = 0.65f * color.z;
|
||||
color = color * ( 1.15f - vertex.y ); // simple gradient, darkening towards the top
|
||||
}
|
||||
// gamma correction
|
||||
color = glm::pow( color, gammacorrection );
|
||||
/*
|
||||
if( Global.GfxFramebufferSRGB ) {
|
||||
color = glm::pow( color, glm::vec3( 2.2f ) - ( gammacorrection * 0.5f ) );
|
||||
}
|
||||
// save
|
||||
*/
|
||||
// simple gradient, darkening towards the top
|
||||
color *= ( 1.15f - vertex.y );
|
||||
// save
|
||||
m_colours[ i ] = color;
|
||||
averagecolor += color;
|
||||
if( ( m_vertices.size() - i ) <= ( m_tesselation * 3 + 3 ) ) {
|
||||
|
||||
Reference in New Issue
Block a user