mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-19 07:39:19 +02:00
build 190522. minor ai logic tweaks, impulse type heating switch support
This commit is contained in:
19
Driver.cpp
19
Driver.cpp
@@ -2127,11 +2127,12 @@ bool TController::CheckVehicles(TOrders user)
|
||||
while (p)
|
||||
{
|
||||
// HACK: wagony muszą mieć baterię załączoną do otwarcia drzwi...
|
||||
if( ( p != pVehicle )
|
||||
&& ( ( p->MoverParameters->Couplers[ end::front ].CouplingFlag & ( coupling::control ) ) == 0 )
|
||||
&& ( ( p->MoverParameters->Couplers[ end::rear ].CouplingFlag & ( coupling::control ) ) == 0 ) ) {
|
||||
// NOTE: don't set battery in the occupied vehicle, let the user/ai do it explicitly
|
||||
p->MoverParameters->BatterySwitch( true );
|
||||
if( p != pVehicle ) {
|
||||
if( ( ( p->MoverParameters->Couplers[ end::front ].CouplingFlag & ( coupling::control ) ) == 0 )
|
||||
&& ( ( p->MoverParameters->Couplers[ end::rear ].CouplingFlag & ( coupling::control ) ) == 0 ) ) {
|
||||
// NOTE: don't set battery in the occupied vehicle, let the user/ai do it explicitly
|
||||
p->MoverParameters->BatterySwitch( true );
|
||||
}
|
||||
// enable heating and converter in carriages with can be heated
|
||||
if( p->MoverParameters->HeatingPower > 0 ) {
|
||||
p->MoverParameters->HeatingAllow = true;
|
||||
@@ -2730,8 +2731,12 @@ bool TController::IncBrake()
|
||||
// NOTE: we could simplify this by doing only check of the rear coupler, but this can be quite tricky in itself
|
||||
// TODO: add easier ways to access front/rear coupler taking into account vehicle's direction
|
||||
standalone =
|
||||
( ( ( vehicle->MoverParameters->Couplers[ end::front ].Connected == nullptr ) || ( vehicle->MoverParameters->Couplers[ end::front ].CouplingFlag & coupling::control ) )
|
||||
&& ( ( vehicle->MoverParameters->Couplers[ end::rear ].Connected == nullptr ) || ( vehicle->MoverParameters->Couplers[ end::rear ].CouplingFlag & coupling::control ) ) );
|
||||
( ( ( vehicle->MoverParameters->Couplers[ end::front ].Connected == nullptr )
|
||||
|| ( ( vehicle->MoverParameters->Couplers[ end::front ].CouplingFlag & coupling::control )
|
||||
&& ( vehicle->MoverParameters->Couplers[ end::front ].Connected->Power > 1 ) ) )
|
||||
&& ( ( vehicle->MoverParameters->Couplers[ end::rear ].Connected == nullptr )
|
||||
|| ( ( vehicle->MoverParameters->Couplers[ end::rear ].CouplingFlag & coupling::control )
|
||||
&& ( vehicle->MoverParameters->Couplers[ end::rear ].Connected->Power > 1 ) ) ) );
|
||||
vehicle = vehicle->Next(); // kolejny pojazd, podłączony od tyłu (licząc od czoła)
|
||||
}
|
||||
}
|
||||
|
||||
6
Driver.h
6
Driver.h
@@ -201,6 +201,10 @@ public:
|
||||
inline
|
||||
TMoverParameters const *Controlling() const {
|
||||
return mvControlling; }
|
||||
inline
|
||||
TMoverParameters const *Occupied() const {
|
||||
return mvOccupied;
|
||||
}
|
||||
void DirectionInitial();
|
||||
void DirectionChange();
|
||||
inline
|
||||
@@ -251,6 +255,7 @@ public:
|
||||
bool AIControllFlag = false; // rzeczywisty/wirtualny maszynista
|
||||
int iOverheadZero = 0; // suma bitowa jezdy bezprądowej, bity ustawiane przez pojazdy z podniesionymi pantografami
|
||||
int iOverheadDown = 0; // suma bitowa opuszczenia pantografów, bity ustawiane przez pojazdy z podniesionymi pantografami
|
||||
double BrakeCtrlPosition = 0.0; // intermediate position of main brake controller
|
||||
private:
|
||||
bool Psyche = false;
|
||||
int HelperState = 0; //stan pomocnika maszynisty
|
||||
@@ -318,7 +323,6 @@ private:
|
||||
double ReactionTime = 0.0; // czas reakcji Ra: czego i na co? świadomości AI
|
||||
double fBrakeTime = 0.0; // wpisana wartość jest zmniejszana do 0, gdy ujemna należy zmienić nastawę hamulca
|
||||
double BrakeChargingCooldown {}; // prevents the ai from trying to charge the train brake too frequently
|
||||
double BrakeCtrlPosition = 0.0; // intermediate position of main brake controller
|
||||
double LastReactionTime = 0.0;
|
||||
double fActionTime = 0.0; // czas używany przy regulacji prędkości i zamykaniu drzwi
|
||||
double m_radiocontroltime{ 0.0 }; // timer used to control speed of radio operations
|
||||
|
||||
23
Train.cpp
23
Train.cpp
@@ -4140,7 +4140,7 @@ void TTrain::OnCommand_heatingtoggle( TTrain *Train, command_data const &Command
|
||||
}
|
||||
|
||||
if( Command.action == GLFW_PRESS ) {
|
||||
// only reacting to press, so the switch doesn't flip back and forth if key is held down
|
||||
// ignore repeats so the switch doesn't flip back and forth if key is held down
|
||||
if( false == Train->mvControlled->HeatingAllow ) {
|
||||
// turn on
|
||||
OnCommand_heatingenable( Train, Command );
|
||||
@@ -4150,6 +4150,14 @@ void TTrain::OnCommand_heatingtoggle( TTrain *Train, command_data const &Command
|
||||
OnCommand_heatingdisable( Train, Command );
|
||||
}
|
||||
}
|
||||
else if( Command.action == GLFW_RELEASE ) {
|
||||
|
||||
if( Train->ggTrainHeatingButton.type() == TGaugeType::push ) {
|
||||
// impulse switch
|
||||
// visual feedback
|
||||
Train->ggTrainHeatingButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TTrain::OnCommand_heatingenable( TTrain *Train, command_data const &Command ) {
|
||||
@@ -4168,7 +4176,11 @@ void TTrain::OnCommand_heatingdisable( TTrain *Train, command_data const &Comman
|
||||
|
||||
Train->mvControlled->HeatingAllow = false;
|
||||
// visual feedback
|
||||
Train->ggTrainHeatingButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||
Train->ggTrainHeatingButton.UpdateValue(
|
||||
( Train->ggTrainHeatingButton.type() == TGaugeType::push ?
|
||||
1.0 :
|
||||
0.0 ),
|
||||
Train->dsbSwitch );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7637,8 +7649,11 @@ void TTrain::set_cab_controls( int const Cab ) {
|
||||
1.f :
|
||||
0.f );
|
||||
// heating
|
||||
if( true == mvControlled->Heating ) {
|
||||
ggTrainHeatingButton.PutValue( 1.f );
|
||||
if( ggTrainHeatingButton.type() != TGaugeType::push ) {
|
||||
ggTrainHeatingButton.PutValue(
|
||||
mvControlled->Heating ?
|
||||
1.f :
|
||||
0.f );
|
||||
}
|
||||
// brake acting time
|
||||
if( ggBrakeProfileCtrl.SubModel != nullptr ) {
|
||||
|
||||
Reference in New Issue
Block a user