mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 18:39:18 +02:00
maintenance: minor code cleanup
This commit is contained in:
30
Camera.cpp
30
Camera.cpp
@@ -31,27 +31,29 @@ void TCamera::Init(vector3 NPos, vector3 NAngle)
|
|||||||
Type = (Global::bFreeFly ? tp_Free : tp_Follow);
|
Type = (Global::bFreeFly ? tp_Free : tp_Follow);
|
||||||
};
|
};
|
||||||
|
|
||||||
void TCamera::OnCursorMove(double x, double y)
|
void TCamera::OnCursorMove(double x, double y) {
|
||||||
{
|
|
||||||
// McZapkie-170402: zeby mysz dzialala zawsze if (Type==tp_Follow)
|
|
||||||
Yaw -= x;
|
Yaw -= x;
|
||||||
Pitch -= y;
|
while( Yaw > M_PI ) {
|
||||||
if (Yaw > M_PI)
|
|
||||||
Yaw -= 2 * M_PI;
|
Yaw -= 2 * M_PI;
|
||||||
else if (Yaw < -M_PI)
|
}
|
||||||
|
while( Yaw < -M_PI ) {
|
||||||
Yaw += 2 * M_PI;
|
Yaw += 2 * M_PI;
|
||||||
if (Type == tp_Follow) // jeżeli jazda z pojazdem
|
}
|
||||||
{
|
Pitch -= y;
|
||||||
clamp(Pitch, -M_PI_4, M_PI_4); // ograniczenie kąta spoglądania w dół i w górę
|
if (Type == tp_Follow) {
|
||||||
|
// jeżeli jazda z pojazdem ograniczenie kąta spoglądania w dół i w górę
|
||||||
|
Pitch = clamp( Pitch, -M_PI_4, M_PI_4 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
bool
|
||||||
TCamera::OnCommand( command_data const &Command ) {
|
TCamera::OnCommand( command_data const &Command ) {
|
||||||
|
|
||||||
auto const walkspeed { 1.0 };
|
auto const walkspeed { 1.0 };
|
||||||
auto const runspeed { 7.5 };
|
auto const runspeed { 7.5 };
|
||||||
|
|
||||||
|
bool iscameracommand { true };
|
||||||
switch( Command.command ) {
|
switch( Command.command ) {
|
||||||
|
|
||||||
case user_command::viewturn: {
|
case user_command::viewturn: {
|
||||||
@@ -122,7 +124,15 @@ TCamera::OnCommand( command_data const &Command ) {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default: {
|
||||||
|
|
||||||
|
iscameracommand = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
} // switch
|
} // switch
|
||||||
|
|
||||||
|
return iscameracommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TCamera::Update()
|
void TCamera::Update()
|
||||||
|
|||||||
2
Camera.h
2
Camera.h
@@ -42,7 +42,7 @@ class TCamera
|
|||||||
void Reset() {
|
void Reset() {
|
||||||
Pitch = Yaw = Roll = 0; };
|
Pitch = Yaw = Roll = 0; };
|
||||||
void OnCursorMove(double const x, double const y);
|
void OnCursorMove(double const x, double const y);
|
||||||
void OnCommand( command_data const &Command );
|
bool OnCommand( command_data const &Command );
|
||||||
void Update();
|
void Update();
|
||||||
vector3 GetDirection();
|
vector3 GetDirection();
|
||||||
bool SetMatrix(glm::dmat4 &Matrix);
|
bool SetMatrix(glm::dmat4 &Matrix);
|
||||||
|
|||||||
@@ -7598,6 +7598,11 @@ void TMoverParameters::LoadFIZ_DList( std::string const &Input ) {
|
|||||||
extract_value( dizel_nmax, "nmax", Input, "" );
|
extract_value( dizel_nmax, "nmax", Input, "" );
|
||||||
extract_value( dizel_nominalfill, "nominalfill", Input, "" );
|
extract_value( dizel_nominalfill, "nominalfill", Input, "" );
|
||||||
extract_value( dizel_Mstand, "Mstand", Input, "" );
|
extract_value( dizel_Mstand, "Mstand", Input, "" );
|
||||||
|
|
||||||
|
if( dizel_nMmax == dizel_nmax ) {
|
||||||
|
// HACK: guard against cases where nMmax == nmax, leading to division by 0 in momentum calculation
|
||||||
|
dizel_nMmax = dizel_nmax - 1.0 / 60.0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TMoverParameters::LoadFIZ_FFList( std::string const &Input ) {
|
void TMoverParameters::LoadFIZ_FFList( std::string const &Input ) {
|
||||||
|
|||||||
36
Train.cpp
36
Train.cpp
@@ -5903,42 +5903,6 @@ TTrain::radio_message( sound_source *Message, int const Channel ) {
|
|||||||
.play( sound_flags::exclusive );
|
.play( sound_flags::exclusive );
|
||||||
}
|
}
|
||||||
|
|
||||||
void TTrain::Silence()
|
|
||||||
{ // wyciszenie dźwięków przy wychodzeniu
|
|
||||||
#ifdef EU07_USE_OLD_SOUNDCODE
|
|
||||||
dsbNastawnikJazdy.Stop();
|
|
||||||
dsbNastawnikBocz.Stop();
|
|
||||||
dsbRelay.Stop();
|
|
||||||
dsbPneumaticRelay.Stop();
|
|
||||||
dsbSwitch.Stop();
|
|
||||||
dsbPneumaticSwitch.Stop();
|
|
||||||
dsbReverserKey.Stop();
|
|
||||||
dsbCouplerAttach.Stop();
|
|
||||||
dsbCouplerDetach.Stop();
|
|
||||||
dsbDieselIgnition.Stop();
|
|
||||||
dsbWejscie_na_bezoporow.Stop();
|
|
||||||
dsbWejscie_na_drugi_uklad.Stop();
|
|
||||||
rsBrake.Stop();
|
|
||||||
rsSlippery.Stop();
|
|
||||||
rsHiss.Stop();
|
|
||||||
rsHissU.Stop();
|
|
||||||
rsHissE.Stop();
|
|
||||||
rsHissX.Stop();
|
|
||||||
rsHissT.Stop();
|
|
||||||
rsSBHiss.Stop();
|
|
||||||
rsRunningNoise.Stop();
|
|
||||||
rsEngageSlippery.Stop();
|
|
||||||
rsFadeSound.Stop();
|
|
||||||
dsbHasler.Stop(); // wyłączenie dźwięków opuszczanej kabiny
|
|
||||||
dsbBuzzer.Stop();
|
|
||||||
dsbSlipAlarm.Stop(); // dźwięk alarmu przy poślizgu
|
|
||||||
// sConverter.Stop();
|
|
||||||
// sSmallCompressor->Stop();
|
|
||||||
dsbCouplerStretch.Stop();
|
|
||||||
dsbBufferClamp.Stop();
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
void TTrain::SetLights()
|
void TTrain::SetLights()
|
||||||
{
|
{
|
||||||
TDynamicObject *p = DynamicObject->GetFirstDynamic(mvOccupied->ActiveCab < 0 ? 1 : 0, 4);
|
TDynamicObject *p = DynamicObject->GetFirstDynamic(mvOccupied->ActiveCab < 0 ? 1 : 0, 4);
|
||||||
|
|||||||
1
Train.h
1
Train.h
@@ -492,7 +492,6 @@ private:
|
|||||||
inline TMoverParameters *Controlled() { return mvControlled; };
|
inline TMoverParameters *Controlled() { return mvControlled; };
|
||||||
inline TMoverParameters const *Controlled() const { return mvControlled; };
|
inline TMoverParameters const *Controlled() const { return mvControlled; };
|
||||||
void DynamicSet(TDynamicObject *d);
|
void DynamicSet(TDynamicObject *d);
|
||||||
void Silence();
|
|
||||||
|
|
||||||
};
|
};
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|||||||
117
World.cpp
117
World.cpp
@@ -512,9 +512,7 @@ void TWorld::OnKeyDown(int cKey)
|
|||||||
// works always in debug mode, or for stopped/slow moving vehicles otherwise
|
// works always in debug mode, or for stopped/slow moving vehicles otherwise
|
||||||
Controlled = tmp; // przejmujemy nowy
|
Controlled = tmp; // przejmujemy nowy
|
||||||
mvControlled = Controlled->ControlledFind()->MoverParameters;
|
mvControlled = Controlled->ControlledFind()->MoverParameters;
|
||||||
if( Train )
|
if( Train == nullptr )
|
||||||
Train->Silence(); // wyciszenie dźwięków opuszczanego pojazdu
|
|
||||||
else
|
|
||||||
Train = new TTrain(); // jeśli niczym jeszcze nie jeździlismy
|
Train = new TTrain(); // jeśli niczym jeszcze nie jeździlismy
|
||||||
if( Train->Init( Controlled ) ) { // przejmujemy sterowanie
|
if( Train->Init( Controlled ) ) { // przejmujemy sterowanie
|
||||||
if( !DebugModeFlag ) // w DebugMode nadal prowadzi AI
|
if( !DebugModeFlag ) // w DebugMode nadal prowadzi AI
|
||||||
@@ -646,11 +644,15 @@ void TWorld::OnKeyDown(int cKey)
|
|||||||
if( Controlled->MoverParameters->Radio )
|
if( Controlled->MoverParameters->Radio )
|
||||||
simulation::Region->RadioStop( Camera.Pos );
|
simulation::Region->RadioStop( Camera.Pos );
|
||||||
}
|
}
|
||||||
else if (!Global::iPause) //||(cKey==VK_F4)) //podczas pauzy sterownaie nie działa, F4 tak
|
else if (!Global::iPause) //podczas pauzy sterownaie nie działa
|
||||||
if (Train)
|
if (Train)
|
||||||
if (Controlled)
|
if (Controlled)
|
||||||
if ((Controlled->Controller == Humandriver) ? true : DebugModeFlag || (cKey == GLFW_KEY_Q))
|
if( ( cKey == GLFW_KEY_Q )
|
||||||
Train->OnKeyDown(cKey); // przekazanie klawisza do kabiny
|
|| ( ( Controlled->Controller == Humandriver )
|
||||||
|
|| ( true == DebugModeFlag ) ) ) {
|
||||||
|
Train->OnKeyDown( cKey ); // przekazanie klawisza do kabiny
|
||||||
|
}
|
||||||
|
|
||||||
if (FreeFlyModeFlag) // aby nie odluźniało wagonu za lokomotywą
|
if (FreeFlyModeFlag) // aby nie odluźniało wagonu za lokomotywą
|
||||||
{ // operacje wykonywane na dowolnym pojeździe, przeniesione tu z kabiny
|
{ // operacje wykonywane na dowolnym pojeździe, przeniesione tu z kabiny
|
||||||
/*
|
/*
|
||||||
@@ -659,17 +661,12 @@ void TWorld::OnKeyDown(int cKey)
|
|||||||
if (cKey == Global::Keys[k_Releaser]) // odluźniacz
|
if (cKey == Global::Keys[k_Releaser]) // odluźniacz
|
||||||
{ // działa globalnie, sprawdzić zasięg
|
{ // działa globalnie, sprawdzić zasięg
|
||||||
TDynamicObject *temp = Global::DynamicNearest();
|
TDynamicObject *temp = Global::DynamicNearest();
|
||||||
if (temp)
|
if (temp) {
|
||||||
{
|
if (Global::ctrlState) // z ctrl odcinanie {
|
||||||
if (Global::ctrlState) // z ctrl odcinanie
|
|
||||||
{
|
|
||||||
temp->MoverParameters->Hamulec->SetBrakeStatus( temp->MoverParameters->Hamulec->GetBrakeStatus() ^ 128 );
|
temp->MoverParameters->Hamulec->SetBrakeStatus( temp->MoverParameters->Hamulec->GetBrakeStatus() ^ 128 );
|
||||||
}
|
}
|
||||||
else if (temp->MoverParameters->BrakeReleaser(1))
|
else {
|
||||||
{
|
temp->MoverParameters->BrakeReleaser(1);
|
||||||
// temp->sBrakeAcc->
|
|
||||||
// dsbPneumaticRelay->SetVolume(DSBVOLUME_MAX);
|
|
||||||
// dsbPneumaticRelay->Play(0,0,0); //temp->Position()-Camera.Pos //???
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -722,20 +719,14 @@ void TWorld::OnKeyDown(int cKey)
|
|||||||
auto *vehicle { std::get<TDynamicObject *>( simulation::Region->find_vehicle( Global::pCameraPosition, 10, false, false ) ) };
|
auto *vehicle { std::get<TDynamicObject *>( simulation::Region->find_vehicle( Global::pCameraPosition, 10, false, false ) ) };
|
||||||
if (vehicle)
|
if (vehicle)
|
||||||
{
|
{
|
||||||
if (Global::ctrlState)
|
if( Global::ctrlState ) {
|
||||||
if ((vehicle->MoverParameters->LocalBrake == ManualBrake) ||
|
if( ( vehicle->MoverParameters->LocalBrake == ManualBrake )
|
||||||
(vehicle->MoverParameters->MBrake == true))
|
|| ( vehicle->MoverParameters->MBrake == true ) )
|
||||||
vehicle->MoverParameters->IncManualBrakeLevel(1);
|
vehicle->MoverParameters->IncManualBrakeLevel( 1 );
|
||||||
else
|
}
|
||||||
;
|
else if( vehicle->MoverParameters->LocalBrake != ManualBrake ) {
|
||||||
else if (vehicle->MoverParameters->LocalBrake != ManualBrake)
|
vehicle->MoverParameters->IncLocalBrakeLevelFAST();
|
||||||
if (vehicle->MoverParameters->IncLocalBrakeLevelFAST())
|
}
|
||||||
if (Train)
|
|
||||||
{ // dźwięk oczywiście jest w kabinie
|
|
||||||
#ifdef EU07_USE_OLD_SOUNDCODE
|
|
||||||
Train->dsbPneumaticRelay.play();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (cKey == Global::Keys[k_DecLocalBrakeLevel])
|
else if (cKey == Global::Keys[k_DecLocalBrakeLevel])
|
||||||
@@ -743,30 +734,19 @@ void TWorld::OnKeyDown(int cKey)
|
|||||||
auto *vehicle { std::get<TDynamicObject *>( simulation::Region->find_vehicle( Global::pCameraPosition, 10, false, false ) ) };
|
auto *vehicle { std::get<TDynamicObject *>( simulation::Region->find_vehicle( Global::pCameraPosition, 10, false, false ) ) };
|
||||||
if (vehicle)
|
if (vehicle)
|
||||||
{
|
{
|
||||||
if (Global::ctrlState)
|
if( Global::ctrlState ) {
|
||||||
if ((vehicle->MoverParameters->LocalBrake == ManualBrake) ||
|
if( ( vehicle->MoverParameters->LocalBrake == ManualBrake )
|
||||||
(vehicle->MoverParameters->MBrake == true))
|
|| ( vehicle->MoverParameters->MBrake == true ) )
|
||||||
vehicle->MoverParameters->DecManualBrakeLevel(1);
|
vehicle->MoverParameters->DecManualBrakeLevel( 1 );
|
||||||
else
|
}
|
||||||
;
|
else if( vehicle->MoverParameters->LocalBrake != ManualBrake ) {
|
||||||
else if (vehicle->MoverParameters->LocalBrake != ManualBrake)
|
vehicle->MoverParameters->DecLocalBrakeLevelFAST();
|
||||||
if (vehicle->MoverParameters->DecLocalBrakeLevelFAST())
|
}
|
||||||
if (Train)
|
|
||||||
{ // dźwięk oczywiście jest w kabinie
|
|
||||||
#ifdef EU07_USE_OLD_SOUNDCODE
|
|
||||||
Train->dsbPneumaticRelay.play();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TWorld::OnMouseMove(double x, double y)
|
|
||||||
{ // McZapkie:060503-definicja obracania myszy
|
|
||||||
Camera.OnCursorMove(x * Global::fMouseXScale / Global::ZoomFactor, -y * Global::fMouseYScale / Global::ZoomFactor);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TWorld::InOutKey( bool const Near )
|
void TWorld::InOutKey( bool const Near )
|
||||||
{ // przełączenie widoku z kabiny na zewnętrzny i odwrotnie
|
{ // przełączenie widoku z kabiny na zewnętrzny i odwrotnie
|
||||||
FreeFlyModeFlag = !FreeFlyModeFlag; // zmiana widoku
|
FreeFlyModeFlag = !FreeFlyModeFlag; // zmiana widoku
|
||||||
@@ -775,8 +755,6 @@ void TWorld::InOutKey( bool const Near )
|
|||||||
if (Train) {
|
if (Train) {
|
||||||
// cache current cab position so there's no need to set it all over again after each out-in switch
|
// cache current cab position so there's no need to set it all over again after each out-in switch
|
||||||
Train->pMechSittingPosition = Train->pMechOffset;
|
Train->pMechSittingPosition = Train->pMechOffset;
|
||||||
// wyłączenie dźwięków kabiny
|
|
||||||
Train->Silence();
|
|
||||||
Train->Dynamic()->bDisplayCab = false;
|
Train->Dynamic()->bDisplayCab = false;
|
||||||
DistantView( Near );
|
DistantView( Near );
|
||||||
}
|
}
|
||||||
@@ -2101,26 +2079,28 @@ void TWorld::CabChange(TDynamicObject *old, TDynamicObject *now)
|
|||||||
void TWorld::ChangeDynamic() {
|
void TWorld::ChangeDynamic() {
|
||||||
|
|
||||||
// Ra: to nie może być tak robione, to zbytnia proteza jest
|
// Ra: to nie może być tak robione, to zbytnia proteza jest
|
||||||
Train->Silence(); // wyłączenie dźwięków opuszczanej kabiny
|
if( Train->Dynamic()->Mechanik ) {
|
||||||
if( Train->Dynamic()->Mechanik ) // AI może sobie samo pójść
|
// AI może sobie samo pójść
|
||||||
if( !Train->Dynamic()->Mechanik->AIControllFlag ) // tylko jeśli ręcznie prowadzony
|
if( false == Train->Dynamic()->Mechanik->AIControllFlag ) {
|
||||||
{ // jeśli prowadzi AI, to mu nie robimy dywersji!
|
// tylko jeśli ręcznie prowadzony
|
||||||
|
// jeśli prowadzi AI, to mu nie robimy dywersji!
|
||||||
Train->Dynamic()->MoverParameters->CabDeactivisation();
|
Train->Dynamic()->MoverParameters->CabDeactivisation();
|
||||||
Train->Dynamic()->Controller = AIdriver;
|
Train->Dynamic()->Controller = AIdriver;
|
||||||
// Train->Dynamic()->MoverParameters->SecuritySystem.Status=0; //rozwala CA w EZT
|
|
||||||
Train->Dynamic()->MoverParameters->ActiveCab = 0;
|
Train->Dynamic()->MoverParameters->ActiveCab = 0;
|
||||||
Train->Dynamic()->MoverParameters->BrakeLevelSet(
|
Train->Dynamic()->MoverParameters->BrakeLevelSet( Train->Dynamic()->MoverParameters->Handle->GetPos( bh_NP ) ); //rozwala sterowanie hamulcem GF 04-2016
|
||||||
Train->Dynamic()->MoverParameters->Handle->GetPos(
|
|
||||||
bh_NP ) ); //rozwala sterowanie hamulcem GF 04-2016
|
|
||||||
Train->Dynamic()->MechInside = false;
|
Train->Dynamic()->MechInside = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
TDynamicObject *temp = Global::changeDynObj;
|
TDynamicObject *temp = Global::changeDynObj;
|
||||||
Train->Dynamic()->bDisplayCab = false;
|
Train->Dynamic()->bDisplayCab = false;
|
||||||
Train->Dynamic()->ABuSetModelShake( vector3( 0, 0, 0 ) );
|
Train->Dynamic()->ABuSetModelShake( {} );
|
||||||
|
|
||||||
if( Train->Dynamic()->Mechanik ) // AI może sobie samo pójść
|
if( Train->Dynamic()->Mechanik ) // AI może sobie samo pójść
|
||||||
if( !Train->Dynamic()->Mechanik->AIControllFlag ) // tylko jeśli ręcznie prowadzony
|
if( false == Train->Dynamic()->Mechanik->AIControllFlag ) {
|
||||||
Train->Dynamic()->Mechanik->MoveTo( temp ); // przsunięcie obiektu zarządzającego
|
// tylko jeśli ręcznie prowadzony
|
||||||
|
// przsunięcie obiektu zarządzającego
|
||||||
|
Train->Dynamic()->Mechanik->MoveTo( temp );
|
||||||
|
}
|
||||||
|
|
||||||
Train->DynamicSet( temp );
|
Train->DynamicSet( temp );
|
||||||
Controlled = temp;
|
Controlled = temp;
|
||||||
@@ -2129,20 +2109,17 @@ void TWorld::ChangeDynamic() {
|
|||||||
if( Train->Dynamic()->Mechanik ) // AI może sobie samo pójść
|
if( Train->Dynamic()->Mechanik ) // AI może sobie samo pójść
|
||||||
if( !Train->Dynamic()->Mechanik->AIControllFlag ) // tylko jeśli ręcznie prowadzony
|
if( !Train->Dynamic()->Mechanik->AIControllFlag ) // tylko jeśli ręcznie prowadzony
|
||||||
{
|
{
|
||||||
Train->Dynamic()->MoverParameters->LimPipePress =
|
Train->Dynamic()->MoverParameters->LimPipePress = Controlled->MoverParameters->PipePress;
|
||||||
Controlled->MoverParameters->PipePress;
|
Train->Dynamic()->MoverParameters->CabActivisation(); // załączenie rozrządu (wirtualne kabiny)
|
||||||
Train->Dynamic()
|
|
||||||
->MoverParameters->CabActivisation(); // załączenie rozrządu (wirtualne kabiny)
|
|
||||||
Train->Dynamic()->Controller = Humandriver;
|
Train->Dynamic()->Controller = Humandriver;
|
||||||
Train->Dynamic()->MechInside = true;
|
Train->Dynamic()->MechInside = true;
|
||||||
}
|
}
|
||||||
Train->InitializeCab( Train->Dynamic()->MoverParameters->CabNo,
|
Train->InitializeCab(
|
||||||
Train->Dynamic()->asBaseDir +
|
Train->Dynamic()->MoverParameters->CabNo,
|
||||||
Train->Dynamic()->MoverParameters->TypeName + ".mmd" );
|
Train->Dynamic()->asBaseDir + Train->Dynamic()->MoverParameters->TypeName + ".mmd" );
|
||||||
if( !FreeFlyModeFlag ) {
|
if( !FreeFlyModeFlag ) {
|
||||||
Train->Dynamic()->bDisplayCab = true;
|
Train->Dynamic()->bDisplayCab = true;
|
||||||
Train->Dynamic()->ABuSetModelShake(
|
Train->Dynamic()->ABuSetModelShake( {} ); // zerowanie przesunięcia przed powrotem?
|
||||||
vector3( 0, 0, 0 ) ); // zerowanie przesunięcia przed powrotem?
|
|
||||||
Train->MechStop();
|
Train->MechStop();
|
||||||
FollowView(); // na pozycję mecha
|
FollowView(); // na pozycję mecha
|
||||||
}
|
}
|
||||||
|
|||||||
1
World.h
1
World.h
@@ -100,7 +100,6 @@ TWorld();
|
|||||||
bool InitPerformed() { return m_init; }
|
bool InitPerformed() { return m_init; }
|
||||||
bool Update();
|
bool Update();
|
||||||
void OnKeyDown( int cKey );
|
void OnKeyDown( int cKey );
|
||||||
void OnMouseMove( double x, double y );
|
|
||||||
void OnCommandGet( multiplayer::DaneRozkaz *pRozkaz );
|
void OnCommandGet( multiplayer::DaneRozkaz *pRozkaz );
|
||||||
// passes specified sound to all vehicles within range as a radio message broadcasted on specified channel
|
// passes specified sound to all vehicles within range as a radio message broadcasted on specified channel
|
||||||
void radio_message( sound_source *Message, int const Channel );
|
void radio_message( sound_source *Message, int const Channel );
|
||||||
|
|||||||
@@ -66,9 +66,7 @@ commanddescription_sequence Commands_descriptions = {
|
|||||||
{ "hornhighactivate", command_target::vehicle },
|
{ "hornhighactivate", command_target::vehicle },
|
||||||
{ "radiotoggle", command_target::vehicle },
|
{ "radiotoggle", command_target::vehicle },
|
||||||
{ "radiostoptest", command_target::vehicle },
|
{ "radiostoptest", command_target::vehicle },
|
||||||
/*
|
|
||||||
const int k_FailedEngineCutOff = 35;
|
|
||||||
*/
|
|
||||||
{ "viewturn", command_target::entity },
|
{ "viewturn", command_target::entity },
|
||||||
{ "movehorizontal", command_target::entity },
|
{ "movehorizontal", command_target::entity },
|
||||||
{ "movehorizontalfast", command_target::entity },
|
{ "movehorizontalfast", command_target::entity },
|
||||||
|
|||||||
@@ -61,9 +61,7 @@ enum class user_command {
|
|||||||
hornhighactivate,
|
hornhighactivate,
|
||||||
radiotoggle,
|
radiotoggle,
|
||||||
radiostoptest,
|
radiostoptest,
|
||||||
/*
|
|
||||||
const int k_FailedEngineCutOff = 35;
|
|
||||||
*/
|
|
||||||
viewturn,
|
viewturn,
|
||||||
movehorizontal,
|
movehorizontal,
|
||||||
movehorizontalfast,
|
movehorizontalfast,
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ keyboard_input::key( int const Key, int const Action ) {
|
|||||||
m_keys[ Key ] = Action;
|
m_keys[ Key ] = Action;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( true == update_movement( Key, Action ) ) {
|
if( true == is_movement_key( Key ) ) {
|
||||||
// if the received key was one of movement keys, it's been handled and we don't need to bother further
|
// if the received key was one of movement keys, it's been handled and we don't need to bother further
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -350,10 +350,6 @@ const int k_ProgramHelp = 48;
|
|||||||
// instrumentlighttoggle
|
// instrumentlighttoggle
|
||||||
{ GLFW_KEY_SEMICOLON },
|
{ GLFW_KEY_SEMICOLON },
|
||||||
/*
|
/*
|
||||||
const int k_Univ1 = 66;
|
|
||||||
const int k_Univ2 = 67;
|
|
||||||
const int k_Univ3 = 68;
|
|
||||||
const int k_Univ4 = 69;
|
|
||||||
const int k_EndSign = 70;
|
const int k_EndSign = 70;
|
||||||
const int k_Active = 71;
|
const int k_Active = 71;
|
||||||
*/
|
*/
|
||||||
@@ -403,8 +399,7 @@ keyboard_input::bind() {
|
|||||||
}
|
}
|
||||||
++commandcode;
|
++commandcode;
|
||||||
}
|
}
|
||||||
|
// cache movement key bindings
|
||||||
// cache movement key bindings, so we can test them faster in the input loop
|
|
||||||
m_bindingscache.forward = m_commands[ static_cast<std::size_t>( user_command::moveforward ) ].binding;
|
m_bindingscache.forward = m_commands[ static_cast<std::size_t>( user_command::moveforward ) ].binding;
|
||||||
m_bindingscache.back = m_commands[ static_cast<std::size_t>( user_command::moveback ) ].binding;
|
m_bindingscache.back = m_commands[ static_cast<std::size_t>( user_command::moveback ) ].binding;
|
||||||
m_bindingscache.left = m_commands[ static_cast<std::size_t>( user_command::moveleft ) ].binding;
|
m_bindingscache.left = m_commands[ static_cast<std::size_t>( user_command::moveleft ) ].binding;
|
||||||
@@ -413,11 +408,10 @@ keyboard_input::bind() {
|
|||||||
m_bindingscache.down = m_commands[ static_cast<std::size_t>( user_command::movedown ) ].binding;
|
m_bindingscache.down = m_commands[ static_cast<std::size_t>( user_command::movedown ) ].binding;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: ugliest code ever, gg
|
|
||||||
bool
|
bool
|
||||||
keyboard_input::update_movement( int const Key, int const Action ) {
|
keyboard_input::is_movement_key( int const Key ) const {
|
||||||
|
|
||||||
bool const movementkey =
|
bool const ismovementkey =
|
||||||
( ( Key == m_bindingscache.forward )
|
( ( Key == m_bindingscache.forward )
|
||||||
|| ( Key == m_bindingscache.back )
|
|| ( Key == m_bindingscache.back )
|
||||||
|| ( Key == m_bindingscache.left )
|
|| ( Key == m_bindingscache.left )
|
||||||
@@ -425,7 +419,7 @@ keyboard_input::update_movement( int const Key, int const Action ) {
|
|||||||
|| ( Key == m_bindingscache.up )
|
|| ( Key == m_bindingscache.up )
|
||||||
|| ( Key == m_bindingscache.down ) );
|
|| ( Key == m_bindingscache.down ) );
|
||||||
|
|
||||||
return ( true == movementkey );
|
return ismovementkey;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ private:
|
|||||||
void
|
void
|
||||||
bind();
|
bind();
|
||||||
bool
|
bool
|
||||||
update_movement( int const Key, int const Action );
|
is_movement_key( int const Key ) const;
|
||||||
|
|
||||||
// members
|
// members
|
||||||
commandsetup_sequence m_commands;
|
commandsetup_sequence m_commands;
|
||||||
|
|||||||
Reference in New Issue
Block a user