ai disconnect logic fix, non modal debug mode pause, minor render code reverts to track down potential crash source

This commit is contained in:
tmj-fstate
2018-09-06 20:24:59 +02:00
parent bb0e1eb3bf
commit 8f1292118b
5 changed files with 33 additions and 18 deletions

View File

@@ -996,7 +996,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
}
}
if (OrderCurrentGet() == Shunt) {
if (OrderCurrentGet() & Shunt) {
OrderNext(Obey_train); // uruchomić jazdę pociągową
CheckVehicles(); // zmienić światła
}
@@ -1060,12 +1060,11 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
sSpeedTable[i].iFlags = 0; // W4 nie liczy się już (nie wyśle SetVelocity)
sSpeedTable[i].fVelNext = -1; // można jechać za W4
fLastStopExpDist = -1.0f; // nie ma rozkładu, nie ma usuwania stacji
/*
// NOTE: disabled as it's no longer needed, required time is calculated as part of loading/unloading procedure
WaitingSet(60); // tak ze 2 minuty, aż wszyscy wysiądą
*/
// wykonanie kolejnego rozkazu (Change_direction albo Shunt)
JumpToNextOrder();
// FIX: don't automatically advance if there's disconnect procedure in progress
if( false == TestFlag( OrderCurrentGet(), Disconnect ) ) {
JumpToNextOrder();
}
// ma się nie ruszać aż do momentu podania sygnału
iDrivigFlags |= moveStopHere | moveStartHorn;
continue; // nie analizować prędkości
@@ -2061,7 +2060,7 @@ bool TController::CheckVehicles(TOrders user)
}
if (AIControllFlag)
{ // jeśli prowadzi komputer
if (OrderCurrentGet() == Obey_train) {
if( true == TestFlag( OrderCurrentGet(), Obey_train ) ) {
// jeśli jazda pociągowa
// światła pociągowe (Pc1) i końcówki (Pc5)
auto const frontlights { (
@@ -2098,7 +2097,7 @@ bool TController::CheckVehicles(TOrders user)
light::headlight_right ); //światła manewrowe (Tb1) na pojeździe z napędem
}
}
else if( OrderCurrentGet() == Disconnect ) {
else if( true == TestFlag( OrderCurrentGet(), Disconnect ) ) {
if( mvOccupied->ActiveDir > 0 ) {
// jak ma kierunek do przodu
// światła manewrowe (Tb1) tylko z przodu, aby nie pozostawić odczepionego ze światłem
@@ -3666,7 +3665,7 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N
// set consist lights pattern hints
m_lighthints[ side::front ] = static_cast<int>( NewValue1 );
m_lighthints[ side::rear ] = static_cast<int>( NewValue2 );
if( OrderCurrentGet() == Obey_train ) {
if( true == TestFlag( OrderCurrentGet(), Obey_train ) ) {
// light hints only apply in the obey_train mode
CheckVehicles();
}
@@ -4296,7 +4295,7 @@ TController::UpdateSituation(double dt) {
IncSpeed(); // dla (Ready)==false nie ruszy
}
}
if ((mvOccupied->Vel == 0.0) && !(iDrivigFlags & movePress))
if ((mvOccupied->Vel < 0.01) && !(iDrivigFlags & movePress))
{ // 2. faza odczepiania: zmień kierunek na przeciwny i dociśnij
// za radą yB ustawiamy pozycję 3 kranu (ruszanie kranem w innych miejscach
// powino zostać wyłączone)
@@ -4333,7 +4332,7 @@ TController::UpdateSituation(double dt) {
}
}
else {
if( mvOccupied->Vel > 0.0 ) {
if( mvOccupied->Vel > 0.01 ) {
// 1st phase(?)
// bring it to stop if it's not already stopped
SetVelocity( 0, 0, stopJoin ); // wyłączyć przyspieszanie

View File

@@ -147,7 +147,7 @@ void
driver_ui::update() {
auto const pausemask { 1 | 2 };
auto ispaused { ( Global.iPause & pausemask ) != 0 };
auto ispaused { ( false == DebugModeFlag ) && ( ( Global.iPause & pausemask ) != 0 ) };
if( ( ispaused != m_paused )
&& ( false == Global.ControlPicking ) ) {
set_cursor( ispaused );

View File

@@ -1528,8 +1528,8 @@ opengl_renderer::Render( world_environment *Environment ) {
if( Environment->m_clouds.mdCloud ) {
// setup
Disable_Lights();
::glEnable( GL_LIGHT0 ); // other lights will be enabled during lights update
::glEnable( GL_LIGHTING );
::glEnable( GL_LIGHT0 ); // other lights will be enabled during lights update
::glLightModelfv(
GL_LIGHT_MODEL_AMBIENT,
glm::value_ptr(
@@ -1538,7 +1538,7 @@ opengl_renderer::Render( world_environment *Environment ) {
* 0.5f // arbitrary adjustment factor
) );
// render
// Render( Environment->m_clouds.mdCloud, nullptr, 100.0 );
Render( Environment->m_clouds.mdCloud, nullptr, 100.0 );
Render_Alpha( Environment->m_clouds.mdCloud, nullptr, 100.0 );
// post-render cleanup
::glLightModelfv( GL_LIGHT_MODEL_AMBIENT, glm::value_ptr( colors::none ) );
@@ -3518,7 +3518,7 @@ opengl_renderer::Update_Mouse_Position() {
void
opengl_renderer::Update( double const Deltatime ) {
/*
m_pickupdateaccumulator += Deltatime;
if( m_updateaccumulator > 0.5 ) {
@@ -3542,7 +3542,7 @@ opengl_renderer::Update( double const Deltatime ) {
m_picksceneryitem = nullptr;
}
}
*/
m_updateaccumulator += Deltatime;
if( m_updateaccumulator < 1.0 ) {
@@ -3595,6 +3595,22 @@ opengl_renderer::Update( double const Deltatime ) {
m_debugtimestext += m_textures.info();
}
if( ( true == Global.ControlPicking )
&& ( false == FreeFlyModeFlag ) ) {
Update_Pick_Control();
}
else {
m_pickcontrolitem = nullptr;
}
// temporary conditions for testing. eventually will be coupled with editor mode
if( ( true == Global.ControlPicking )
&& ( true == DebugModeFlag )
&& ( true == FreeFlyModeFlag ) ) {
Update_Pick_Node();
}
else {
m_picksceneryitem = nullptr;
}
// dump last opengl error, if any
auto const glerror = ::glGetError();
if( glerror != GL_NO_ERROR ) {

View File

@@ -375,7 +375,7 @@ private:
unsigned int m_framestamp; // id of currently rendered gfx frame
float m_framerate;
double m_updateaccumulator { 0.0 };
double m_pickupdateaccumulator { 0.0 };
// double m_pickupdateaccumulator { 0.0 };
std::string m_debugtimestext;
std::string m_pickdebuginfo;
debug_stats m_debugstats;

View File

@@ -204,7 +204,7 @@ init() {
"nastawa hamulca",
"nastawa hamulca: towarowy",
"nastawa hamulca: pospieszny",
"rozruch niski/wysoki",
"zakres pradu rozruchu",
"pompa wody",
"wylacznik samoczynny pompy wody",
"podgrzewacz wody",