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

line breaker cab control enhancement, minor bug fixes

This commit is contained in:
tmj-fstate
2020-02-02 22:30:36 +01:00
parent a1e8f6e24d
commit 2ce3091e8f
8 changed files with 120 additions and 63 deletions

View File

@@ -687,6 +687,16 @@ putvalues_event::run_() {
m_input.data_value_2,
loc );
}
else if( m_activator->ctOwner ) {
// send the command to consist owner,
// we're acting on presumption there's hardly ever need to issue command to unmanned vehicle
// and the intended recipient moved between vehicles after the event was queued
m_activator->ctOwner->PutCommand(
m_input.data_text,
m_input.data_value_1,
m_input.data_value_2,
loc );
}
else {
// przekazanie do pojazdu
m_activator->MoverParameters->PutCommand(

View File

@@ -636,7 +636,7 @@ bool TMoverParameters::ChangeCab(int direction)
BrakeLevelSet(Handle->GetPos(bh_NP));
// if not TestFlag(BrakeStatus,b_dmg) then
// BrakeStatus:=b_off; //z Megapacka
MainCtrlPos = 0;
MainCtrlPos = MainCtrlNoPowerPos();
ScndCtrlPos = 0;
// Ra: to poniżej jest bez sensu - można przejść nie wyłączając
// if ((EngineType!=DieselEngine)&&(EngineType!=DieselElectric))
@@ -7878,8 +7878,7 @@ TMoverParameters::update_doors( double const Deltatime ) {
auto const autoopenrequest {
( Doors.open_control == control_t::autonomous )
&& ( ( false == Doors.permit_needed ) || door.open_permit )
};
&& ( ( false == Doors.permit_needed ) || door.open_permit ) };
auto const openrequest {
( localopencontrol && door.local_open )
|| ( remoteopencontrol && door.remote_open )

View File

@@ -1890,7 +1890,11 @@ void TSubModel::BinInit(TSubModel *s, float4x4 *m, std::vector<std::string> *t,
b_aAnim = b_Anim; // skopiowanie animacji do drugiego cyklu
if( (eType == TP_FREESPOTLIGHT) && (iFlags & 0x10)) {
if( eType == TP_STARS ) {
m_material = GfxRenderer->Fetch_Material( "stars" );
iFlags |= 0x10;
}
else if( (eType == TP_FREESPOTLIGHT) && (iFlags & 0x10)) {
// we've added light glare which needs to be rendered during transparent phase,
// but models converted to e3d before addition won't have the render flag set correctly for this
// so as a workaround we're doing it here manually

146
Train.cpp
View File

@@ -1151,7 +1151,16 @@ void TTrain::OnCommand_independentbrakeincrease( TTrain *Train, command_data con
if( Command.action != GLFW_RELEASE ) {
if( Train->mvOccupied->LocalBrake != TLocalBrake::ManualBrake ) {
Train->mvOccupied->IncLocalBrakeLevel( 1 );
if( ( Train->ggJointCtrl.SubModel != nullptr )
&& ( Train->mvOccupied->MainCtrlPos > 0 ) ) {
OnCommand_mastercontrollerdecrease( Train, Command );
}
else {
Train->mvOccupied->IncLocalBrakeLevel( 1 );
if( Train->ggJointCtrl.SubModel != nullptr ) {
Train->m_mastercontrollerinuse = true;
}
}
}
}
}
@@ -1161,7 +1170,16 @@ void TTrain::OnCommand_independentbrakeincreasefast( TTrain *Train, command_data
if( Command.action != GLFW_RELEASE ) {
if( Train->mvOccupied->LocalBrake != TLocalBrake::ManualBrake ) {
Train->mvOccupied->IncLocalBrakeLevel( LocalBrakePosNo );
if( ( Train->ggJointCtrl.SubModel != nullptr )
&& ( Train->mvOccupied->MainCtrlPos > 0 ) ) {
OnCommand_mastercontrollerdecreasefast( Train, Command );
}
else {
Train->mvOccupied->IncLocalBrakeLevel( LocalBrakePosNo );
if( Train->ggJointCtrl.SubModel != nullptr ) {
Train->m_mastercontrollerinuse = true;
}
}
}
}
}
@@ -1174,7 +1192,16 @@ void TTrain::OnCommand_independentbrakedecrease( TTrain *Train, command_data con
// Ra 1014-06: AI potrafi zahamować pomocniczym mimo jego braku - odhamować jakoś trzeba
// TODO: sort AI out so it doesn't do things it doesn't have equipment for
|| ( Train->mvOccupied->LocalBrakePosA > 0 ) ) {
Train->mvOccupied->DecLocalBrakeLevel( 1 );
if( ( Train->ggJointCtrl.SubModel != nullptr )
&& ( Train->mvOccupied->LocalBrakePosA == 0.0 ) ) {
OnCommand_mastercontrollerincrease( Train, Command );
}
else {
Train->mvOccupied->DecLocalBrakeLevel( 1 );
if( Train->ggJointCtrl.SubModel != nullptr ) {
Train->m_mastercontrollerinuse = true;
}
}
}
}
}
@@ -1187,7 +1214,16 @@ void TTrain::OnCommand_independentbrakedecreasefast( TTrain *Train, command_data
// Ra 1014-06: AI potrafi zahamować pomocniczym mimo jego braku - odhamować jakoś trzeba
// TODO: sort AI out so it doesn't do things it doesn't have equipment for
|| ( Train->mvOccupied->LocalBrakePosA > 0 ) ) {
Train->mvOccupied->DecLocalBrakeLevel( LocalBrakePosNo );
if( ( Train->ggJointCtrl.SubModel != nullptr )
&& ( Train->mvOccupied->LocalBrakePosA == 0.0 ) ) {
OnCommand_mastercontrollerincreasefast( Train, Command );
}
else {
Train->mvOccupied->DecLocalBrakeLevel( LocalBrakePosNo );
if( Train->ggJointCtrl.SubModel != nullptr ) {
Train->m_mastercontrollerinuse = true;
}
}
}
}
}
@@ -2243,15 +2279,27 @@ void TTrain::OnCommand_pantographtoggleselected( TTrain *Train, command_data con
}
else if( Command.action == GLFW_RELEASE ) {
// impulse switches return automatically to neutral position
if( Train->ggPantSelectedButton.type() != TGaugeType::toggle ) {
Train->mvControlled->OperatePantographsValve( operation_t::enable_off );
// visual feedback
Train->ggPantSelectedButton.UpdateValue( 0.0, Train->dsbSwitch );
if( Train->m_controlmapper.contains( "pantselectedoff_sw:" ) ) {
// two buttons setup
if( Train->ggPantSelectedButton.type() != TGaugeType::toggle ) {
Train->mvControlled->OperatePantographsValve( operation_t::enable_off );
// visual feedback
Train->ggPantSelectedButton.UpdateValue( 0.0, Train->dsbSwitch );
}
if( Train->ggPantSelectedDownButton.type() != TGaugeType::toggle ) {
Train->mvControlled->OperatePantographsValve( operation_t::disable_off );
// visual feedback
Train->ggPantSelectedDownButton.UpdateValue( 0.0, Train->dsbSwitch );
}
}
if( Train->ggPantSelectedDownButton.type() != TGaugeType::toggle ) {
Train->mvControlled->OperatePantographsValve( operation_t::disable_off );
// visual feedback
Train->ggPantSelectedDownButton.UpdateValue( 0.0, Train->dsbSwitch );
else {
if( Train->ggPantSelectedButton.type() != TGaugeType::toggle ) {
// special case, just one impulse switch controlling both states
// with neutral position mid-way
Train->mvControlled->OperatePantographsValve( operation_t::none );
// visual feedback
Train->ggPantSelectedButton.UpdateValue( 0.5, Train->dsbSwitch );
}
}
}
}
@@ -2286,8 +2334,12 @@ void TTrain::OnCommand_pantographlowerselected( TTrain *Train, command_data cons
operation_t::disable_on :
operation_t::disable );
// visual feedback
Train->ggPantSelectedDownButton.UpdateValue( 1.0, Train->dsbSwitch );
if( Train->ggPantSelectedButton.type() == TGaugeType::toggle ) {
if( Train->m_controlmapper.contains( "pantselectedoff_sw:" ) ) {
// two button setup
Train->ggPantSelectedDownButton.UpdateValue( 1.0, Train->dsbSwitch );
}
else {
// single button
Train->ggPantSelectedButton.UpdateValue( 0.0, Train->dsbSwitch );
}
}
@@ -2391,9 +2443,9 @@ void TTrain::OnCommand_linebreakertoggle( TTrain *Train, command_data const &Com
else if( Command.action == GLFW_RELEASE ) {
// release...
if( ( Train->ggMainOnButton.SubModel != nullptr )
|| ( Train->mvControlled->TrainType == dt_EZT ) ) {
// only impulse switches react to release events; since we don't have switch type definition for the line breaker,
// we detect it from presence of relevant button, or presume such switch arrangement for EMUs
|| ( Train->ggMainButton.type() != TGaugeType::toggle ) ) {
// only impulse switches react to release events
// NOTE: we presume dedicated state switch is of impulse type
if( Train->m_linebreakerstate == 0 ) {
// ...after opening circuit, or holding for too short time to close it
OnCommand_linebreakeropen( Train, Command );
@@ -2411,37 +2463,20 @@ void TTrain::OnCommand_linebreakeropen( TTrain *Train, command_data const &Comma
if( Command.action == GLFW_PRESS ) {
// visual feedback
if( Train->ggMainOffButton.SubModel != nullptr ) {
// two separate switches to close and break the circuit
if( Train->m_controlmapper.contains( "main_off_bt:" ) ) {
Train->ggMainOffButton.UpdateValue( 1.0, Train->dsbSwitch );
}
else if( Train->ggMainButton.SubModel != nullptr ) {
// single two-state switch
// NOTE: we don't have switch type definition for the line breaker switch
// so for the time being we have hard coded "impulse" switches for all EMUs
// TODO: have proper switch type config for all switches, and put it in the cab switch descriptions, not in the .fiz
if( Train->mvControlled->TrainType == dt_EZT ) {
Train->ggMainButton.UpdateValue( 1.0, Train->dsbSwitch );
}
else {
Train->ggMainButton.UpdateValue( 0.0, Train->dsbSwitch );
}
else if( Train->m_controlmapper.contains( "main_sw:" ) ) {
Train->ggMainButton.UpdateValue( 0.0, Train->dsbSwitch );
}
else {
// fallback for cabs with no submodel
Train->ggMainButton.UpdateValue( 0.0, Train->dsbSwitch );
// there's no switch capable of doing the job
return;
}
// play sound immediately when the switch is hit, not after release
Train->fMainRelayTimer = 0.0f;
if( Train->m_linebreakerstate == 0 ) { return; } // already in the desired state
// NOTE: we don't have switch type definition for the line breaker switch
// so for the time being we have hard coded "impulse" switches for all EMUs
// TODO: have proper switch type config for all switches, and put it in the cab switch descriptions, not in the .fiz
if( Train->mvControlled->TrainType == dt_EZT ) {
// a single impulse switch can't open the circuit, only close it
return;
}
if( true == Train->mvControlled->MainSwitch( false ) ) {
Train->m_linebreakerstate = 0;
@@ -2459,7 +2494,11 @@ void TTrain::OnCommand_linebreakeropen( TTrain *Train, command_data const &Comma
}
// and the two-state switch too, for good measure
if( Train->ggMainButton.SubModel != nullptr ) {
Train->ggMainButton.UpdateValue( 0.0, Train->dsbSwitch );
Train->ggMainButton.UpdateValue( (
Train->ggMainButton.type() != TGaugeType::toggle ?
0.5 :
0.0 ),
Train->dsbSwitch );
}
}
}
@@ -2472,15 +2511,10 @@ void TTrain::OnCommand_linebreakerclose( TTrain *Train, command_data const &Comm
// two separate switches to close and break the circuit
Train->ggMainOnButton.UpdateValue( 1.0, Train->dsbSwitch );
}
else if( Train->ggMainButton.SubModel != nullptr ) {
else {
// single two-state switch
Train->ggMainButton.UpdateValue( 1.0, Train->dsbSwitch );
}
else {
// fallback for cabs with no submodel
Train->ggMainButton.UpdateValue( 1.0, Train->dsbSwitch );
}
// the actual closing of the line breaker is handled in the train update routine
}
else if( Command.action == GLFW_RELEASE ) {
@@ -2489,12 +2523,9 @@ void TTrain::OnCommand_linebreakerclose( TTrain *Train, command_data const &Comm
// setup with two separate switches
Train->ggMainOnButton.UpdateValue( 0.0, Train->dsbSwitch );
}
// NOTE: we don't have switch type definition for the line breaker switch
// so for the time being we have hard coded "impulse" switches for all EMUs
// TODO: have proper switch type config for all switches, and put it in the cab switch descriptions, not in the .fiz
if( Train->mvControlled->TrainType == dt_EZT ) {
if( Train->ggMainButton.SubModel != nullptr ) {
Train->ggMainButton.UpdateValue( 0.0, Train->dsbSwitch );
else {
if( Train->ggMainButton.type() != TGaugeType::toggle ) {
Train->ggMainButton.UpdateValue( 0.5, Train->dsbSwitch );
}
}
@@ -8131,6 +8162,11 @@ void TTrain::set_cab_controls( int const Cab ) {
( ggBatteryButton.type() == TGaugeType::push ? 0.5f :
mvOccupied->Battery ? 1.f :
0.f ) );
// line breaker
ggMainButton.PutValue(
( ggMainButton.type() == TGaugeType::push ? 0.5f :
m_linebreakerstate > 0 ? 1.f :
0.f ) );
// motor connectors
ggStLinOffButton.PutValue(
( mvControlled->StLinSwitchOff ?
@@ -8186,6 +8222,12 @@ void TTrain::set_cab_controls( int const Cab ) {
1.f :
0.f ) );
}
else {
if( false == m_controlmapper.contains( "pantselectedoff_sw:" ) ) {
// single impulse switch arrangement, with neutral position mid-way
ggPantSelectedButton.PutValue( 0.5f );
}
}
if( ggPantSelectedDownButton.type() == TGaugeType::toggle ) {
ggPantSelectedDownButton.PutValue(
( mvControlled->PantsValve.is_disabled ?

View File

@@ -1244,6 +1244,8 @@ driver_mode::ChangeDynamic() {
occupied->CabDeactivisation();
occupied->CabOccupied = 0;
occupied->BrakeLevelSet( occupied->Handle->GetPos( bh_NP ) ); //rozwala sterowanie hamulcem GF 04-2016
occupied->MainCtrlPos = occupied->MainCtrlNoPowerPos();
occupied->ScndCtrlPos = 0;
vehicle->MechInside = false;
vehicle->Controller = AIdriver;
}

View File

@@ -12,9 +12,9 @@ void gl::glsl_common_setup()
"#define POSTFX_ENABLED " + std::to_string((int)!Global.gfx_skippipeline) + "\n" +
"#define EXTRAEFFECTS_ENABLED " + std::to_string((int)Global.gfx_extraeffects) + "\n" +
"#define USE_GLES " + std::to_string((int)Global.gfx_usegles) + "\n" +
"const uint MAX_LIGHTS = " + std::to_string(MAX_LIGHTS) + "U;\n" +
"const uint MAX_CASCADES = " + std::to_string(MAX_CASCADES) + "U;\n" +
"const uint MAX_PARAMS = " + std::to_string(MAX_PARAMS) + "U;\n" +
"#define MAX_LIGHTS " + std::to_string(MAX_LIGHTS) + "U\n" +
"#define MAX_CASCADES " + std::to_string(MAX_CASCADES) + "U\n" +
"#define MAX_PARAMS " + std::to_string(MAX_PARAMS) + "U\n" +
R"STRING(
const uint LIGHT_SPOT = 0U;
const uint LIGHT_POINT = 1U;

View File

@@ -3634,13 +3634,13 @@ void opengl33_renderer::Render_Alpha(TSubModel *Submodel)
if (Global.Overcast > 1.0f)
{
// fake fog halo
float const fogfactor{interpolate(2.f, 1.f, clamp(Global.fFogEnd / 2000, 0.f, 1.f)) * std::max(1.f, Global.Overcast)};
model_ubs.param[1].x = pointsize * resolutionratio * fogfactor * 3.0f;
float const fogfactor{interpolate(1.5f, 1.f, clamp(Global.fFogEnd / 2000, 0.f, 1.f)) * std::max(1.f, Global.Overcast)};
model_ubs.param[1].x = pointsize * resolutionratio * fogfactor * 4.0f;
model_ubs.param[0] = glm::vec4(glm::vec3(lightcolor), Submodel->fVisible * std::min(1.f, lightlevel) * 0.5f);
draw(Submodel->m_geometry);
}
model_ubs.param[1].x = pointsize * resolutionratio * 3.0f;
model_ubs.param[1].x = pointsize * resolutionratio * 4.0f;
model_ubs.param[0] = glm::vec4(glm::vec3(lightcolor), Submodel->fVisible * std::min(1.f, lightlevel));
if (!Submodel->occlusion_query)

View File

@@ -1,5 +1,5 @@
#pragma once
#define VERSION_MAJOR 20
#define VERSION_MINOR 126
#define VERSION_MINOR 129
#define VERSION_REVISION 0