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

revert to frequent log flushing, fix for fiz parsing on linux, unify brake_speed interpretation as full rotations per second

This commit is contained in:
milek7
2018-08-11 20:13:45 +02:00
parent f479f2cabe
commit 0453e10534
5 changed files with 8 additions and 13 deletions

View File

@@ -36,12 +36,10 @@ int main( int argc, char *argv[] )
result = Application.run();
}
Application.exit();
return result;
}
catch( std::bad_alloc const &Error )
{
ErrorLog( "Critical error, memory allocation failure: " + std::string( Error.what() ) );
}
LogsFlush();
std::_Exit(0); // skip destructors, there are ordering errors which causes segfaults
}

View File

@@ -81,6 +81,7 @@ void WriteLog( const char *str, logtype const Type ) {
}
output << str << "\n";
}
output.flush();
UILayer.log.emplace_back(std::string(str));
if (UILayer.log.size() > 100)
@@ -119,14 +120,6 @@ void ErrorLog( const char *str, logtype const Type ) {
errors.flush();
};
void LogsFlush()
{
if (output.is_open())
output.flush();
if (errors.is_open())
errors.flush();
}
void Error(const std::string &asMessage, bool box)
{
// if (box)

1
Logs.h
View File

@@ -27,4 +27,3 @@ void ErrorLog( const std::string &str, logtype const Type = logtype::generic );
void WriteLog( const std::string &str, logtype const Type = logtype::generic );
void CommLog( const char *str );
void CommLog( const std::string &str );
void LogsFlush();

View File

@@ -7286,6 +7286,11 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
// guard against malformed config files with leading spaces
inputline.erase( 0, inputline.find_first_not_of( ' ' ) );
}
// trim CR at end (mainly for linux)
if (!inputline.empty() && inputline.back() == '\r')
inputline.pop_back();
if( inputline.length() == 0 ) {
startBPT = false;
continue;

View File

@@ -1002,14 +1002,14 @@ void TTrain::OnCommand_independentbrakebailoff( TTrain *Train, command_data cons
void TTrain::OnCommand_trainbrakeincrease( TTrain *Train, command_data const &Command ) {
if (Command.action == GLFW_REPEAT && Train->mvOccupied->BrakeHandle == TBrakeHandle::FV4a)
Train->mvOccupied->BrakeLevelAdd( Global.brake_speed * Command.time_delta );
Train->mvOccupied->BrakeLevelAdd( Global.brake_speed * Command.time_delta * Train->mvOccupied->BrakeCtrlPosNo );
else if (Command.action == GLFW_PRESS && Train->mvOccupied->BrakeHandle != TBrakeHandle::FV4a)
Train->set_train_brake( Train->mvOccupied->fBrakeCtrlPos + Global.fBrakeStep );
}
void TTrain::OnCommand_trainbrakedecrease( TTrain *Train, command_data const &Command ) {
if (Command.action == GLFW_REPEAT && Train->mvOccupied->BrakeHandle == TBrakeHandle::FV4a)
Train->mvOccupied->BrakeLevelAdd( -Global.brake_speed * Command.time_delta );
Train->mvOccupied->BrakeLevelAdd( -Global.brake_speed * Command.time_delta * Train->mvOccupied->BrakeCtrlPosNo );
else if (Command.action == GLFW_PRESS && Train->mvOccupied->BrakeHandle != TBrakeHandle::FV4a)
Train->set_train_brake( Train->mvOccupied->fBrakeCtrlPos - Global.fBrakeStep );