control for alerter, doors, vehicle lights. support for multiple logs. fixes for relaytype 45, 46

This commit is contained in:
tmj-fstate
2017-04-13 15:56:28 +02:00
parent 1034fb8aa9
commit fafb7a63c3
18 changed files with 1951 additions and 1194 deletions

View File

@@ -214,7 +214,11 @@ int main(int argc, char *argv[])
if (!glfwInit())
return -1;
DeleteFile("errors.txt");
#ifdef _WINDOWS
DeleteFile( "log.txt" );
DeleteFile( "errors.txt" );
_mkdir("logs");
#endif
Global::LoadIniFile("eu07.ini");
Global::InitKeys();

View File

@@ -166,6 +166,7 @@ bool Global::bOldSmudge = false; // Używanie starej smugi
bool Global::bWireFrame = false;
bool Global::bSoundEnabled = true;
int Global::iWriteLogEnabled = 3; // maska bitowa: 1-zapis do pliku, 2-okienko, 4-nazwy torów
bool Global::MultipleLogs{ false };
bool Global::bManageNodes = true;
bool Global::bDecompressDDS = false; // czy programowa dekompresja DDS
@@ -374,7 +375,11 @@ void Global::ConfigParse(cParser &Parser)
Global::iWriteLogEnabled = stol_def(token,3);
}
}
else if (token == "adjustscreenfreq")
else if( token == "multiplelogs" ) {
Parser.getTokens();
Parser >> Global::MultipleLogs;
}
else if( token == "adjustscreenfreq" )
{
// McZapkie-240403 - czestotliwosc odswiezania ekranu
Parser.getTokens();

View File

@@ -214,6 +214,7 @@ class Global
static void SetCameraPosition(Math3D::vector3 pNewCameraPosition);
static void SetCameraRotation(double Yaw);
static int iWriteLogEnabled; // maska bitowa: 1-zapis do pliku, 2-okienko
static bool MultipleLogs;
// McZapkie-221002: definicja swiatla dziennego
static float Background[3];
static GLfloat AtmoColor[];

View File

@@ -386,7 +386,7 @@ void TGroundNode::RenderAlphaVBO()
if( ( PROBLEND ) ) // sprawdza, czy w nazwie nie ma @ //Q: 13122011 - Szociu: 27012012
{
glDisable( GL_BLEND );
glAlphaFunc( GL_GREATER, 0.45f ); // im mniejsza wartość, tym większa ramka, domyślnie 0.1f
glAlphaFunc( GL_GREATER, 0.50f ); // im mniejsza wartość, tym większa ramka, domyślnie 0.1f
};
#endif
@@ -662,7 +662,7 @@ void TGroundNode::RenderAlphaDL()
if ((PROBLEND)) // sprawdza, czy w nazwie nie ma @ //Q: 13122011 - Szociu: 27012012
{
glDisable(GL_BLEND);
glAlphaFunc(GL_GREATER, 0.45f); // im mniejsza wartość, tym większa ramka, domyślnie 0.1f
glAlphaFunc(GL_GREATER, 0.50f); // im mniejsza wartość, tym większa ramka, domyślnie 0.1f
};
#endif
if (!DisplayListID) //||Global::bReCompile) //Ra: wymuszenie rekompilacji
@@ -4758,7 +4758,7 @@ TGround::Render( Math3D::vector3 const &Camera ) {
bool TGround::RenderDL(vector3 pPosition)
{ // renderowanie scenerii z Display List - faza nieprzezroczystych
glDisable(GL_BLEND);
glAlphaFunc(GL_GREATER, 0.45f); // im mniejsza wartość, tym większa ramka, domyślnie 0.1f
glAlphaFunc(GL_GREATER, 0.50f); // im mniejsza wartość, tym większa ramka, domyślnie 0.1f
++TGroundRect::iFrameNumber; // zwięszenie licznika ramek (do usuwniania nadanimacji)
CameraDirection.x = sin(Global::pCameraRotation); // wektor kierunkowy
CameraDirection.z = cos(Global::pCameraRotation);
@@ -4848,7 +4848,7 @@ bool TGround::RenderAlphaDL(vector3 pPosition)
bool TGround::RenderVBO(vector3 pPosition)
{ // renderowanie scenerii z VBO - faza nieprzezroczystych
glDisable(GL_BLEND);
glAlphaFunc(GL_GREATER, 0.45f); // im mniejsza wartość, tym większa ramka, domyślnie 0.1f
glAlphaFunc(GL_GREATER, 0.50f); // im mniejsza wartość, tym większa ramka, domyślnie 0.1f
++TGroundRect::iFrameNumber; // zwięszenie licznika ramek
CameraDirection.x = sin(Global::pCameraRotation); // wektor kierunkowy
CameraDirection.z = cos(Global::pCameraRotation);

View File

@@ -18,6 +18,33 @@ std::ofstream comms; // lista komunikatow "comms.txt", można go wyłączyć
char endstring[10] = "\n";
std::string filename_date() {
::SYSTEMTIME st;
::GetSystemTime( &st );
char buffer[ 256 ];
sprintf( buffer,
"%d%02d%02d_%02d%02d",
st.wYear,
st.wMonth,
st.wDay,
st.wHour,
st.wMinute );
return std::string( buffer );
}
std::string filename_scenery() {
auto extension = Global::SceneryFile.rfind( '.' );
if( extension != std::string::npos ) {
return Global::SceneryFile.substr( 0, extension );
}
else {
return Global::SceneryFile;
}
}
void WriteConsoleOnly(const char *str, double value)
{
char buf[255];
@@ -57,8 +84,14 @@ void WriteLog(const char *str, bool newline)
{
if (Global::iWriteLogEnabled & 1)
{
if (!output.is_open())
output.open("log.txt", std::ios::trunc);
if( !output.is_open() ) {
std::string const filename =
( Global::MultipleLogs ?
"logs/log (" + filename_scenery() + ") " + filename_date() + ".txt" :
"log.txt" );
output.open( filename, std::ios::trunc );
}
output << str;
if (newline)
output << "\n";
@@ -72,9 +105,13 @@ void WriteLog(const char *str, bool newline)
void ErrorLog(const char *str)
{ // Ra: bezwarunkowa rejestracja poważnych błędów
if (!errors.is_open())
{
errors.open("errors.txt", std::ios::trunc);
if (!errors.is_open()) {
std::string const filename =
( Global::MultipleLogs ?
"logs/errors (" + filename_scenery() + ") " + filename_date() + ".txt" :
"errors.txt" );
errors.open( filename, std::ios::trunc );
errors << "EU07.EXE " + Global::asRelease << "\n";
}
if (str)

View File

@@ -416,37 +416,30 @@ struct TPowerParameters
struct
{
_mover__3 RHeater;
};
struct
{
_mover__2 RPowerCable;
};
struct
{
TCurrentCollector CollectorParameters;
};
struct
{
_mover__1 RAccumulator;
};
struct
{
TEngineTypes GeneratorEngine;
};
struct
{
double InputVoltage;
};
struct
{
TPowerType PowerType;
};
};
@@ -670,10 +663,18 @@ public:
/*nastawniki:*/
int MainCtrlPosNo = 0; /*ilosc pozycji nastawnika*/
int ScndCtrlPosNo = 0;
int LightsPosNo = 0; // NOTE: values higher than 0 seem to break the current code for light switches
int LightsPosNo = 0;
int LightsDefPos = 1;
bool LightsWrap = false;
int Lights[2][17]; // pozycje świateł, przód - tył, 1 .. 16
enum light {
headlight_left = 0x01,
redmarker_left = 0x02,
headlight_upper = 0x04,
headlight_right = 0x10,
redmarker_right = 0x20,
};
bool ScndInMain = false; /*zaleznosc bocznika od nastawnika*/
bool MBrake = false; /*Czy jest hamulec reczny*/
double StopBrakeDecc = 0.0;
@@ -1173,6 +1174,10 @@ extract_value( _Type &Variable, std::string const &Key, std::string const &Input
}
}
template <>
bool
extract_value( bool &Variable, std::string const &Key, std::string const &Input, std::string const &Default );
inline
std::string
extract_value( std::string const &Key, std::string const &Input ) {

View File

@@ -1814,8 +1814,9 @@ bool TMoverParameters::IncScndCtrl(int CtrlSpeed)
LastRelayTime = 0;
if ((OK) && (EngineType == ElectricInductionMotor))
// NOTE: round() already adds 0.5, are the ones added here as well correct?
if ((Vmax < 250))
ScndCtrlActualPos = Round(Vel + 0.5f);
ScndCtrlActualPos = Round(Vel + 0.5);
else
ScndCtrlActualPos = Round(Vel * 1.0 / 2 + 0.5);
@@ -2031,10 +2032,12 @@ void TMoverParameters::SecuritySystemCheck(double dt)
(Battery)) // Ra: EZT ma teraz czuwak w rozrządczym
{
// CA
if (Vel >=
SecuritySystem
.AwareMinSpeed) // domyślnie predkość większa od 10% Vmax, albo podanej jawnie w FIZ
{
if( ( SecuritySystem.AwareMinSpeed > 0.0 ?
( Vel >= SecuritySystem.AwareMinSpeed ) :
( ActiveDir != 0 ) ) ) {
// domyślnie predkość większa od 10% Vmax, albo podanej jawnie w FIZ
// with defined minspeed of 0 the alerter will activate with reverser out of neutral position
// this emulates behaviour of engines like SM42
SecuritySystem.SystemTimer += dt;
if (TestFlag(SecuritySystem.SystemType, 1) &&
TestFlag(SecuritySystem.Status, s_aware)) // jeśli świeci albo miga
@@ -4087,106 +4090,152 @@ double TMoverParameters::TractionForce(double dt)
if ((MainCtrlPos == 0) || (ShuntMode))
ScndCtrlPos = 0;
else if (AutoRelayFlag)
switch (RelayType)
{
case 0:
{
if ((Im <= (MPTRelay[ScndCtrlPos].Iup * PosRatio)) &&
(ScndCtrlPos < ScndCtrlPosNo))
++ScndCtrlPos;
if ((Im >= (MPTRelay[ScndCtrlPos].Idown * PosRatio)) && (ScndCtrlPos > 0))
--ScndCtrlPos;
break;
}
case 1:
{
if ((MPTRelay[ScndCtrlPos].Iup < Vel) && (ScndCtrlPos < ScndCtrlPosNo))
++ScndCtrlPos;
if ((MPTRelay[ScndCtrlPos].Idown > Vel) && (ScndCtrlPos > 0))
--ScndCtrlPos;
break;
}
case 2:
{
if ((MPTRelay[ScndCtrlPos].Iup < Vel) && (ScndCtrlPos < ScndCtrlPosNo) &&
(EnginePower < (tmp * 0.99)))
++ScndCtrlPos;
if ((MPTRelay[ScndCtrlPos].Idown < Im) && (ScndCtrlPos > 0))
--ScndCtrlPos;
break;
}
case 41:
{
if ((MainCtrlPos == MainCtrlPosNo) &&
(tmpV * 3.6 > MPTRelay[ScndCtrlPos].Iup) && (ScndCtrlPos < ScndCtrlPosNo))
{
++ScndCtrlPos;
enrot = enrot * 0.73;
}
if ((Im > MPTRelay[ScndCtrlPos].Idown) && (ScndCtrlPos > 0))
--ScndCtrlPos;
break;
}
case 45:
{
if ((MainCtrlPos > 11) && (ScndCtrlPos < ScndCtrlPosNo))
if ((ScndCtrlPos == 0))
if ((MPTRelay[ScndCtrlPos].Iup > Im))
++ScndCtrlPos;
else if ((MPTRelay[ScndCtrlPos].Iup < Vel))
++ScndCtrlPos;
else {
if( AutoRelayFlag ) {
// malenie
if ((ScndCtrlPos > 0) && (MainCtrlPos < 12))
if ((ScndCtrlPos == ScndCtrlPosNo))
if ((MPTRelay[ScndCtrlPos].Idown < Im))
--ScndCtrlPos;
else if ((MPTRelay[ScndCtrlPos].Idown > Vel))
--ScndCtrlPos;
if ((MainCtrlPos < 11) && (ScndCtrlPos > 2))
ScndCtrlPos = 2;
if ((MainCtrlPos < 9) && (ScndCtrlPos > 0))
ScndCtrlPos = 0;
}
case 46:
{
// wzrastanie
if ((MainCtrlPos > 9) && (ScndCtrlPos < ScndCtrlPosNo))
if ((ScndCtrlPos) % 2 == 0)
if ((MPTRelay[ScndCtrlPos].Iup > Im))
++ScndCtrlPos;
else if ((MPTRelay[ScndCtrlPos - 1].Iup > Im) &&
(MPTRelay[ScndCtrlPos].Iup < Vel))
++ScndCtrlPos;
switch( RelayType ) {
// malenie
if ((MainCtrlPos < 10) && (ScndCtrlPos > 0))
if ((ScndCtrlPos) % 2 == 0)
if ((MPTRelay[ScndCtrlPos].Idown < Im))
case 0: {
if( ( Im <= ( MPTRelay[ ScndCtrlPos ].Iup * PosRatio ) ) &&
( ScndCtrlPos < ScndCtrlPosNo ) )
++ScndCtrlPos;
if( ( Im >= ( MPTRelay[ ScndCtrlPos ].Idown * PosRatio ) ) && ( ScndCtrlPos > 0 ) )
--ScndCtrlPos;
else if ((MPTRelay[ScndCtrlPos + 1].Idown < Im) &&
(MPTRelay[ScndCtrlPos].Idown > Vel))
break;
}
case 1: {
if( ( MPTRelay[ ScndCtrlPos ].Iup < Vel ) && ( ScndCtrlPos < ScndCtrlPosNo ) )
++ScndCtrlPos;
if( ( MPTRelay[ ScndCtrlPos ].Idown > Vel ) && ( ScndCtrlPos > 0 ) )
--ScndCtrlPos;
if ((MainCtrlPos < 9) && (ScndCtrlPos > 2))
ScndCtrlPos = 2;
if ((MainCtrlPos < 6) && (ScndCtrlPos > 0))
ScndCtrlPos = 0;
break;
}
case 2: {
if( ( MPTRelay[ ScndCtrlPos ].Iup < Vel ) && ( ScndCtrlPos < ScndCtrlPosNo ) &&
( EnginePower < ( tmp * 0.99 ) ) )
++ScndCtrlPos;
if( ( MPTRelay[ ScndCtrlPos ].Idown < Im ) && ( ScndCtrlPos > 0 ) )
--ScndCtrlPos;
break;
}
case 41:
{
if( ( MainCtrlPos == MainCtrlPosNo )
&& ( tmpV * 3.6 > MPTRelay[ ScndCtrlPos ].Iup )
&& ( ScndCtrlPos < ScndCtrlPosNo ) ) {
++ScndCtrlPos;
enrot = enrot * 0.73;
}
if( ( Im > MPTRelay[ ScndCtrlPos ].Idown )
&& ( ScndCtrlPos > 0 ) ) {
--ScndCtrlPos;
}
break;
}
case 45:
{
if( ( MainCtrlPos >= 10 ) && ( ScndCtrlPos < ScndCtrlPosNo ) ) {
if( ScndCtrlPos == 0 ) {
if( Im < MPTRelay[ ScndCtrlPos ].Iup ) {
++ScndCtrlPos;
}
}
else {
if( Vel > MPTRelay[ ScndCtrlPos ].Iup ) {
++ScndCtrlPos;
}
// check for cases where the speed drops below threshold for level 2 or 3
if( ( ScndCtrlPos > 1 )
&& ( Vel < MPTRelay[ ScndCtrlPos - 1 ].Idown ) ){
--ScndCtrlPos;
}
}
}
// malenie
if( ( ScndCtrlPos > 0 ) && ( MainCtrlPos < 10 ) ) {
if( ScndCtrlPos == 1 ) {
if( Im > MPTRelay[ ScndCtrlPos - 1 ].Idown ) {
--ScndCtrlPos;
}
}
else {
if( Vel < MPTRelay[ ScndCtrlPos ].Idown ) {
--ScndCtrlPos;
}
}
}
// 3rd level drops with master controller at position lower than 10...
if( MainCtrlPos < 10 ) {
ScndCtrlPos = std::min( 2, ScndCtrlPos );
}
// ...and below position 7 field shunt drops altogether
if( MainCtrlPos < 7 ) {
ScndCtrlPos = 0;
}
break;
}
case 46:
{
// wzrastanie
if( ( MainCtrlPos >= 10 )
&& ( ScndCtrlPos < ScndCtrlPosNo ) ) {
if( ( ScndCtrlPos ) % 2 == 0 ) {
if( ( MPTRelay[ ScndCtrlPos ].Iup > Im ) ) {
++ScndCtrlPos;
}
}
else {
if( ( MPTRelay[ ScndCtrlPos - 1 ].Iup > Im )
&& ( MPTRelay[ ScndCtrlPos ].Iup < Vel ) ) {
++ScndCtrlPos;
}
}
}
// malenie
if( ( MainCtrlPos < 10 )
&& ( ScndCtrlPos > 0 ) ) {
if( ( ScndCtrlPos ) % 2 == 0 ) {
if( ( MPTRelay[ ScndCtrlPos ].Idown < Im ) ) {
--ScndCtrlPos;
}
}
else {
if( ( MPTRelay[ ScndCtrlPos + 1 ].Idown < Im )
&& ( MPTRelay[ ScndCtrlPos ].Idown > Vel ) ) {
--ScndCtrlPos;
}
}
}
if( MainCtrlPos < 10 ) {
ScndCtrlPos = std::min( 2, ScndCtrlPos );
}
if( MainCtrlPos < 7 ) {
ScndCtrlPos = 0;
}
break;
}
default: {
break;
}
} // switch RelayType
}
} // switch RelayType
}
break;
} // DieselElectric
case ElectricInductionMotor:
{
if ((Mains)) // nie wchodzić w funkcję bez potrzeby
if ((abs(Voltage) < EnginePowerSource.CollectorParameters.MinV) ||
(abs(Voltage) > EnginePowerSource.CollectorParameters.MaxV + 200))
{
MainSwitch(false);
if( ( Mains ) ) {
// nie wchodzić w funkcję bez potrzeby
if( ( abs( Voltage ) < EnginePowerSource.CollectorParameters.MinV )
|| ( abs( Voltage ) > EnginePowerSource.CollectorParameters.MaxV + 200 ) ) {
MainSwitch( false );
}
tmpV = abs(nrot) * (PI * WheelDiameter) *
3.6; //*DirAbsolute*eimc[eimc_s_p]; - do przemyslenia dzialanie pp
}
tmpV = abs(nrot) * (PI * WheelDiameter) * 3.6; //*DirAbsolute*eimc[eimc_s_p]; - do przemyslenia dzialanie pp
if ((Mains))
{
@@ -7915,3 +7964,22 @@ double TMoverParameters::ShowCurrentP(int AmpN)
return current;
}
}
template <>
bool
extract_value( bool &Variable, std::string const &Key, std::string const &Input, std::string const &Default ) {
auto value = extract_value( Key, Input );
if( false == value.empty() ) {
// set the specified variable to retrieved value
Variable = ( ToLower( value ) == "yes" );
return true; // located the variable
}
else {
// set the variable to provided default value
if( false == Default.empty() ) {
Variable = ( ToLower( Default ) == "yes" );
}
return false; // supplied the default
}
}

View File

@@ -72,23 +72,11 @@ double Min0R(double x1, double x2)
// TODO: replace with something sensible
std::string Now() {
std::time_t timenow = std::time( nullptr );
std::tm tm = *std::localtime( &timenow );
std::stringstream converter;
converter << std::put_time( &tm, "%c" );
std::time_t timenow = std::time( nullptr );
std::tm tm = *std::localtime( &timenow );
std::stringstream converter;
converter << std::put_time( &tm, "%c" );
return converter.str();
/* char buffer[ 256 ];
sprintf( buffer,
"%d-%02d-%02d %02d:%02d:%02d.%03d",
st.wYear,
st.wMonth,
st.wDay,
st.wHour,
st.wMinute,
st.wSecond,
st.wMilliseconds );
*/
}
bool TestFlag(int Flag, int Value)

View File

@@ -62,7 +62,7 @@ inline double Sign(double x)
return x >= 0 ? 1.0 : -1.0;
}
inline long Round(float f)
inline long Round(double const f)
{
return (long)(f + 0.5);
//return lround(f);

2529
Train.cpp

File diff suppressed because it is too large Load Diff

100
Train.h
View File

@@ -70,37 +70,32 @@ class TTrain
bool InitializeCab(int NewCabNo, std::string const &asFileName);
TTrain();
~TTrain();
// bool Init(TTrack *Track);
// McZapkie-010302
bool Init(TDynamicObject *NewDynamicObject, bool e3d = false);
void OnKeyDown(int cKey);
void OnKeyUp(int cKey);
void OnCommand( command_data const &Command );
// bool SHP() { fShpTimer= 0; };
inline vector3 GetDirection()
{
return DynamicObject->VectorFront();
};
inline vector3 GetUp()
{
return DynamicObject->VectorUp();
};
inline vector3 GetDirection() { return DynamicObject->VectorFront(); };
inline vector3 GetUp() { return DynamicObject->VectorUp(); };
void UpdateMechPosition(double dt);
vector3 GetWorldMechPosition();
bool Update( double const Deltatime );
bool m_updated = false;
void MechStop();
void SetLights();
// virtual bool RenderAlpha();
// McZapkie-310302: ladowanie parametrow z pliku
bool LoadMMediaFile(std::string const &asFileName);
PyObject *GetTrainState();
private:
// types
typedef void( *command_handler )( TTrain *Train, command_data const &Command );
typedef std::unordered_map<user_command, command_handler> commandhandler_map;
// clears state of all cabin controls
void clear_cab_controls();
// sets cabin controls based on current state of the vehicle
// NOTE: we can get rid of this function once we have per-cab persistent state
void set_cab_controls();
// initializes a gauge matching provided label. returns: true if the label was found, false
// otherwise
bool initialize_gauge(cParser &Parser, std::string const &Label, int const Cabindex);
@@ -109,20 +104,67 @@ class TTrain
bool initialize_button(cParser &Parser, std::string const &Label, int const Cabindex);
// plays specified sound, or fallback sound if the primary sound isn't presend
// NOTE: temporary routine until sound system is sorted out and paired with switches
void play_sound( PSound Sound, PSound Fallbacksound = nullptr );
void play_sound( PSound Sound, int const Volume = DSBVOLUME_MAX, DWORD const Flags = 0 );
void play_sound( PSound Sound, PSound Fallbacksound, int const Volume, DWORD const Flags );
// helper, returns true for EMU with oerlikon brake
bool is_eztoer() const;
// command handlers
// NOTE: we're currently using universal handlers and static handler map but it may be beneficial to have these implemented on individual class instance basis
// TBD, TODO: consider this approach if we ever want to have customized consist behaviour to received commands, based on the consist/vehicle type or whatever
static void OnCommand_mastercontrollerincrease( TTrain *Train, command_data const &Command );
static void OnCommand_mastercontrollerincreasefast( TTrain *Train, command_data const &Command );
static void OnCommand_mastercontrollerdecrease( TTrain *Train, command_data const &Command );
static void OnCommand_mastercontrollerdecreasefast( TTrain *Train, command_data const &Command );
static void OnCommand_secondcontrollerincrease( TTrain *Train, command_data const &Command );
static void OnCommand_secondcontrollerincreasefast( TTrain *Train, command_data const &Command );
static void OnCommand_secondcontrollerdecrease( TTrain *Train, command_data const &Command );
static void OnCommand_secondcontrollerdecreasefast( TTrain *Train, command_data const &Command );
static void OnCommand_independentbrakeincrease( TTrain *Train, command_data const &Command );
static void OnCommand_independentbrakeincreasefast( TTrain *Train, command_data const &Command );
static void OnCommand_independentbrakedecrease( TTrain *Train, command_data const &Command );
static void OnCommand_independentbrakedecreasefast( TTrain *Train, command_data const &Command );
static void OnCommand_independentbrakebailoff( TTrain *Train, command_data const &Command );
static void OnCommand_trainbrakeincrease( TTrain *Train, command_data const &Command );
static void OnCommand_trainbrakedecrease( TTrain *Train, command_data const &Command );
static void OnCommand_trainbrakecharging( TTrain *Train, command_data const &Command );
static void OnCommand_trainbrakerelease( TTrain *Train, command_data const &Command );
static void OnCommand_trainbrakefirstservice( TTrain *Train, command_data const &Command );
static void OnCommand_trainbrakeservice( TTrain *Train, command_data const &Command );
static void OnCommand_trainbrakefullservice( TTrain *Train, command_data const &Command );
static void OnCommand_trainbrakeemergency( TTrain *Train, command_data const &Command );
static void OnCommand_reverserincrease( TTrain *Train, command_data const &Command );
static void OnCommand_reverserdecrease( TTrain *Train, command_data const &Command );
static void OnCommand_alerteracknowledge( TTrain *Train, command_data const &Command );
static void OnCommand_batterytoggle( TTrain *Train, command_data const &Command );
static void OnCommand_pantographtogglefront( TTrain *Train, command_data const &Command );
static void OnCommand_pantographtogglerear( TTrain *Train, command_data const &Command );
static void OnCommand_linebreakertoggle( TTrain *Train, command_data const &Command );
static void OnCommand_convertertoggle( TTrain *Train, command_data const &Command );
static void OnCommand_compressortoggle( TTrain *Train, command_data const &Command );
static void OnCommand_headlighttoggleleft( TTrain *Train, command_data const &Command );
static void OnCommand_headlighttoggleright( TTrain *Train, command_data const &Command );
static void OnCommand_headlighttoggleupper( TTrain *Train, command_data const &Command );
static void OnCommand_redmarkertoggleleft( TTrain *Train, command_data const &Command );
static void OnCommand_redmarkertoggleright( TTrain *Train, command_data const &Command );
static void OnCommand_headlighttogglerearleft( TTrain *Train, command_data const &Command );
static void OnCommand_headlighttogglerearright( TTrain *Train, command_data const &Command );
static void OnCommand_headlighttogglerearupper( TTrain *Train, command_data const &Command );
static void OnCommand_redmarkertogglerearleft( TTrain *Train, command_data const &Command );
static void OnCommand_redmarkertogglerearright( TTrain *Train, command_data const &Command );
static void OnCommand_doortoggleleft( TTrain *Train, command_data const &Command );
static void OnCommand_doortoggleright( TTrain *Train, command_data const &Command );
// helper variable, to prevent immediate switch between closing and opening line breaker circuit
bool m_linebreakerclosed{ false };
private: //żeby go nic z zewnątrz nie przestawiało
// members
TDynamicObject *DynamicObject; // przestawia zmiana pojazdu [F5]
private: //żeby go nic z zewnątrz nie przestawiało
TMoverParameters *mvControlled; // człon, w którym sterujemy silnikiem
TMoverParameters *mvOccupied; // człon, w którym sterujemy hamulcem
TMoverParameters *mvSecond; // drugi człon (ET40, ET41, ET42, ukrotnienia)
TMoverParameters *mvThird; // trzeci człon (SN61)
public: // reszta może by?publiczna
// AnsiString asMessage;
// helper variable, to prevent immediate switch between closing and opening line breaker circuit
bool m_linebreakerclosed{ false };
static const commandhandler_map m_commandhandlers;
public: // reszta może by?publiczna
// McZapkie: definicje wskaźników
// Ra 2014-08: częsciowo przeniesione do tablicy w TCab
@@ -220,7 +262,6 @@ class TTrain
TGauge ggTrainHeatingButton;
TGauge ggSignallingButton;
TGauge ggDoorSignallingButton;
// TModel3d *mdKabina; McZapkie-030303: to do dynobj
// TGauge ggDistCounter; //Ra 2014-07: licznik kilometrów
// TGauge ggVelocityDgt; //i od razu prędkościomierz
@@ -422,18 +463,9 @@ class TTrain
public:
float fPress[20][3]; // cisnienia dla wszystkich czlonow
float fEIMParams[9][10]; // parametry dla silnikow asynchronicznych
int RadioChannel()
{
return iRadioChannel;
};
inline TDynamicObject *Dynamic()
{
return DynamicObject;
};
inline TMoverParameters *Controlled()
{
return mvControlled;
};
int RadioChannel() { return iRadioChannel; };
inline TDynamicObject *Dynamic() { return DynamicObject; };
inline TMoverParameters *Controlled() { return mvControlled; };
void DynamicSet(TDynamicObject *d);
void Silence();
};

View File

@@ -1692,13 +1692,18 @@ TWorld::Update_UI() {
// timetable
TDynamicObject *tmp =
( FreeFlyModeFlag ?
Ground.DynamicNearest( Camera.Pos ) :
Controlled ); // w trybie latania lokalizujemy wg mapy
Ground.DynamicNearest( Camera.Pos ) :
Controlled ); // w trybie latania lokalizujemy wg mapy
if( tmp == nullptr ) { break; }
if( tmp->Mechanik == nullptr ) { break; }
// if the nearest located vehicle doesn't have a direct driver, try to query its owner
auto const owner = (
tmp->Mechanik != nullptr ?
tmp->Mechanik :
tmp->ctOwner );
if( owner == nullptr ){ break; }
auto const table = tmp->Mechanik->Timetable();
auto const table = owner->Timetable();
if( table == nullptr ) { break; }
auto const &time = simulation::Time.data();
@@ -1711,14 +1716,12 @@ TWorld::Update_UI() {
uitextline1 += " (paused)";
}
if( Controlled
&& Controlled->Mechanik ) {
uitextline2 = Global::Bezogonkow( Controlled->Mechanik->Relation(), true ) + " (" + tmp->Mechanik->Timetable()->TrainName + ")";
if( !uitextline2.empty() ) {
// jeśli jest podana relacja, to dodajemy punkt następnego zatrzymania
uitextline3 = " -> " + Global::Bezogonkow( Controlled->Mechanik->NextStop(), true );
}
}
uitextline2 = Global::Bezogonkow( owner->Relation(), true ) + " (" + owner->Timetable()->TrainName + ")";
auto const nextstation = Global::Bezogonkow( owner->NextStop(), true );
if( !nextstation.empty() ) {
// jeśli jest podana relacja, to dodajemy punkt następnego zatrzymania
uitextline3 = " -> " + nextstation;
}
if( Global::iScreenMode[ Global::iTextMode - GLFW_KEY_F1 ] == 1 ) {
@@ -1731,7 +1734,7 @@ TWorld::Update_UI() {
UITable->text_lines.emplace_back( "+----------------------------+-------+-------+-----+", Global::UITextColor );
TMTableLine *tableline;
for( int i = tmp->Mechanik->iStationStart; i <= std::min( tmp->Mechanik->iStationStart + 15, table->StationCount ); ++i ) {
for( int i = owner->iStationStart; i <= std::min( owner->iStationStart + 15, table->StationCount ); ++i ) {
// wyświetlenie pozycji z rozkładu
tableline = table->TimeTable + i; // linijka rozkładu
@@ -1752,7 +1755,7 @@ TWorld::Update_UI() {
UITable->text_lines.emplace_back(
Global::Bezogonkow( "| " + station + " | " + arrival + " | " + departure + " | " + vmax + " | " + tableline->StationWare, true ),
( ( tmp->Mechanik->iStationStart < table->StationIndex ) && ( i < table->StationIndex ) ?
( ( owner->iStationStart < table->StationIndex ) && ( i < table->StationIndex ) ?
float4( 0.0f, 1.0f, 0.0f, 1.0f ) :// czas minął i odjazd był, to nazwa stacji będzie na zielono
Global::UITextColor )
);

View File

@@ -91,6 +91,9 @@ const int k_Fuse = 26;
const int k_MaxCurrent = 29;
const int k_CurrentAutoRelay = 30;
const int k_BrakeProfile = 31;
*/
{ user_command::alerteracknowledge, command_target::vehicle },
/*
const int k_Czuwak = 32;
const int k_Horn = 33;
const int k_Horn2 = 34;
@@ -118,10 +121,10 @@ const int k_DeCouple = 45;
const int k_ProgramQuit = 46;
// const int k_ProgramPause= 47;
const int k_ProgramHelp = 48;
const int k_OpenLeft = 49;
const int k_OpenRight = 50;
const int k_CloseLeft = 51;
const int k_CloseRight = 52;
*/
{ user_command::doortoggleleft, command_target::vehicle },
{ user_command::doortoggleright, command_target::vehicle },
/*
const int k_DepartureSignal = 53;
*/
{ user_command::pantographtogglefront, command_target::vehicle },
@@ -129,9 +132,18 @@ const int k_DepartureSignal = 53;
/*
const int k_Heating = 58;
// const int k_FreeFlyMode= 59;
const int k_LeftSign = 60;
const int k_UpperSign = 61;
const int k_RightSign = 62;
*/
{ user_command::headlighttoggleleft, command_target::vehicle },
{ user_command::headlighttoggleright, command_target::vehicle },
{ user_command::headlighttoggleupper, command_target::vehicle },
{ user_command::redmarkertoggleleft, command_target::vehicle },
{ user_command::redmarkertoggleright, command_target::vehicle },
{ user_command::headlighttogglerearleft, command_target::vehicle },
{ user_command::headlighttogglerearright, command_target::vehicle },
{ user_command::headlighttogglerearupper, command_target::vehicle },
{ user_command::redmarkertogglerearleft, command_target::vehicle },
{ user_command::redmarkertogglerearright, command_target::vehicle },
/*
const int k_SmallCompressor = 63;
const int k_StLinOff = 64;
const int k_CurrentNext = 65;
@@ -189,6 +201,9 @@ const int k_Fuse = 26;
const int k_MaxCurrent = 29;
const int k_CurrentAutoRelay = 30;
const int k_BrakeProfile = 31;
*/
"alerteracknowledge",
/*
const int k_Czuwak = 32;
const int k_Horn = 33;
const int k_Horn2 = 34;
@@ -216,10 +231,10 @@ const int k_DeCouple = 45;
const int k_ProgramQuit = 46;
// const int k_ProgramPause= 47;
const int k_ProgramHelp = 48;
const int k_OpenLeft = 49;
const int k_OpenRight = 50;
const int k_CloseLeft = 51;
const int k_CloseRight = 52;
*/
"doortoggleleft",
"doortoggleright",
/*
const int k_DepartureSignal = 53;
*/
"pantographtogglefront",
@@ -227,9 +242,18 @@ const int k_DepartureSignal = 53;
/*
const int k_Heating = 58;
// const int k_FreeFlyMode= 59;
const int k_LeftSign = 60;
const int k_UpperSign = 61;
const int k_RightSign = 62;
*/
"headlighttoggleleft",
"headlighttoggleright",
"headlighttoggleupper",
"redmarkertoggleleft",
"redmarkertoggleright",
"headlighttogglerearleft",
"headlighttogglerearright",
"headlighttogglerearupper",
"redmarkertogglerearleft",
"redmarkertogglerearright",
/*
const int k_SmallCompressor = 63;
const int k_StLinOff = 64;
const int k_CurrentNext = 65;
@@ -258,8 +282,9 @@ command_relay::post( user_command const Command, std::uint64_t const Param1, std
return;
}
if( ( lookup->second == command_target::vehicle )
&& ( true == FreeFlyModeFlag ) ) {
// don't pass vehicle commands if the user isn't in one
&& ( true == FreeFlyModeFlag )
&& ( false == DebugModeFlag ) ) {
// don't pass vehicle commands if the user isn't in one, unless we're in debug mode
return;
}

View File

@@ -51,6 +51,9 @@ const int k_Fuse = 26;
const int k_MaxCurrent = 29;
const int k_CurrentAutoRelay = 30;
const int k_BrakeProfile = 31;
*/
alerteracknowledge,
/*
const int k_Czuwak = 32;
const int k_Horn = 33;
const int k_Horn2 = 34;
@@ -78,10 +81,10 @@ const int k_DeCouple = 45;
const int k_ProgramQuit = 46;
// const int k_ProgramPause= 47;
const int k_ProgramHelp = 48;
const int k_OpenLeft = 49;
const int k_OpenRight = 50;
const int k_CloseLeft = 51;
const int k_CloseRight = 52;
*/
doortoggleleft,
doortoggleright,
/*
const int k_DepartureSignal = 53;
*/
pantographtogglefront,
@@ -89,9 +92,18 @@ const int k_DepartureSignal = 53;
/*
const int k_Heating = 58;
// const int k_FreeFlyMode= 59;
const int k_LeftSign = 60;
const int k_UpperSign = 61;
const int k_RightSign = 62;
*/
headlighttoggleleft,
headlighttoggleright,
headlighttoggleupper,
redmarkertoggleleft,
redmarkertoggleright,
headlighttogglerearleft,
headlighttogglerearright,
headlighttogglerearupper,
redmarkertogglerearleft,
redmarkertogglerearright,
/*
const int k_SmallCompressor = 63;
const int k_StLinOff = 64;
const int k_CurrentNext = 65;

View File

@@ -130,7 +130,9 @@ const int k_Fuse = 26;
const int k_MaxCurrent = 29;
const int k_CurrentAutoRelay = 30;
const int k_BrakeProfile = 31;
const int k_Czuwak = 32;
*/
{ "alerteracknowledge", command_target::vehicle, GLFW_KEY_SPACE },
/*
const int k_Horn = 33;
const int k_Horn2 = 34;
const int k_FailedEngineCutOff = 35;
@@ -157,10 +159,10 @@ const int k_DeCouple = 45;
const int k_ProgramQuit = 46;
// const int k_ProgramPause= 47;
const int k_ProgramHelp = 48;
const int k_OpenLeft = 49;
const int k_OpenRight = 50;
const int k_CloseLeft = 51;
const int k_CloseRight = 52;
*/
{ "doortoggleleft", command_target::vehicle, GLFW_KEY_COMMA },
{ "doortoggleright", command_target::vehicle, GLFW_KEY_PERIOD },
/*
const int k_DepartureSignal = 53;
*/
{ "pantographtogglefront", command_target::vehicle, GLFW_KEY_P },
@@ -168,9 +170,18 @@ const int k_DepartureSignal = 53;
/*
const int k_Heating = 58;
// const int k_FreeFlyMode= 59;
const int k_LeftSign = 60;
const int k_UpperSign = 61;
const int k_RightSign = 62;
*/
{ "headlighttoggleleft", command_target::vehicle, GLFW_KEY_Y },
{ "headlighttoggleright", command_target::vehicle, GLFW_KEY_I },
{ "headlighttoggleupper", command_target::vehicle, GLFW_KEY_U },
{ "redmarkertoggleleft", command_target::vehicle, GLFW_KEY_Y | keymodifier::shift },
{ "redmarkertoggleright", command_target::vehicle, GLFW_KEY_I | keymodifier::shift },
{ "headlighttogglerearleft", command_target::vehicle, GLFW_KEY_Y | keymodifier::control },
{ "headlighttogglerearright", command_target::vehicle, GLFW_KEY_I | keymodifier::control },
{ "headlighttogglerearupper", command_target::vehicle, GLFW_KEY_U | keymodifier::control },
{ "redmarkertogglerearleft", command_target::vehicle, GLFW_KEY_Y | keymodifier::control | keymodifier::shift },
{ "redmarkertogglerearright", command_target::vehicle, GLFW_KEY_I | keymodifier::control | keymodifier::shift },
/*
const int k_SmallCompressor = 63;
const int k_StLinOff = 64;
const int k_CurrentNext = 65;

View File

@@ -220,7 +220,7 @@
<Filter>Source Files\input</Filter>
</ClCompile>
<ClCompile Include="gamepadinput.cpp">
<Filter>Source Files</Filter>
<Filter>Source Files\input</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
@@ -429,7 +429,7 @@
<Filter>Header Files\input</Filter>
</ClInclude>
<ClInclude Include="gamepadinput.h">
<Filter>Header Files</Filter>
<Filter>Header Files\input</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>

View File

@@ -282,7 +282,7 @@ bool
opengl_renderer::Render( TGround *Ground ) {
glDisable( GL_BLEND );
glAlphaFunc( GL_GREATER, 0.45f ); // im mniejsza wartość, tym większa ramka, domyślnie 0.1f
glAlphaFunc( GL_GREATER, 0.50f ); // im mniejsza wartość, tym większa ramka, domyślnie 0.1f
glEnable( GL_LIGHTING );
glColor3f( 1.0f, 1.0f, 1.0f );

View File

@@ -25,6 +25,7 @@
#include <shlobj.h>
#undef NOMINMAX
#include <dbghelp.h>
#include <direct.h>
#endif
// stl
#include <cstdlib>