mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-21 14:49:19 +02:00
reformat: remove redundant parentheses
This commit is contained in:
@@ -888,10 +888,9 @@ command_relay::post(user_command const Command, double const Param1, double cons
|
||||
Recipient = simulation::Train->id();
|
||||
}
|
||||
|
||||
if( ( command.target == command_target::vehicle )
|
||||
&& ( true == FreeFlyModeFlag )
|
||||
&& ( ( false == DebugModeFlag )
|
||||
&& ( true == Global.RealisticControlMode ) ) ) {
|
||||
if( command.target == command_target::vehicle
|
||||
&& true == FreeFlyModeFlag
|
||||
&& false == DebugModeFlag && true == Global.RealisticControlMode ) {
|
||||
// in realistic control mode don't pass vehicle commands if the user isn't in one, unless we're in debug mode
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -490,7 +490,7 @@ private:
|
||||
// hash operator for m_active_continuous
|
||||
struct command_set_hash {
|
||||
uint64_t operator() (const std::pair<user_command, uint32_t> &pair) const {
|
||||
return ((uint64_t)pair.first << 32) | ((uint64_t) pair.second);
|
||||
return (uint64_t)pair.first << 32 | (uint64_t)pair.second;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -34,12 +34,12 @@ mouse_slider::bind( user_command const &Command ) {
|
||||
case user_command::jointcontrollerset:
|
||||
case user_command::mastercontrollerset:
|
||||
case user_command::secondcontrollerset: {
|
||||
vehicle = ( train ? train->Controlled() : nullptr );
|
||||
vehicle = train ? train->Controlled() : nullptr;
|
||||
break;
|
||||
}
|
||||
case user_command::trainbrakeset:
|
||||
case user_command::independentbrakeset: {
|
||||
vehicle = ( train ? train->Occupied() : nullptr );
|
||||
vehicle = train ? train->Occupied() : nullptr;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@@ -74,14 +74,8 @@ mouse_slider::bind( user_command const &Command ) {
|
||||
break;
|
||||
}
|
||||
case user_command::mastercontrollerset: {
|
||||
m_valuerange = (
|
||||
vehicle->CoupledCtrl ?
|
||||
vehicle->MainCtrlPosNo + vehicle->ScndCtrlPosNo :
|
||||
vehicle->MainCtrlPosNo );
|
||||
m_value = (
|
||||
vehicle->CoupledCtrl ?
|
||||
vehicle->MainCtrlPos + vehicle->ScndCtrlPos :
|
||||
vehicle->MainCtrlPos );
|
||||
m_valuerange = vehicle->CoupledCtrl ? vehicle->MainCtrlPosNo + vehicle->ScndCtrlPosNo : vehicle->MainCtrlPosNo;
|
||||
m_value = vehicle->CoupledCtrl ? vehicle->MainCtrlPos + vehicle->ScndCtrlPos : vehicle->MainCtrlPos;
|
||||
m_analogue = false;
|
||||
m_invertrange = false;
|
||||
break;
|
||||
@@ -126,9 +120,7 @@ mouse_slider::bind( user_command const &Command ) {
|
||||
|
||||
Application.set_cursor_pos(
|
||||
Global.window_size.y,
|
||||
( m_analogue ?
|
||||
controledge - m_value * controlsize :
|
||||
controledge - m_value * stepsize - 0.5 * stepsize ) );
|
||||
m_analogue ? controledge - m_value * controlsize : controledge - m_value * stepsize - 0.5 * stepsize );
|
||||
}
|
||||
|
||||
void
|
||||
@@ -147,10 +139,7 @@ mouse_slider::on_move( double const Mousex, double const Mousey ) {
|
||||
auto const stepsize { controlsize / m_valuerange };
|
||||
|
||||
auto mousey = std::clamp( Mousey, controledge - controlsize, controledge );
|
||||
m_value = (
|
||||
m_analogue ?
|
||||
( controledge - mousey ) / controlsize :
|
||||
std::floor( ( controledge - mousey ) / stepsize ) );
|
||||
m_value = m_analogue ? (controledge - mousey) / controlsize : std::floor((controledge - mousey) / stepsize);
|
||||
if( m_invertrange ) {
|
||||
m_value = ( m_analogue ? 1.0 : m_valuerange ) - m_value; }
|
||||
}
|
||||
@@ -309,7 +298,7 @@ drivermouse_input::scroll( double const Xoffset, double const Yoffset ) {
|
||||
// TODO: allow configurable scroll commands
|
||||
auto command {
|
||||
adjust_command(
|
||||
( Yoffset > 0.0 ) ?
|
||||
Yoffset > 0.0 ?
|
||||
m_wheelbindings.up :
|
||||
m_wheelbindings.down ) };
|
||||
|
||||
@@ -340,24 +329,20 @@ drivermouse_input::button( int const Button, int const Action ) {
|
||||
if( Action == GLFW_PRESS ) {
|
||||
GfxRenderer->Pick_Node_Callback(
|
||||
[this](scene::basic_node *node) {
|
||||
if( ( node == nullptr )
|
||||
|| ( typeid( *node ) != typeid( TAnimModel ) ) )
|
||||
if( node == nullptr
|
||||
|| typeid(*node) != typeid(TAnimModel) )
|
||||
return;
|
||||
simulation::Region->on_click( static_cast<TAnimModel const *>( node ) ); } );
|
||||
}
|
||||
}
|
||||
// right button controls panning
|
||||
if( Button == GLFW_MOUSE_BUTTON_RIGHT ) {
|
||||
m_pickmodepanning = ( Action == GLFW_PRESS );
|
||||
m_pickmodepanning = Action == GLFW_PRESS;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// cab controls mode
|
||||
user_command &mousecommand = (
|
||||
Button == GLFW_MOUSE_BUTTON_LEFT ?
|
||||
m_mousecommandleft :
|
||||
m_mousecommandright
|
||||
);
|
||||
user_command &mousecommand = Button == GLFW_MOUSE_BUTTON_LEFT ? m_mousecommandleft : m_mousecommandright;
|
||||
|
||||
if( Action == GLFW_RELEASE ) {
|
||||
if( mousecommand != user_command::none ) {
|
||||
@@ -401,11 +386,7 @@ drivermouse_input::button( int const Button, int const Action ) {
|
||||
|
||||
auto const controlbindings { bindings( simulation::Train->GetLabel( control ) ) };
|
||||
// if the recognized element under the cursor has a command associated with the pressed button, notify the recipient
|
||||
mousecommand = (
|
||||
Button == GLFW_MOUSE_BUTTON_LEFT ?
|
||||
controlbindings.first :
|
||||
controlbindings.second
|
||||
);
|
||||
mousecommand = Button == GLFW_MOUSE_BUTTON_LEFT ? controlbindings.first : controlbindings.second;
|
||||
|
||||
if( mousecommand == user_command::none ) {
|
||||
// if we don't have any recognized element under the cursor and the right button was pressed, enter view panning mode
|
||||
@@ -504,10 +485,7 @@ drivermouse_input::poll() {
|
||||
user_command
|
||||
drivermouse_input::command() const {
|
||||
|
||||
return (
|
||||
m_slider.command() != user_command::none ? m_slider.command() :
|
||||
m_mousecommandleft != user_command::none ? m_mousecommandleft :
|
||||
m_mousecommandright );
|
||||
return m_slider.command() != user_command::none ? m_slider.command() : m_mousecommandleft != user_command::none ? m_mousecommandleft : m_mousecommandright;
|
||||
}
|
||||
|
||||
// returns pair of bindings associated with specified cab control
|
||||
@@ -1151,8 +1129,8 @@ drivermouse_input::default_bindings() {
|
||||
user_command
|
||||
drivermouse_input::adjust_command( user_command Command ) {
|
||||
|
||||
if( ( true == Global.shiftState )
|
||||
&& ( Command != user_command::none ) ) {
|
||||
if( true == Global.shiftState
|
||||
&& Command != user_command::none ) {
|
||||
switch( Command ) {
|
||||
case user_command::mastercontrollerincrease: { Command = user_command::mastercontrollerincreasefast; break; }
|
||||
case user_command::mastercontrollerdecrease: { Command = user_command::mastercontrollerdecreasefast; break; }
|
||||
|
||||
@@ -55,9 +55,9 @@ editormouse_input::button( int const Button, int const Action ) {
|
||||
|
||||
// right button controls panning
|
||||
if( Button == GLFW_MOUSE_BUTTON_RIGHT ) {
|
||||
bool const panning = ( Action == GLFW_PRESS );
|
||||
bool const panning = Action == GLFW_PRESS;
|
||||
// when panning starts, request a one-frame resync so toggling the cursor grab doesn't jerk the view
|
||||
if( panning && ( false == m_pickmodepanning ) ) {
|
||||
if( panning && false == m_pickmodepanning ) {
|
||||
m_pickmodepanning_resync = true;
|
||||
}
|
||||
m_pickmodepanning = panning;
|
||||
|
||||
@@ -95,9 +95,7 @@ gamepad_input::poll() {
|
||||
// button pressed or released, both are important
|
||||
on_button(
|
||||
idx,
|
||||
( buttons[ idx ] == 1 ?
|
||||
GLFW_PRESS :
|
||||
GLFW_RELEASE ) );
|
||||
buttons[idx] == 1 ? GLFW_PRESS : GLFW_RELEASE);
|
||||
}
|
||||
else {
|
||||
// otherwise we only pass info about button being held down
|
||||
@@ -476,10 +474,7 @@ gamepad_input::process_axes() {
|
||||
param = 0.0;
|
||||
}
|
||||
else {
|
||||
param = (
|
||||
param > 0.0 ?
|
||||
( param - m_deadzone ) / ( 1.0 - m_deadzone ) :
|
||||
( param + m_deadzone ) / ( 1.0 - m_deadzone ) );
|
||||
param = param > 0.0 ? (param - m_deadzone) / (1.0 - m_deadzone) : (param + m_deadzone) / (1.0 - m_deadzone);
|
||||
}
|
||||
if( param != 0.0 ) {
|
||||
if( inputtype == input_type::value_invert ) {
|
||||
@@ -515,8 +510,8 @@ gamepad_input::process_axes() {
|
||||
auto const param1 { std::get<0>( command.second ) };
|
||||
auto const param2 { std::get<1>( command.second ) };
|
||||
auto &lastparams { m_lastcommandparams[ command.first ] };
|
||||
if( ( param1 != 0.0 ) || ( std::get<0>( lastparams ) != 0.0 )
|
||||
|| ( param2 != 0.0 ) || ( std::get<1>( lastparams ) != 0.0 ) ) {
|
||||
if( param1 != 0.0 || std::get<0>(lastparams) != 0.0
|
||||
|| param2 != 0.0 || std::get<1>(lastparams) != 0.0 ) {
|
||||
m_relay.post(
|
||||
command.first,
|
||||
param1,
|
||||
|
||||
@@ -220,7 +220,7 @@ keyboard_input::recall_bindings() {
|
||||
else {
|
||||
// replace any existing binding, preserve modifiers
|
||||
// (protection from cases where there's more than one key listed in the entry)
|
||||
keycode = keylookup->second | ( keycode & 0xffff0000 );
|
||||
keycode = keylookup->second | keycode & 0xffff0000;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -272,29 +272,23 @@ keyboard_input::key( int const Key, int const Action ) {
|
||||
|
||||
bool modifier( false );
|
||||
|
||||
if( ( Key == GLFW_KEY_LEFT_SHIFT ) || ( Key == GLFW_KEY_RIGHT_SHIFT ) ) {
|
||||
if( Key == GLFW_KEY_LEFT_SHIFT || Key == GLFW_KEY_RIGHT_SHIFT) {
|
||||
// update internal state, but don't bother passing these
|
||||
input::key_shift =
|
||||
( Action == GLFW_RELEASE ?
|
||||
false :
|
||||
true );
|
||||
Action == GLFW_RELEASE ? false : true;
|
||||
modifier = true;
|
||||
// whenever shift key is used it may affect currently pressed movement keys, so check and update these
|
||||
}
|
||||
if( ( Key == GLFW_KEY_LEFT_CONTROL ) || ( Key == GLFW_KEY_RIGHT_CONTROL ) ) {
|
||||
if( Key == GLFW_KEY_LEFT_CONTROL || Key == GLFW_KEY_RIGHT_CONTROL) {
|
||||
// update internal state, but don't bother passing these
|
||||
input::key_ctrl =
|
||||
( Action == GLFW_RELEASE ?
|
||||
false :
|
||||
true );
|
||||
Action == GLFW_RELEASE ? false : true;
|
||||
modifier = true;
|
||||
}
|
||||
if( ( Key == GLFW_KEY_LEFT_ALT ) || ( Key == GLFW_KEY_RIGHT_ALT ) ) {
|
||||
if( Key == GLFW_KEY_LEFT_ALT || Key == GLFW_KEY_RIGHT_ALT) {
|
||||
// update internal state, but don't bother passing these
|
||||
input::key_alt =
|
||||
( Action == GLFW_RELEASE ?
|
||||
false :
|
||||
true );
|
||||
Action == GLFW_RELEASE ? false : true;
|
||||
}
|
||||
|
||||
if( Key == -1 ) { return false; }
|
||||
@@ -310,8 +304,8 @@ keyboard_input::key( int const Key, int const Action ) {
|
||||
// include active modifiers for currently pressed key, except if the key is a modifier itself
|
||||
auto key =
|
||||
Key
|
||||
| ( modifier ? 0 : ( input::key_shift ? keymodifier::shift : 0 ) )
|
||||
| ( modifier ? 0 : ( input::key_ctrl ? keymodifier::control : 0 ) );
|
||||
| ( modifier ? 0 : input::key_shift ? keymodifier::shift : 0 )
|
||||
| ( modifier ? 0 : input::key_ctrl ? keymodifier::control : 0 );
|
||||
|
||||
if( Action == GLFW_RELEASE ) {
|
||||
auto const stored = m_modsforkeys.find( Key );
|
||||
@@ -333,10 +327,7 @@ keyboard_input::key( int const Key, int const Action ) {
|
||||
// as we haven't yet implemented either item id system or multiplayer, the 'local' controlled vehicle and entity have temporary ids of 0
|
||||
// TODO: pass correct entity id once the missing systems are in place
|
||||
m_relay.post( lookup->second, 0, 0, Action, 0 );
|
||||
m_command = (
|
||||
Action == GLFW_RELEASE ?
|
||||
user_command::none :
|
||||
lookup->second );
|
||||
m_command = Action == GLFW_RELEASE ? user_command::none : lookup->second;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -380,12 +371,7 @@ bool
|
||||
keyboard_input::is_movement_key( int const Key ) const {
|
||||
|
||||
bool const ismovementkey =
|
||||
( ( Key == m_bindingscache.forward )
|
||||
|| ( Key == m_bindingscache.back )
|
||||
|| ( Key == m_bindingscache.left )
|
||||
|| ( Key == m_bindingscache.right )
|
||||
|| ( Key == m_bindingscache.up )
|
||||
|| ( Key == m_bindingscache.down ) );
|
||||
Key == m_bindingscache.forward || Key == m_bindingscache.back || Key == m_bindingscache.left || Key == m_bindingscache.right || Key == m_bindingscache.up || Key == m_bindingscache.down;
|
||||
|
||||
return ismovementkey;
|
||||
}
|
||||
@@ -395,22 +381,20 @@ keyboard_input::poll() {
|
||||
|
||||
glm::vec2 const movementhorizontal {
|
||||
// x-axis
|
||||
( Global.shiftState ? 1.f : (2.0f / 3.0f) ) *
|
||||
( Global.shiftState ? 1.f : 2.0f / 3.0f ) *
|
||||
( input::keys[ m_bindingscache.left ] != GLFW_RELEASE ? -1.f :
|
||||
input::keys[ m_bindingscache.right ] != GLFW_RELEASE ? 1.f :
|
||||
0.f ),
|
||||
// z-axis
|
||||
( Global.shiftState ? 1.f : (2.0f / 3.0f) ) *
|
||||
( Global.shiftState ? 1.f : 2.0f / 3.0f ) *
|
||||
( input::keys[ m_bindingscache.forward ] != GLFW_RELEASE ? 1.f :
|
||||
input::keys[ m_bindingscache.back ] != GLFW_RELEASE ? -1.f :
|
||||
0.f ) };
|
||||
|
||||
if( ( movementhorizontal.x != 0.f || movementhorizontal.y != 0.f )
|
||||
|| ( m_movementhorizontal.x != 0.f || m_movementhorizontal.y != 0.f ) ) {
|
||||
if( movementhorizontal.x != 0.f || movementhorizontal.y != 0.f
|
||||
|| m_movementhorizontal.x != 0.f || m_movementhorizontal.y != 0.f ) {
|
||||
m_relay.post(
|
||||
( true == Global.ctrlState ?
|
||||
user_command::movehorizontalfast :
|
||||
user_command::movehorizontal ),
|
||||
true == Global.ctrlState ? user_command::movehorizontalfast : user_command::movehorizontal,
|
||||
movementhorizontal.x,
|
||||
movementhorizontal.y,
|
||||
GLFW_PRESS,
|
||||
@@ -421,17 +405,15 @@ keyboard_input::poll() {
|
||||
|
||||
float const movementvertical {
|
||||
// y-axis
|
||||
( Global.shiftState ? 1.f : (2.0f / 3.0f) ) *
|
||||
( Global.shiftState ? 1.f : 2.0f / 3.0f ) *
|
||||
( input::keys[ m_bindingscache.up ] != GLFW_RELEASE ? 1.f :
|
||||
input::keys[ m_bindingscache.down ] != GLFW_RELEASE ? -1.f :
|
||||
0.f ) };
|
||||
|
||||
if( ( movementvertical != 0.f )
|
||||
|| ( m_movementvertical != 0.f ) ) {
|
||||
if( movementvertical != 0.f
|
||||
|| m_movementvertical != 0.f ) {
|
||||
m_relay.post(
|
||||
( true == Global.ctrlState ?
|
||||
user_command::moveverticalfast :
|
||||
user_command::movevertical ),
|
||||
true == Global.ctrlState ? user_command::moveverticalfast : user_command::movevertical,
|
||||
movementvertical,
|
||||
0,
|
||||
GLFW_PRESS,
|
||||
|
||||
@@ -59,14 +59,14 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz)
|
||||
case 2: {
|
||||
// event
|
||||
CommLog( Now() + " " + std::to_string( pRozkaz->iComm ) + " " +
|
||||
std::string( pRozkaz->cString + 1, (unsigned)( pRozkaz->cString[ 0 ] ) ) + " rcvd" );
|
||||
std::string( pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0] ) + " rcvd" );
|
||||
|
||||
if( Global.iMultiplayer ) {
|
||||
auto *event = simulation::Events.FindEvent( std::string( pRozkaz->cString + 1, (unsigned)( pRozkaz->cString[ 0 ] ) ) );
|
||||
auto *event = simulation::Events.FindEvent( std::string( pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0] ) );
|
||||
if( event != nullptr ) {
|
||||
if( ( typeid( *event ) == typeid( multi_event ) )
|
||||
|| ( typeid( *event ) == typeid( lights_event ) )
|
||||
|| ( event->m_sibling != 0 ) ) {
|
||||
if( typeid(*event) == typeid(multi_event)
|
||||
|| typeid(*event) == typeid(lights_event)
|
||||
|| event->m_sibling != 0 ) {
|
||||
// tylko jawne albo niejawne Multiple
|
||||
command_relay relay;
|
||||
relay.post(user_command::queueevent, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &event->name());
|
||||
@@ -81,12 +81,12 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz)
|
||||
int i = int(pRozkaz->cString[8]); // długość pierwszego łańcucha (z przodu dwa floaty)
|
||||
CommLog(
|
||||
Now() + " " + std::to_string(pRozkaz->iComm) + " " +
|
||||
std::string(pRozkaz->cString + 11 + i, (unsigned)(pRozkaz->cString[10 + i])) +
|
||||
std::string(pRozkaz->cString + 11 + i, (unsigned)pRozkaz->cString[10 + i]) +
|
||||
" rcvd");
|
||||
// nazwa pojazdu jest druga
|
||||
auto *vehicle = simulation::Vehicles.find( { pRozkaz->cString + 11 + i, (unsigned)pRozkaz->cString[ 10 + i ] } );
|
||||
if( ( vehicle != nullptr )
|
||||
&& ( vehicle->Mechanik != nullptr ) ) {
|
||||
if( vehicle != nullptr
|
||||
&& vehicle->Mechanik != nullptr ) {
|
||||
vehicle->Mechanik->PutCommand(
|
||||
{ pRozkaz->cString + 9, static_cast<std::size_t>(i) },
|
||||
pRozkaz->fPar[0], pRozkaz->fPar[1],
|
||||
@@ -99,11 +99,11 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz)
|
||||
case 4: // badanie zajętości toru
|
||||
{
|
||||
CommLog(Now() + " " + std::to_string(pRozkaz->iComm) + " " +
|
||||
std::string(pRozkaz->cString + 1, (unsigned)(pRozkaz->cString[0])) + " rcvd");
|
||||
std::string(pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0]) + " rcvd");
|
||||
|
||||
auto *track = simulation::Paths.find( std::string( pRozkaz->cString + 1, (unsigned)( pRozkaz->cString[ 0 ] ) ) );
|
||||
if( ( track != nullptr )
|
||||
&& ( track->IsEmpty() ) ) {
|
||||
auto *track = simulation::Paths.find( std::string( pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0] ) );
|
||||
if( track != nullptr
|
||||
&& track->IsEmpty() ) {
|
||||
WyslijWolny( track->name() );
|
||||
}
|
||||
}
|
||||
@@ -134,14 +134,11 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz)
|
||||
CommLog(
|
||||
Now() + " "
|
||||
+ std::to_string( pRozkaz->iComm ) + " "
|
||||
+ std::string{ pRozkaz->cString + 1, (unsigned)( pRozkaz->cString[ 0 ] ) }
|
||||
+ std::string{ pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0] }
|
||||
+ " rcvd" );
|
||||
if (pRozkaz->cString[0]) {
|
||||
// jeśli długość nazwy jest niezerowa szukamy pierwszego pojazdu o takiej nazwie i odsyłamy parametry ramką #7
|
||||
auto *vehicle = (
|
||||
pRozkaz->cString[ 1 ] == '*' ?
|
||||
simulation::Train->Dynamic() :
|
||||
simulation::Vehicles.find( std::string{ pRozkaz->cString + 1, (unsigned)pRozkaz->cString[ 0 ] } ) );
|
||||
auto *vehicle = pRozkaz->cString[1] == '*' ? simulation::Train->Dynamic() : simulation::Vehicles.find(std::string{pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0]});
|
||||
if( vehicle != nullptr ) {
|
||||
WyslijNamiary( vehicle ); // wysłanie informacji o pojeździe
|
||||
}
|
||||
@@ -162,8 +159,8 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz)
|
||||
break;
|
||||
case 10: // badanie zajętości jednego odcinka izolowanego
|
||||
CommLog(Now() + " " + std::to_string(pRozkaz->iComm) + " " +
|
||||
std::string(pRozkaz->cString + 1, (unsigned)(pRozkaz->cString[0])) + " rcvd");
|
||||
simulation::Paths.IsolatedBusy( std::string( pRozkaz->cString + 1, (unsigned)( pRozkaz->cString[ 0 ] ) ) );
|
||||
std::string(pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0]) + " rcvd");
|
||||
simulation::Paths.IsolatedBusy( std::string( pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0] ) );
|
||||
break;
|
||||
case 11: // ustawienie parametrów ruchu pojazdu
|
||||
// Ground.IsolatedBusy(AnsiString(pRozkaz->cString+1,(unsigned)(pRozkaz->cString[0])));
|
||||
@@ -175,14 +172,12 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz)
|
||||
break;
|
||||
case 13: // ramka uszkodzenia i innych stanow pojazdu, np. wylaczenie CA, wlaczenie recznego itd.
|
||||
CommLog(Now() + " " + std::to_string(pRozkaz->iComm) + " " +
|
||||
std::string(pRozkaz->cString + 1, (unsigned)(pRozkaz->cString[0])) +
|
||||
std::string(pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0]) +
|
||||
" rcvd");
|
||||
if( pRozkaz->cString[ 1 ] ) // jeśli długość nazwy jest niezerowa
|
||||
{ // szukamy pierwszego pojazdu o takiej nazwie i odsyłamy parametry ramką #13
|
||||
auto *lookup = (
|
||||
pRozkaz->cString[ 2 ] == '*' ?
|
||||
simulation::Train->Dynamic() : // nazwa pojazdu użytkownika
|
||||
simulation::Vehicles.find( std::string( pRozkaz->cString + 2, (unsigned)pRozkaz->cString[ 1 ] ) ) ); // nazwa pojazdu
|
||||
auto *lookup = pRozkaz->cString[2] == '*' ? simulation::Train->Dynamic() : // nazwa pojazdu użytkownika
|
||||
simulation::Vehicles.find(std::string(pRozkaz->cString + 2, (unsigned)pRozkaz->cString[1])); // nazwa pojazdu
|
||||
if( lookup == nullptr ) { break; } // nothing found, nothing to do
|
||||
auto *d { lookup };
|
||||
while( d != nullptr ) {
|
||||
|
||||
@@ -26,7 +26,7 @@ float zmq_input::unpack_float(const zmq::message_t &msg) {
|
||||
return 0.0f;
|
||||
|
||||
uint8_t *buf = (uint8_t*)msg.data();
|
||||
uint32_t v = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];
|
||||
uint32_t v = buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3];
|
||||
return reinterpret_cast<float&>(v);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ void zmq_input::poll()
|
||||
continue;
|
||||
|
||||
uint8_t* buf = (uint8_t*)multipart[0].data();
|
||||
uint32_t peer_id = (buf[1] << 24) | (buf[2] << 16) | (buf[3] << 8) | buf[4];
|
||||
uint32_t peer_id = buf[1] << 24 | buf[2] << 16 | buf[3] << 8 | buf[4];
|
||||
|
||||
auto peer_it = peers.find(peer_id);
|
||||
if (peer_it == peers.end()) {
|
||||
@@ -139,8 +139,8 @@ void zmq_input::poll()
|
||||
else if (type == input_type::none)
|
||||
continue;
|
||||
|
||||
bool state = (value > 0.5f);
|
||||
bool changed = (state != std::get<3>(entry));
|
||||
bool state = value > 0.5f;
|
||||
bool changed = state != std::get<3>(entry);
|
||||
|
||||
if (!changed)
|
||||
continue;
|
||||
@@ -148,16 +148,12 @@ void zmq_input::poll()
|
||||
auto const action { (
|
||||
type != input_type::impulse ?
|
||||
GLFW_PRESS :
|
||||
( state ?
|
||||
GLFW_PRESS :
|
||||
GLFW_RELEASE ) ) };
|
||||
state ? GLFW_PRESS : GLFW_RELEASE) };
|
||||
|
||||
auto const command { (
|
||||
type != input_type::toggle ?
|
||||
std::get<1>( entry ) :
|
||||
( state ?
|
||||
std::get<1>( entry ) :
|
||||
std::get<2>( entry ) ) ) };
|
||||
state ? std::get<1>(entry) : std::get<2>(entry) ) };
|
||||
|
||||
std::get<3>(entry) = state;
|
||||
|
||||
@@ -181,7 +177,7 @@ void zmq_input::poll()
|
||||
continue;
|
||||
}
|
||||
|
||||
uint8_t peerbuf[5] = { 0, (uint8_t)(peer->first >> 24), (uint8_t)(peer->first >> 16), (uint8_t)(peer->first >> 8), (uint8_t)(peer->first) };
|
||||
uint8_t peerbuf[5] = { 0, (uint8_t)(peer->first >> 24), (uint8_t)(peer->first >> 16), (uint8_t)(peer->first >> 8), (uint8_t)peer->first };
|
||||
zmq::multipart_t msg;
|
||||
|
||||
msg.addmem(peerbuf, sizeof(peerbuf));
|
||||
|
||||
Reference in New Issue
Block a user