17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-07 00:22:56 +01:00

fix(ai): release horn when human driver takes over from AI

This commit is contained in:
jerrrrycho
2026-10-16 13:10:50 +02:00
parent 05ffb9058c
commit ccb973e049
24 changed files with 8090 additions and 83 deletions

View File

@@ -13,6 +13,8 @@ http://mozilla.org/MPL/2.0/.
#include <map>
#include "hamulce.h"
#include "scripting/ladderlogic.h"
class cParser;
/*
MaSzyna EU07 locomotive simulator
Copyright (C) 2001-2004 Maciej Czapkiewicz and others
@@ -2534,10 +2536,12 @@ class TMoverParameters
/*funkcje ladujace pliki opisujace pojazd*/
bool LoadFIZ(std::string const &chkpath); // Q 20160717 bool LoadChkFile(std::string chkpath);
bool LoadFIZ_Text(std::string const &Text); // the same, from text in the .fiz format
bool CheckLocomotiveParameters(bool ReadyFlag, int Dir);
std::string EngineDescription(int what) const;
private:
bool LoadFIZ_Parse(cParser &Parser); // reads the definition from either of the above
void LoadFIZ_Param(std::string const &line);
void LoadFIZ_Load(std::string const &line);
void LoadFIZ_Dimensions(std::string const &line);

View File

@@ -5032,6 +5032,14 @@ void TMoverParameters::ComputeTotalForce(double dt)
{
SlippingWheels = true;
}
if (true == SlippingWheels && Vel < 0.1 // the same crude trap: (nearly) stopped vehicle...
&& std::abs(nrot * M_PI * WheelDiameter - V) < 0.1 / 3.6) // ...with wheels turning at its speed, i.e. locked wheels at the end of a skid
{
// locked wheels never pass the rotation speed test below once the vehicle stops, and a skidding vehicle
// keeps its braking force capped by the sliding adhesion, so the rest of the consist could push it around
SlippingWheels = false;
nrot = V / M_PI / WheelDiameter;
}
double temp_nrot = nrot;
if (true == SlippingWheels)
{
@@ -9559,6 +9567,37 @@ bool TMoverParameters::LoadFIZ(std::string const &chkpath)
chkPath = chkpath; // assign class path for reloading
ConversionError = 666;
std::string file = TypeName + ".fiz";
WriteLog("LOAD FIZ FROM " + file);
/*
std::ifstream in(file);
if (!in.is_open())
{
WriteLog("E8 - FIZ FILE NOT EXIST.");
return false;
}
*/
cParser fizparser(file, cParser::buffer_FILE, chkpath);
if (false == fizparser.ok())
{
WriteLog("E8 - FIZ FILE NOT EXIST.");
return false;
}
return LoadFIZ_Parse(fizparser);
}
// reads the vehicle definition from text in the .fiz format, e.g. one made up by a unit test
bool TMoverParameters::LoadFIZ_Text(std::string const &Text)
{
ConversionError = 666;
cParser fizparser(Text, cParser::buffer_TEXT);
return LoadFIZ_Parse(fizparser);
}
bool TMoverParameters::LoadFIZ_Parse(cParser &fizparser) // NOSONAR the former body of LoadFIZ(), moved as it was; splitting it up is a change of its own
{
LISTLINE = 0;
startBPT = false;
startMPT = false;
@@ -9577,23 +9616,6 @@ bool TMoverParameters::LoadFIZ(std::string const &chkpath)
startDimmerList = false;
startLIGHTSLIST = false;
startCOMPRESSORLIST = false;
std::string file = TypeName + ".fiz";
WriteLog("LOAD FIZ FROM " + file);
/*
std::ifstream in(file);
if (!in.is_open())
{
WriteLog("E8 - FIZ FILE NOT EXIST.");
return false;
}
*/
cParser fizparser(file, cParser::buffer_FILE, chkpath);
if (false == fizparser.ok())
{
WriteLog("E8 - FIZ FILE NOT EXIST.");
return false;
}
ConversionError = 0;