mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 01:59:19 +02:00
custom sounds for cab controls configurable on per-item basis
This commit is contained in:
@@ -1717,7 +1717,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424"
|
||||
if (ConversionError == -8)
|
||||
ErrorLog("Missed file: " + BaseDir + "\\" + Type_Name + ".fiz");
|
||||
Error("Cannot load dynamic object " + asName + " from:\r\n" + BaseDir + "\\" + Type_Name +
|
||||
".fiz\r\nError " + to_string(ConversionError) + " in line " + to_string(LineCount));
|
||||
".fiz\r\nError " + to_string(ConversionError));
|
||||
return 0.0; // zerowa długość to brak pojazdu
|
||||
}
|
||||
bool driveractive = (fVel != 0.0); // jeśli prędkość niezerowa, to aktywujemy ruch
|
||||
|
||||
@@ -21,8 +21,8 @@ class TFadeSound
|
||||
fTime = 0.0f;
|
||||
TSoundState State = ss_Off;
|
||||
|
||||
public:
|
||||
TFadeSound();
|
||||
public:
|
||||
TFadeSound() = default;
|
||||
~TFadeSound();
|
||||
void Init(std::string const &Name, float fNewFade);
|
||||
void TurnOn();
|
||||
|
||||
190
Gauge.cpp
190
Gauge.cpp
@@ -20,31 +20,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "Timer.h"
|
||||
#include "logs.h"
|
||||
|
||||
TGauge::TGauge()
|
||||
{
|
||||
eType = gt_Unknown;
|
||||
fFriction = 0.0;
|
||||
fDesiredValue = 0.0;
|
||||
fValue = 0.0;
|
||||
fOffset = 0.0;
|
||||
fScale = 1.0;
|
||||
fStepSize = 5;
|
||||
// iChannel=-1; //kanał analogowej komunikacji zwrotnej
|
||||
SubModel = NULL;
|
||||
};
|
||||
|
||||
TGauge::~TGauge(){};
|
||||
|
||||
void TGauge::Clear()
|
||||
{
|
||||
SubModel = NULL;
|
||||
eType = gt_Unknown;
|
||||
fValue = 0;
|
||||
fDesiredValue = 0;
|
||||
};
|
||||
|
||||
void TGauge::Init(TSubModel *NewSubModel, TGaugeType eNewType, double fNewScale, double fNewOffset,
|
||||
double fNewFriction, double fNewValue)
|
||||
void TGauge::Init(TSubModel *NewSubModel, TGaugeType eNewType, double fNewScale, double fNewOffset, double fNewFriction, double fNewValue)
|
||||
{ // ustawienie parametrów animacji submodelu
|
||||
if (NewSubModel)
|
||||
{ // warunek na wszelki wypadek, gdyby się submodel nie
|
||||
@@ -75,41 +51,107 @@ void TGauge::Init(TSubModel *NewSubModel, TGaugeType eNewType, double fNewScale,
|
||||
}
|
||||
};
|
||||
|
||||
bool TGauge::Load(cParser &Parser, TModel3d *md1, TModel3d *md2, double mul)
|
||||
{
|
||||
std::string str1 = Parser.getToken<std::string>(false);
|
||||
std::string str2 = Parser.getToken<std::string>();
|
||||
Parser.getTokens( 3, false );
|
||||
double val3, val4, val5;
|
||||
Parser
|
||||
>> val3
|
||||
>> val4
|
||||
>> val5;
|
||||
val3 *= mul;
|
||||
TSubModel *sm = md1->GetFromName( str1.c_str() );
|
||||
if( val3 == 0.0 ) {
|
||||
ErrorLog( "Scale of 0.0 defined for sub-model \"" + str1 + "\" in 3d model \"" + md1->NameGet() + "\". Forcing scale of 1.0 to prevent division by 0" );
|
||||
val3 = 1.0;
|
||||
bool TGauge::Load(cParser &Parser, TModel3d *md1, TModel3d *md2, double mul) {
|
||||
|
||||
std::string submodelname, gaugetypename;
|
||||
double scale, offset, friction;
|
||||
|
||||
Parser.getTokens();
|
||||
if( Parser.peek() != "{" ) {
|
||||
// old fixed size config
|
||||
Parser >> submodelname;
|
||||
gaugetypename = Parser.getToken<std::string>( true );
|
||||
Parser.getTokens( 3, false );
|
||||
Parser
|
||||
>> scale
|
||||
>> offset
|
||||
>> friction;
|
||||
}
|
||||
if (sm) // jeśli nie znaleziony
|
||||
md2 = NULL; // informacja, że znaleziony
|
||||
else if (md2) // a jest podany drugi model (np. zewnętrzny)
|
||||
sm = md2->GetFromName(str1.c_str()); // to może tam będzie, co za różnica gdzie
|
||||
if( sm == nullptr ) {
|
||||
ErrorLog( "Failed to locate sub-model \"" + str1 + "\" in 3d model \"" + md1->NameGet() + "\"" );
|
||||
else {
|
||||
// new, block type config
|
||||
// TODO: rework the base part into yaml-compatible flow style mapping
|
||||
cParser mappingparser( Parser.getToken<std::string>( false, "}" ) );
|
||||
submodelname = mappingparser.getToken<std::string>( false );
|
||||
gaugetypename = mappingparser.getToken<std::string>( true );
|
||||
mappingparser.getTokens( 3, false );
|
||||
mappingparser
|
||||
>> scale
|
||||
>> offset
|
||||
>> friction;
|
||||
// new, variable length section
|
||||
while( true == Load_mapping( mappingparser ) ) {
|
||||
; // all work done by while()
|
||||
}
|
||||
}
|
||||
|
||||
if (str2 == "mov")
|
||||
Init(sm, gt_Move, val3, val4, val5);
|
||||
else if (str2 == "wip")
|
||||
Init(sm, gt_Wiper, val3, val4, val5);
|
||||
else if (str2 == "dgt")
|
||||
Init(sm, gt_Digital, val3, val4, val5);
|
||||
else
|
||||
Init(sm, gt_Rotate, val3, val4, val5);
|
||||
scale *= mul;
|
||||
TSubModel *submodel = md1->GetFromName( submodelname.c_str() );
|
||||
if( scale == 0.0 ) {
|
||||
ErrorLog( "Scale of 0.0 defined for sub-model \"" + submodelname + "\" in 3d model \"" + md1->NameGet() + "\". Forcing scale of 1.0 to prevent division by 0" );
|
||||
scale = 1.0;
|
||||
}
|
||||
if (submodel) // jeśli nie znaleziony
|
||||
md2 = nullptr; // informacja, że znaleziony
|
||||
else if (md2) // a jest podany drugi model (np. zewnętrzny)
|
||||
submodel = md2->GetFromName(submodelname.c_str()); // to może tam będzie, co za różnica gdzie
|
||||
if( submodel == nullptr ) {
|
||||
ErrorLog( "Failed to locate sub-model \"" + submodelname + "\" in 3d model \"" + md1->NameGet() + "\"" );
|
||||
}
|
||||
|
||||
std::map<std::string, TGaugeType> gaugetypes {
|
||||
{ "mov", gt_Move },
|
||||
{ "wip", gt_Wiper },
|
||||
{ "dgt", gt_Digital }
|
||||
};
|
||||
auto lookup = gaugetypes.find( gaugetypename );
|
||||
auto const type = (
|
||||
lookup != gaugetypes.end() ?
|
||||
lookup->second :
|
||||
gt_Rotate );
|
||||
Init(submodel, type, scale, offset, friction);
|
||||
|
||||
return md2 != nullptr; // true, gdy podany model zewnętrzny, a w kabinie nie było
|
||||
};
|
||||
|
||||
bool
|
||||
TGauge::Load_mapping( cParser &Input ) {
|
||||
|
||||
if( false == Input.getTokens( 2, true, ", " ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string key, value;
|
||||
Input
|
||||
>> key
|
||||
>> value;
|
||||
|
||||
if( key == "soundinc:" ) {
|
||||
m_soundfxincrease = (
|
||||
value != "none" ?
|
||||
TSoundsManager::GetFromName( value, true ) :
|
||||
nullptr );
|
||||
}
|
||||
else if( key == "sounddec:" ) {
|
||||
m_soundfxdecrease = (
|
||||
value != "none" ?
|
||||
TSoundsManager::GetFromName( value, true ) :
|
||||
nullptr );
|
||||
}
|
||||
else if( key.find( "sound" ) == 0 ) {
|
||||
// sounds assigned to specific gauge values, defined by key soundFoo: where Foo = value
|
||||
auto const indexstart = key.find_first_of( "1234567890" );
|
||||
auto const indexend = key.find_first_not_of( "1234567890", indexstart );
|
||||
if( indexstart != std::string::npos ) {
|
||||
m_soundfxvalues.emplace(
|
||||
std::stoi( key.substr( indexstart, indexend - indexstart ) ),
|
||||
( value != "none" ?
|
||||
TSoundsManager::GetFromName( value, true ) :
|
||||
nullptr ) );
|
||||
}
|
||||
}
|
||||
return true; // return value marks a key: value pair was extracted, nothing about whether it's recognized
|
||||
}
|
||||
|
||||
void TGauge::PermIncValue(double fNewDesired)
|
||||
{
|
||||
fDesiredValue = fDesiredValue + fNewDesired * fScale + fOffset;
|
||||
@@ -134,9 +176,34 @@ void TGauge::DecValue(double fNewDesired)
|
||||
fDesiredValue = 0;
|
||||
};
|
||||
|
||||
void TGauge::UpdateValue(double fNewDesired)
|
||||
{ // ustawienie wartości docelowej
|
||||
// ustawienie wartości docelowej. plays provided fallback sound, if no sound was defined in the control itself
|
||||
void
|
||||
TGauge::UpdateValue( double fNewDesired, PSound Fallbacksound ) {
|
||||
|
||||
if( static_cast<int>( std::round( ( fDesiredValue - fOffset ) / fScale ) ) == static_cast<int>( fNewDesired ) ) {
|
||||
return;
|
||||
}
|
||||
fDesiredValue = fNewDesired * fScale + fOffset;
|
||||
// if there's any sound associated with new requested value, play it
|
||||
// check value-specific table first...
|
||||
auto const desiredvalue = static_cast<int>( std::round( fNewDesired ) );
|
||||
auto const lookup = m_soundfxvalues.find( desiredvalue );
|
||||
if( lookup != m_soundfxvalues.end() ) {
|
||||
play( lookup->second );
|
||||
return;
|
||||
}
|
||||
// ...and if there isn't any, fall back on the basic set...
|
||||
auto const currentvalue = GetValue();
|
||||
if( ( currentvalue < fNewDesired ) && ( m_soundfxincrease != nullptr ) ) {
|
||||
play( m_soundfxincrease );
|
||||
}
|
||||
else if( ( currentvalue > fNewDesired ) && ( m_soundfxdecrease != nullptr ) ) {
|
||||
play( m_soundfxdecrease );
|
||||
}
|
||||
else {
|
||||
// ...and if that fails too, try the provided fallback sound from legacy system
|
||||
play( Fallbacksound );
|
||||
}
|
||||
};
|
||||
|
||||
void TGauge::PutValue(double fNewDesired)
|
||||
@@ -245,4 +312,15 @@ void TGauge::UpdateValue()
|
||||
}
|
||||
};
|
||||
|
||||
void
|
||||
TGauge::play( PSound Sound ) {
|
||||
|
||||
if( Sound == nullptr ) { return; }
|
||||
|
||||
Sound->SetCurrentPosition( 0 );
|
||||
Sound->SetVolume( DSBVOLUME_MAX );
|
||||
Sound->Play( 0, 0, 0 );
|
||||
return;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
47
Gauge.h
47
Gauge.h
@@ -10,6 +10,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#pragma once
|
||||
|
||||
#include "Classes.h"
|
||||
#include "sound.h"
|
||||
|
||||
typedef enum
|
||||
{ // typ ruchu
|
||||
@@ -21,35 +22,43 @@ typedef enum
|
||||
gt_Digital // licznik cyfrowy, np. kilometrów
|
||||
} TGaugeType;
|
||||
|
||||
class TGauge // zmienne "gg"
|
||||
{ // animowany wskaźnik, mogący przyjmować wiele stanów pośrednich
|
||||
// animowany wskaźnik, mogący przyjmować wiele stanów pośrednich
|
||||
class TGauge {
|
||||
|
||||
private:
|
||||
TGaugeType eType; // typ ruchu
|
||||
double fFriction{ 0.0 }; // hamowanie przy zliżaniu się do zadanej wartości
|
||||
double fDesiredValue{ 0.0 }; // wartość docelowa
|
||||
double fValue{ 0.0 }; // wartość obecna
|
||||
double fOffset{ 0.0 }; // wartość początkowa ("0")
|
||||
double fScale{ 1.0 }; // wartość końcowa ("1")
|
||||
double fStepSize; // nie używane
|
||||
TGaugeType eType { gt_Unknown }; // typ ruchu
|
||||
double fFriction { 0.0 }; // hamowanie przy zliżaniu się do zadanej wartości
|
||||
double fDesiredValue { 0.0 }; // wartość docelowa
|
||||
double fValue { 0.0 }; // wartość obecna
|
||||
double fOffset { 0.0 }; // wartość początkowa ("0")
|
||||
double fScale { 1.0 }; // wartość końcowa ("1")
|
||||
char cDataType; // typ zmiennej parametru: f-float, d-double, i-int
|
||||
union
|
||||
{ // wskaźnik na parametr pokazywany przez animację
|
||||
union {
|
||||
// wskaźnik na parametr pokazywany przez animację
|
||||
float *fData;
|
||||
double *dData;
|
||||
double *dData { nullptr };
|
||||
int *iData;
|
||||
};
|
||||
PSound m_soundfxincrease { nullptr }; // sound associated with increasing control's value
|
||||
PSound m_soundfxdecrease { nullptr }; // sound associated with decreasing control's value
|
||||
std::map<int, PSound> m_soundfxvalues; // sounds associated with specific values
|
||||
// methods
|
||||
// plays specified sound
|
||||
void
|
||||
play( PSound Sound );
|
||||
|
||||
public:
|
||||
TGauge();
|
||||
~TGauge();
|
||||
void Clear();
|
||||
void Init(TSubModel *NewSubModel, TGaugeType eNewTyp, double fNewScale = 1,
|
||||
double fNewOffset = 0, double fNewFriction = 0, double fNewValue = 0);
|
||||
bool Load(cParser &Parser, TModel3d *md1, TModel3d *md2 = NULL, double mul = 1.0);
|
||||
TGauge() = default;
|
||||
~TGauge() {}
|
||||
inline
|
||||
void Clear() { *this = TGauge(); }
|
||||
void Init(TSubModel *NewSubModel, TGaugeType eNewTyp, double fNewScale = 1, double fNewOffset = 0, double fNewFriction = 0, double fNewValue = 0);
|
||||
bool Load(cParser &Parser, TModel3d *md1, TModel3d *md2 = nullptr, double mul = 1.0);
|
||||
bool Load_mapping( cParser &Input );
|
||||
void PermIncValue(double fNewDesired);
|
||||
void IncValue(double fNewDesired);
|
||||
void DecValue(double fNewDesired);
|
||||
void UpdateValue(double fNewDesired);
|
||||
void UpdateValue(double fNewDesired, PSound Fallbacksound = nullptr );
|
||||
void PutValue(double fNewDesired);
|
||||
double GetValue() const;
|
||||
void Update();
|
||||
|
||||
@@ -78,7 +78,8 @@ zwiekszenie nacisku przy duzych predkosciach w hamulcach Oerlikona
|
||||
*/
|
||||
|
||||
#include "dumb3d.h"
|
||||
using namespace Math3D;
|
||||
|
||||
extern int ConversionError;
|
||||
|
||||
const double Steel2Steel_friction = 0.15; //tarcie statyczne
|
||||
const double g = 9.81; //przyspieszenie ziemskie
|
||||
@@ -996,8 +997,8 @@ public:
|
||||
double FrictConst2d= 0.0;
|
||||
double TotalMassxg = 0.0; /*TotalMass*g*/
|
||||
|
||||
vector3 vCoulpler[2]; // powtórzenie współrzędnych sprzęgów z DynObj :/
|
||||
vector3 DimHalf; // połowy rozmiarów do obliczeń geometrycznych
|
||||
Math3D::vector3 vCoulpler[2]; // powtórzenie współrzędnych sprzęgów z DynObj :/
|
||||
Math3D::vector3 DimHalf; // połowy rozmiarów do obliczeń geometrycznych
|
||||
// int WarningSignal; //0: nie trabi, 1,2: trabi syreną o podanym numerze
|
||||
int WarningSignal = 0; // tymczasowo 8bit, ze względu na funkcje w MTools
|
||||
double fBrakeCtrlPos = -2.0; // płynna nastawa hamulca zespolonego
|
||||
@@ -1210,47 +1211,3 @@ private:
|
||||
};
|
||||
|
||||
extern double Distance(TLocation Loc1, TLocation Loc2, TDimension Dim1, TDimension Dim2);
|
||||
|
||||
inline
|
||||
std::string
|
||||
extract_value( std::string const &Key, std::string const &Input ) {
|
||||
|
||||
std::string value;
|
||||
auto lookup = Input.find( Key + "=" );
|
||||
if( lookup != std::string::npos ) {
|
||||
value = Input.substr( Input.find_first_not_of( ' ', lookup + Key.size() + 1 ) );
|
||||
lookup = value.find( ' ' );
|
||||
if( lookup != std::string::npos ) {
|
||||
// trim everything past the value
|
||||
value.erase( lookup );
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
template <typename Type_>
|
||||
bool
|
||||
extract_value( Type_ &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
|
||||
std::stringstream converter;
|
||||
converter << value;
|
||||
converter >> Variable;
|
||||
return true; // located the variable
|
||||
}
|
||||
else {
|
||||
// set the variable to provided default value
|
||||
if( false == Default.empty() ) {
|
||||
std::stringstream converter;
|
||||
converter << Default;
|
||||
converter >> Variable;
|
||||
}
|
||||
return false; // couldn't locate the variable in provided input
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
bool
|
||||
extract_value( bool &Variable, std::string const &Key, std::string const &Input, std::string const &Default );
|
||||
|
||||
@@ -13,6 +13,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "../logs.h"
|
||||
#include "Oerlikon_ESt.h"
|
||||
#include "../parser.h"
|
||||
#include "mctools.h"
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// Ra: tu należy przenosić funcje z mover.pas, które nie są z niego wywoływane.
|
||||
@@ -22,6 +23,8 @@ http://mozilla.org/MPL/2.0/.
|
||||
const double dEpsilon = 0.01; // 1cm (zależy od typu sprzęgu...)
|
||||
const double CouplerTune = 0.1; // skalowanie tlumiennosci
|
||||
|
||||
int ConversionError = 0;
|
||||
|
||||
std::vector<std::string> const TMoverParameters::eimc_labels = {
|
||||
"dfic: ", "dfmax:", "p: ", "scfu: ", "cim: ", "icif: ", "Uzmax:", "Uzh: ", "DU: ", "I0: ",
|
||||
"fcfu: ", "F0: ", "a1: ", "Pmax: ", "Fh: ", "Ph: ", "Vh0: ", "Vh1: ", "Imax: ", "abed: ",
|
||||
@@ -5097,14 +5100,17 @@ bool TMoverParameters::AutoRelayCheck(void)
|
||||
// IminLo
|
||||
}
|
||||
// main bez samoczynnego rozruchu
|
||||
if( ( MainCtrlActualPos < ( sizeof( RList ) / sizeof( TScheme ) - 1 ) ) // crude guard against running out of current fixed table
|
||||
&& ( ( RList[ MainCtrlActualPos ].Relay < MainCtrlPos )
|
||||
|| ( RList[ MainCtrlActualPos + 1 ].Relay == MainCtrlPos )
|
||||
|| ( ( TrainType == dt_ET22 )
|
||||
&& ( DelayCtrlFlag ) ) ) ) {
|
||||
|
||||
if( ( RList[MainCtrlPos].R == 0 )
|
||||
&& ( MainCtrlPos > 0 )
|
||||
&& ( MainCtrlPos != MainCtrlPosNo )
|
||||
&& ( FastSerialCircuit == 1 ) ) {
|
||||
|
||||
if ((RList[MainCtrlActualPos].Relay < MainCtrlPos) ||
|
||||
(RList[MainCtrlActualPos + 1].Relay == MainCtrlPos) ||
|
||||
((TrainType == dt_ET22) && (DelayCtrlFlag)))
|
||||
{
|
||||
if ((RList[MainCtrlPos].R == 0) && (MainCtrlPos > 0) &&
|
||||
(!(MainCtrlPos == MainCtrlPosNo)) && (FastSerialCircuit == 1))
|
||||
{
|
||||
MainCtrlActualPos++;
|
||||
// MainCtrlActualPos:=MainCtrlPos; //hunter-111012:
|
||||
// szybkie wchodzenie na bezoporowa (303E)
|
||||
@@ -5803,28 +5809,28 @@ std::string TMoverParameters::EngineDescription(int what)
|
||||
{
|
||||
if (TestFlag(DamageFlag, dtrain_thinwheel))
|
||||
if (Power > 0.1)
|
||||
outstr = "Thin wheel,";
|
||||
outstr = "Thin wheel";
|
||||
else
|
||||
outstr = "Load shifted,";
|
||||
outstr = "Load shifted";
|
||||
if (TestFlag(DamageFlag, dtrain_wheelwear))
|
||||
outstr = "Wheel wear,";
|
||||
outstr = "Wheel wear";
|
||||
if (TestFlag(DamageFlag, dtrain_bearing))
|
||||
outstr = "Bearing damaged,";
|
||||
outstr = "Bearing damaged";
|
||||
if (TestFlag(DamageFlag, dtrain_coupling))
|
||||
outstr = "Coupler broken,";
|
||||
outstr = "Coupler broken";
|
||||
if (TestFlag(DamageFlag, dtrain_loaddamage))
|
||||
if (Power > 0.1)
|
||||
outstr = "Ventilator damaged,";
|
||||
outstr = "Ventilator damaged";
|
||||
else
|
||||
outstr = "Load damaged,";
|
||||
outstr = "Load damaged";
|
||||
|
||||
if (TestFlag(DamageFlag, dtrain_loaddestroyed))
|
||||
if (Power > 0.1)
|
||||
outstr = "Engine damaged,";
|
||||
outstr = "Engine damaged";
|
||||
else
|
||||
outstr = "LOAD DESTROYED,";
|
||||
outstr = "LOAD DESTROYED";
|
||||
if (TestFlag(DamageFlag, dtrain_axle))
|
||||
outstr = "Axle broken,";
|
||||
outstr = "Axle broken";
|
||||
if (TestFlag(DamageFlag, dtrain_out))
|
||||
outstr = "DERAILED";
|
||||
if (outstr == "")
|
||||
@@ -6105,7 +6111,7 @@ bool TMoverParameters::readRList( std::string const &Input ) {
|
||||
return false;
|
||||
}
|
||||
auto idx = LISTLINE++;
|
||||
if( idx >= sizeof( RList ) ) {
|
||||
if( idx >= sizeof( RList ) / sizeof( TScheme ) ) {
|
||||
WriteLog( "Read RList: number of entries exceeded capacity of the data table" );
|
||||
return false;
|
||||
}
|
||||
@@ -6127,7 +6133,7 @@ bool TMoverParameters::readDList( std::string const &line ) {
|
||||
cParser parser( line );
|
||||
parser.getTokens( 3, false );
|
||||
auto idx = LISTLINE++;
|
||||
if( idx >= sizeof( RList ) ) {
|
||||
if( idx >= sizeof( RList ) / sizeof( TScheme ) ) {
|
||||
WriteLog( "Read DList: number of entries exceeded capacity of the data table" );
|
||||
return false;
|
||||
}
|
||||
@@ -6147,7 +6153,7 @@ bool TMoverParameters::readFFList( std::string const &line ) {
|
||||
return false;
|
||||
}
|
||||
int idx = LISTLINE++;
|
||||
if( idx >= sizeof( DElist ) ) {
|
||||
if( idx >= sizeof( DElist ) / sizeof( TDEScheme ) ) {
|
||||
WriteLog( "Read FList: number of entries exceeded capacity of the data table" );
|
||||
return false;
|
||||
}
|
||||
@@ -6167,7 +6173,7 @@ bool TMoverParameters::readWWList( std::string const &line ) {
|
||||
return false;
|
||||
}
|
||||
int idx = LISTLINE++;
|
||||
if( idx >= sizeof( DElist ) ) {
|
||||
if( idx >= sizeof( DElist ) / sizeof( TDEScheme ) ) {
|
||||
WriteLog( "Read WWList: number of entries exceeded capacity of the data table" );
|
||||
return false;
|
||||
}
|
||||
@@ -8364,22 +8370,3 @@ 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; // couldn't locate the variable in provided input
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,41 +17,9 @@ Copyright (C) 2007-2014 Maciej Cierniak
|
||||
|
||||
/*================================================*/
|
||||
|
||||
int ConversionError = 0;
|
||||
int LineCount = 0;
|
||||
bool DebugModeFlag = false;
|
||||
bool FreeFlyModeFlag = false;
|
||||
|
||||
//std::string Ups(std::string s)
|
||||
//{
|
||||
// int jatka;
|
||||
// std::string swy;
|
||||
//
|
||||
// swy = "";
|
||||
// {
|
||||
// long jatka_end = s.length() + 1;
|
||||
// for (jatka = 0; jatka < jatka_end; jatka++)
|
||||
// swy = swy + UpCase(s[jatka]);
|
||||
// }
|
||||
// return swy;
|
||||
//} /*=Ups=*/
|
||||
|
||||
int Max0(int x1, int x2)
|
||||
{
|
||||
if (x1 > x2)
|
||||
return x1;
|
||||
else
|
||||
return x2;
|
||||
}
|
||||
|
||||
int Min0(int x1, int x2)
|
||||
{
|
||||
if (x1 < x2)
|
||||
return x1;
|
||||
else
|
||||
return x2;
|
||||
}
|
||||
|
||||
double Max0R(double x1, double x2)
|
||||
{
|
||||
if (x1 > x2)
|
||||
@@ -87,13 +55,8 @@ bool TestFlag(int Flag, int Value)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SetFlag(int &Flag, int Value)
|
||||
{
|
||||
return iSetFlag(Flag, Value);
|
||||
}
|
||||
bool SetFlag(int &Flag, int Value) {
|
||||
|
||||
bool iSetFlag(int &Flag, int Value)
|
||||
{
|
||||
if (Value > 0)
|
||||
{
|
||||
if ((Flag & Value) == 0)
|
||||
@@ -263,33 +226,13 @@ std::string to_hex_str( int const Value, int const Width )
|
||||
return converter.str();
|
||||
};
|
||||
|
||||
int stol_def(const std::string &str, const int &DefaultValue)
|
||||
{
|
||||
int stol_def(const std::string &str, const int &DefaultValue) {
|
||||
|
||||
int result { DefaultValue };
|
||||
std::stringstream converter;
|
||||
converter << str;
|
||||
converter >> result;
|
||||
return result;
|
||||
/*
|
||||
// this function was developed iteratively on Codereview.stackexchange
|
||||
// with the assistance of @Corbin
|
||||
std::size_t len = str.size();
|
||||
while (std::isspace(str[len - 1]))
|
||||
len--;
|
||||
if (len == 0)
|
||||
return DefaultValue;
|
||||
errno = 0;
|
||||
char *s = new char[len + 1];
|
||||
std::strncpy(s, str.c_str(), len);
|
||||
char *p;
|
||||
int result = strtol(s, &p, 0);
|
||||
delete[] s;
|
||||
if( ( *p != '\0' ) || ( errno != 0 ) )
|
||||
{
|
||||
return DefaultValue;
|
||||
}
|
||||
return result;
|
||||
*/
|
||||
}
|
||||
|
||||
std::string ToLower(std::string const &text)
|
||||
@@ -321,114 +264,27 @@ win1250_to_ascii( std::string &Input ) {
|
||||
}
|
||||
}
|
||||
|
||||
void ComputeArc(double X0, double Y0, double Xn, double Yn, double R, double L, double dL,
|
||||
double &phi, double &Xout, double &Yout)
|
||||
/*wylicza polozenie Xout Yout i orientacje phi punktu na elemencie dL luku*/
|
||||
{
|
||||
double dX;
|
||||
double dY;
|
||||
double Xc;
|
||||
double Yc;
|
||||
double gamma;
|
||||
double alfa;
|
||||
double AbsR;
|
||||
template <>
|
||||
bool
|
||||
extract_value( bool &Variable, std::string const &Key, std::string const &Input, std::string const &Default ) {
|
||||
|
||||
if ((R != 0) && (L != 0))
|
||||
{
|
||||
AbsR = abs(R);
|
||||
dX = Xn - X0;
|
||||
dY = Yn - Y0;
|
||||
if (dX != 0)
|
||||
gamma = atan(dY * 1.0 / dX);
|
||||
else if (dY > 0)
|
||||
gamma = M_PI * 1.0 / 2;
|
||||
else
|
||||
gamma = 3 * M_PI * 1.0 / 2;
|
||||
alfa = L * 1.0 / R;
|
||||
phi = gamma - (alfa + M_PI * Round(R * 1.0 / AbsR)) * 1.0 / 2;
|
||||
Xc = X0 - AbsR * cos(phi);
|
||||
Yc = Y0 - AbsR * sin(phi);
|
||||
phi = phi + alfa * dL * 1.0 / L;
|
||||
Xout = AbsR * cos(phi) + Xc;
|
||||
Yout = AbsR * sin(phi) + Yc;
|
||||
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; // couldn't locate the variable in provided input
|
||||
}
|
||||
}
|
||||
|
||||
void ComputeALine(double X0, double Y0, double Xn, double Yn, double L, double R, double &Xout,
|
||||
double &Yout)
|
||||
{
|
||||
double dX;
|
||||
double dY;
|
||||
double gamma;
|
||||
double alfa;
|
||||
/* pX,pY : real;*/
|
||||
|
||||
alfa = 0; // ABu: bo nie bylo zainicjowane
|
||||
dX = Xn - X0;
|
||||
dY = Yn - Y0;
|
||||
if (dX != 0)
|
||||
gamma = atan(dY * 1.0 / dX);
|
||||
else if (dY > 0)
|
||||
gamma = M_PI * 1.0 / 2;
|
||||
else
|
||||
gamma = 3 * M_PI * 1.0 / 2;
|
||||
if (R != 0)
|
||||
alfa = L * 1.0 / R;
|
||||
Xout = X0 + L * cos(alfa * 1.0 / 2 - gamma);
|
||||
Yout = Y0 + L * sin(alfa * 1.0 / 2 - gamma);
|
||||
}
|
||||
|
||||
bool FileExists( std::string const &Filename ) {
|
||||
|
||||
std::ifstream file( Filename );
|
||||
std::ifstream file( Filename );
|
||||
return( true == file.is_open() );
|
||||
}
|
||||
|
||||
/*
|
||||
//graficzne:
|
||||
|
||||
double Xhor(double h)
|
||||
{
|
||||
return h * Hstep + Xmin;
|
||||
}
|
||||
|
||||
double Yver(double v)
|
||||
{
|
||||
return (Vsize - v) * Vstep + Ymin;
|
||||
}
|
||||
|
||||
long Horiz(double x)
|
||||
{
|
||||
x = (x - Xmin) * 1.0 / Hstep;
|
||||
if (x > -INT_MAX)
|
||||
if (x < INT_MAX)
|
||||
return Round(x);
|
||||
else
|
||||
return INT_MAX;
|
||||
else
|
||||
return -INT_MAX;
|
||||
}
|
||||
|
||||
long Vert(double Y)
|
||||
{
|
||||
Y = (Y - Ymin) * 1.0 / Vstep;
|
||||
if (Y > -INT_MAX)
|
||||
if (Y < INT_MAX)
|
||||
return Vsize - Round(Y);
|
||||
else
|
||||
return INT_MAX;
|
||||
else
|
||||
return -INT_MAX;
|
||||
}
|
||||
*/
|
||||
|
||||
// NOTE: this now does nothing.
|
||||
void ClearPendingExceptions()
|
||||
// resetuje błędy FPU, wymagane dla Trunc()
|
||||
{
|
||||
; /*?*/ /* ASM
|
||||
FNCLEX
|
||||
ASM END */
|
||||
}
|
||||
|
||||
// END
|
||||
|
||||
@@ -15,48 +15,16 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <ctime>
|
||||
#include <sys/stat.h>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
|
||||
/*Ra: te stałe nie są używane...
|
||||
_FileName = ['a'..'z','A'..'Z',':','\','.','*','?','0'..'9','_','-'];
|
||||
_RealNum = ['0'..'9','-','+','.','E','e'];
|
||||
_Integer = ['0'..'9','-']; //Ra: to się gryzie z STLport w Builder 6
|
||||
_Plus_Int = ['0'..'9'];
|
||||
_All = [' '..'ţ'];
|
||||
_Delimiter= [',',';']+_EOL;
|
||||
_Delimiter_Space=_Delimiter+[' '];
|
||||
*/
|
||||
static char _EOL[2] = { (char)13, (char)10 };
|
||||
static char _Spacesigns[4] = { (char)' ', (char)9, (char)13, (char)10 };
|
||||
static std::string _spacesigns = " " + (char)9 + (char)13 + (char)10;
|
||||
static int const CutLeft = -1;
|
||||
static int const CutRight = 1;
|
||||
static int const CutBoth = 0; /*Cut_Space*/
|
||||
|
||||
extern int ConversionError;
|
||||
extern int LineCount;
|
||||
extern bool DebugModeFlag;
|
||||
extern bool FreeFlyModeFlag;
|
||||
|
||||
|
||||
typedef unsigned long/*?*//*set of: char */ TableChar; /*MCTUTIL*/
|
||||
|
||||
/*konwersje*/
|
||||
|
||||
/*funkcje matematyczne*/
|
||||
int Max0(int x1, int x2);
|
||||
int Min0(int x1, int x2);
|
||||
|
||||
double Max0R(double x1, double x2);
|
||||
double Min0R(double x1, double x2);
|
||||
|
||||
inline int Sign(int x)
|
||||
{
|
||||
return x >= 0 ? 1 : -1;
|
||||
}
|
||||
|
||||
inline double Sign(double x)
|
||||
{
|
||||
return x >= 0 ? 1.0 : -1.0;
|
||||
@@ -68,7 +36,7 @@ inline long Round(double const f)
|
||||
//return lround(f);
|
||||
}
|
||||
|
||||
extern double Random(double a, double b);
|
||||
double Random(double a, double b);
|
||||
|
||||
inline double Random()
|
||||
{
|
||||
@@ -94,10 +62,9 @@ inline double BorlandTime()
|
||||
std::string Now();
|
||||
|
||||
/*funkcje logiczne*/
|
||||
extern bool TestFlag(int Flag, int Value);
|
||||
extern bool SetFlag( int & Flag, int Value);
|
||||
extern bool iSetFlag( int & Flag, int Value);
|
||||
extern bool UnSetFlag(int &Flag, int Value);
|
||||
bool TestFlag(int Flag, int Value);
|
||||
bool SetFlag( int & Flag, int Value);
|
||||
bool UnSetFlag(int &Flag, int Value);
|
||||
|
||||
bool FuzzyLogic(double Test, double Threshold, double Probability);
|
||||
/*jesli Test>Threshold to losowanie*/
|
||||
@@ -139,40 +106,48 @@ std::string ToUpper(std::string const &text);
|
||||
// replaces polish letters with basic ascii
|
||||
void win1250_to_ascii( std::string &Input );
|
||||
|
||||
/*procedury, zmienne i funkcje graficzne*/
|
||||
void ComputeArc(double X0, double Y0, double Xn, double Yn, double R, double L, double dL, double & phi, double & Xout, double & Yout);
|
||||
/*wylicza polozenie Xout Yout i orientacje phi punktu na elemencie dL luku*/
|
||||
void ComputeALine(double X0, double Y0, double Xn, double Yn, double L, double R, double & Xout, double & Yout);
|
||||
/*
|
||||
inline bool fileExists(const std::string &name)
|
||||
{
|
||||
struct stat buffer;
|
||||
return (stat(name.c_str(), &buffer) == 0);
|
||||
}*/
|
||||
inline
|
||||
std::string
|
||||
extract_value( std::string const &Key, std::string const &Input ) {
|
||||
|
||||
std::string value;
|
||||
auto lookup = Input.find( Key + "=" );
|
||||
if( lookup != std::string::npos ) {
|
||||
value = Input.substr( Input.find_first_not_of( ' ', lookup + Key.size() + 1 ) );
|
||||
lookup = value.find( ' ' );
|
||||
if( lookup != std::string::npos ) {
|
||||
// trim everything past the value
|
||||
value.erase( lookup );
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
template <typename Type_>
|
||||
bool
|
||||
extract_value( Type_ &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
|
||||
std::stringstream converter;
|
||||
converter << value;
|
||||
converter >> Variable;
|
||||
return true; // located the variable
|
||||
}
|
||||
else {
|
||||
// set the variable to provided default value
|
||||
if( false == Default.empty() ) {
|
||||
std::stringstream converter;
|
||||
converter << Default;
|
||||
converter >> Variable;
|
||||
}
|
||||
return false; // couldn't locate the variable in provided input
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
bool
|
||||
extract_value( bool &Variable, std::string const &Key, std::string const &Input, std::string const &Default );
|
||||
|
||||
bool FileExists( std::string const &Filename );
|
||||
/*
|
||||
extern double Xmin;
|
||||
extern double Ymin;
|
||||
extern double Xmax;
|
||||
extern double Ymax;
|
||||
extern double Xaspect;
|
||||
extern double Yaspect;
|
||||
extern double Hstep;
|
||||
extern double Vstep;
|
||||
extern int Vsize;
|
||||
extern int Hsize;
|
||||
|
||||
|
||||
// Converts horizontal screen coordinate into real X-coordinate.
|
||||
double Xhor( double h );
|
||||
|
||||
// Converts vertical screen coordinate into real Y-coordinate.
|
||||
double Yver( double v );
|
||||
|
||||
long Horiz(double x);
|
||||
|
||||
long Vert(double Y);
|
||||
*/
|
||||
|
||||
void ClearPendingExceptions();
|
||||
|
||||
|
||||
@@ -1217,11 +1217,11 @@ TSubModel *TModel3d::GetFromName(const char *sName)
|
||||
if (!sName)
|
||||
return Root; // potrzebne do terenu z E3D
|
||||
if (iFlags & 0x0200) // wczytany z pliku tekstowego, wyszukiwanie rekurencyjne
|
||||
return Root ? Root->GetFromName(sName) : NULL;
|
||||
return Root ? Root->GetFromName(sName) : nullptr;
|
||||
else // wczytano z pliku binarnego, można wyszukać iteracyjnie
|
||||
{
|
||||
// for (int i=0;i<iSubModelsCount;++i)
|
||||
return Root ? Root->GetFromName(sName) : NULL;
|
||||
return Root ? Root->GetFromName(sName) : nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
46
Train.h
46
Train.h
@@ -34,8 +34,9 @@ class TCab
|
||||
public:
|
||||
TCab();
|
||||
~TCab();
|
||||
void Init(double Initx1, double Inity1, double Initz1, double Initx2, double Inity2,
|
||||
double Initz2, bool InitEnabled, bool InitOccupied);
|
||||
/*
|
||||
void Init(double Initx1, double Inity1, double Initz1, double Initx2, double Inity2, double Initz2, bool InitEnabled, bool InitOccupied);
|
||||
*/
|
||||
void Load(cParser &Parser);
|
||||
vector3 CabPos1;
|
||||
vector3 CabPos2;
|
||||
@@ -43,17 +44,19 @@ class TCab
|
||||
bool bOccupied;
|
||||
double dimm_r, dimm_g, dimm_b; // McZapkie-120503: tlumienie swiatla
|
||||
double intlit_r, intlit_g, intlit_b; // McZapkie-120503: oswietlenie kabiny
|
||||
double intlitlow_r, intlitlow_g,
|
||||
intlitlow_b; // McZapkie-120503: przyciemnione oswietlenie kabiny
|
||||
double intlitlow_r, intlitlow_g, intlitlow_b; // McZapkie-120503: przyciemnione oswietlenie kabiny
|
||||
private:
|
||||
// bool bChangePossible;
|
||||
/*
|
||||
TGauge *ggList; // Ra 2014-08: lista animacji macierzowych (gałek) w kabinie
|
||||
int iGaugesMax, iGauges; // ile miejsca w tablicy i ile jest w użyciu
|
||||
TButton *btList; // Ra 2014-08: lista animacji dwustanowych (lampek) w kabinie
|
||||
int iButtonsMax, iButtons; // ile miejsca w tablicy i ile jest w użyciu
|
||||
*/
|
||||
std::vector<TGauge> ggList;
|
||||
std::vector<TButton> btList;
|
||||
public:
|
||||
TGauge *Gauge(int n = -1); // pobranie adresu obiektu
|
||||
TButton *Button(int n = -1); // pobranie adresu obiektu
|
||||
TGauge &Gauge(int n = -1); // pobranie adresu obiektu
|
||||
TButton &Button(int n = -1); // pobranie adresu obiektu
|
||||
void Update();
|
||||
};
|
||||
|
||||
@@ -103,11 +106,9 @@ class TTrain
|
||||
// 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
|
||||
// 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);
|
||||
// initializes a button matching provided label. returns: true if the label was found, false
|
||||
// otherwise
|
||||
// initializes a button matching provided label. returns: true if the label was found, false otherwise
|
||||
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
|
||||
@@ -209,12 +210,7 @@ public: // reszta może by?publiczna
|
||||
TGauge ggClockSInd;
|
||||
TGauge ggClockMInd;
|
||||
TGauge ggClockHInd;
|
||||
// TGauge ggHVoltage;
|
||||
TGauge ggLVoltage;
|
||||
// TGauge ggEnrot1m;
|
||||
// TGauge ggEnrot2m;
|
||||
// TGauge ggEnrot3m;
|
||||
// TGauge ggEngageRatio;
|
||||
TGauge ggMainGearStatus;
|
||||
|
||||
TGauge ggEngineVoltage;
|
||||
@@ -277,13 +273,7 @@ public: // reszta może by?publiczna
|
||||
TGauge ggHornLowButton;
|
||||
TGauge ggHornHighButton;
|
||||
TGauge ggNextCurrentButton;
|
||||
/*
|
||||
// ABu 090305 - uniwersalne przyciski
|
||||
TGauge ggUniversal1Button;
|
||||
TGauge ggUniversal2Button;
|
||||
TGauge ggUniversal4Button;
|
||||
bool Universal4Active;
|
||||
*/
|
||||
|
||||
std::array<TGauge, 10> ggUniversals; // NOTE: temporary arrangement until we have dynamically built control table
|
||||
|
||||
TGauge ggInstrumentLightButton;
|
||||
@@ -336,7 +326,6 @@ public: // reszta może by?publiczna
|
||||
TButton btLampkaRadio;
|
||||
TButton btLampkaHamowanie1zes;
|
||||
TButton btLampkaHamowanie2zes;
|
||||
// TButton btLampkaUnknown;
|
||||
TButton btLampkaOpory;
|
||||
TButton btLampkaWysRozr;
|
||||
TButton btInstrumentLight;
|
||||
@@ -363,8 +352,6 @@ public: // reszta może by?publiczna
|
||||
TButton btLampkaBoczniki;
|
||||
TButton btLampkaMaxSila;
|
||||
TButton btLampkaPrzekrMaxSila;
|
||||
// TButton bt;
|
||||
//
|
||||
TButton btLampkaDoorLeft;
|
||||
TButton btLampkaDoorRight;
|
||||
TButton btLampkaDepartureSignal;
|
||||
@@ -439,8 +426,6 @@ public: // reszta może by?publiczna
|
||||
PSound dsbHasler;
|
||||
PSound dsbBuzzer;
|
||||
PSound dsbSlipAlarm; // Bombardier 011010: alarm przy poslizgu dla 181/182
|
||||
// TFadeSound sConverter; //przetwornica
|
||||
// TFadeSound sSmallCompressor; //przetwornica
|
||||
|
||||
int iCabLightFlag; // McZapkie:120503: oswietlenie kabiny (0: wyl, 1: przyciemnione, 2: pelne)
|
||||
bool bCabLight; // hunter-091012: czy swiatlo jest zapalone?
|
||||
@@ -454,11 +439,6 @@ public: // reszta może by?publiczna
|
||||
PSound dsbCouplerStretch;
|
||||
PSound dsbEN57_CouplerStretch;
|
||||
PSound dsbBufferClamp;
|
||||
// TSubModel *smCzuwakShpOn;
|
||||
// TSubModel *smCzuwakOn;
|
||||
// TSubModel *smShpOn;
|
||||
// TSubModel *smCzuwakShpOff;
|
||||
// double fCzuwakTimer;
|
||||
double fBlinkTimer;
|
||||
float fHaslerTimer;
|
||||
float fConverterTimer; // hunter-261211: dla przekaznika
|
||||
|
||||
@@ -114,7 +114,7 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
|
||||
{ // omijamy cały ten blok, gdy tor nie ma on żadnych eventów (większość nie ma)
|
||||
if (fDistance < 0)
|
||||
{
|
||||
if (iSetFlag(iEventFlag, -1)) // zawsze zeruje flagę sprawdzenia, jak mechanik
|
||||
if (SetFlag(iEventFlag, -1)) // zawsze zeruje flagę sprawdzenia, jak mechanik
|
||||
// dosiądzie, to się nie wykona
|
||||
if (Owner->Mechanik->Primary()) // tylko dla jednego członu
|
||||
// if (TestFlag(iEventFlag,1)) //McZapkie-280503: wyzwalanie event tylko dla
|
||||
@@ -126,7 +126,7 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
|
||||
// Owner->RaAxleEvent(pCurrentTrack->Event1); //Ra: dynamic zdecyduje, czy dodać do
|
||||
// kolejki
|
||||
// if (TestFlag(iEventallFlag,1))
|
||||
if (iSetFlag(iEventallFlag,
|
||||
if (SetFlag(iEventallFlag,
|
||||
-1)) // McZapkie-280503: wyzwalanie eventall dla wszystkich pojazdow
|
||||
if (bPrimary && pCurrentTrack->evEventall1 &&
|
||||
(!pCurrentTrack->evEventall1->iQueued))
|
||||
@@ -136,7 +136,7 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
|
||||
}
|
||||
else if (fDistance > 0)
|
||||
{
|
||||
if (iSetFlag(iEventFlag, -2)) // zawsze ustawia flagę sprawdzenia, jak mechanik
|
||||
if (SetFlag(iEventFlag, -2)) // zawsze ustawia flagę sprawdzenia, jak mechanik
|
||||
// dosiądzie, to się nie wykona
|
||||
if (Owner->Mechanik->Primary()) // tylko dla jednego członu
|
||||
// if (TestFlag(iEventFlag,2)) //sprawdzanie jest od razu w pierwszym
|
||||
@@ -147,7 +147,7 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
|
||||
// Owner->RaAxleEvent(pCurrentTrack->Event2); //Ra: dynamic zdecyduje, czy dodać do
|
||||
// kolejki
|
||||
// if (TestFlag(iEventallFlag,2))
|
||||
if (iSetFlag(iEventallFlag,
|
||||
if (SetFlag(iEventallFlag,
|
||||
-2)) // sprawdza i zeruje na przyszłość, true jeśli zmieni z 2 na 0
|
||||
if (bPrimary && pCurrentTrack->evEventall2 &&
|
||||
(!pCurrentTrack->evEventall2->iQueued))
|
||||
|
||||
39
parser.h
39
parser.h
@@ -33,29 +33,28 @@ class cParser //: public std::stringstream
|
||||
virtual ~cParser();
|
||||
// methods:
|
||||
template <typename Type_>
|
||||
cParser&
|
||||
cParser &
|
||||
operator>>( Type_ &Right );
|
||||
template <>
|
||||
cParser&
|
||||
cParser &
|
||||
operator>>( std::string &Right );
|
||||
template <>
|
||||
cParser&
|
||||
cParser &
|
||||
operator>>( bool &Right );
|
||||
template <typename _Output>
|
||||
_Output
|
||||
getToken( bool const ToLower = true )
|
||||
{
|
||||
getTokens( 1, ToLower );
|
||||
_Output output;
|
||||
*this >> output;
|
||||
return output;
|
||||
};
|
||||
template <typename Output_>
|
||||
Output_
|
||||
getToken( bool const ToLower = true, const char *Break = "\n\r\t ;" ) {
|
||||
getTokens( 1, ToLower, Break );
|
||||
Output_ output;
|
||||
*this >> output;
|
||||
return output; };
|
||||
template <>
|
||||
bool
|
||||
getToken<bool>( bool const ToLower ) {
|
||||
|
||||
return ( getToken<std::string>() == "true" );
|
||||
}
|
||||
getToken<bool>( bool const ToLower, const char *Break ) {
|
||||
auto const token = getToken<std::string>( true, Break );
|
||||
return ( ( token == "true" )
|
||||
|| ( token == "yes" )
|
||||
|| ( token == "1" ) ); }
|
||||
inline void ignoreToken()
|
||||
{
|
||||
readToken();
|
||||
@@ -77,7 +76,13 @@ class cParser //: public std::stringstream
|
||||
{
|
||||
return !mStream->fail();
|
||||
};
|
||||
bool getTokens(unsigned int Count = 1, bool ToLower = true, const char *Break = "\n\r\t ;");
|
||||
bool getTokens(unsigned int Count = 1, bool ToLower = true, char const *Break = "\n\r\t ;");
|
||||
// returns next incoming token, if any, without removing it from the set
|
||||
std::string peek() const {
|
||||
return (
|
||||
false == tokens.empty() ?
|
||||
tokens.front() :
|
||||
"" ); }
|
||||
// returns percentage of file processed so far
|
||||
int getProgress() const;
|
||||
int getFullProgress() const;
|
||||
|
||||
34
uilayer.cpp
34
uilayer.cpp
@@ -44,7 +44,7 @@ ui_layer::init( GLFWwindow *Window ) {
|
||||
DEFAULT_PITCH | FF_DONTCARE, // family and pitch
|
||||
"Lucida Console"); // font name
|
||||
::SelectObject(hDC, font); // selects the font we want
|
||||
if( true == ::wglUseFontBitmaps( hDC, 32, 96, m_fontbase ) ) {
|
||||
if( TRUE == ::wglUseFontBitmaps( hDC, 32, 96, m_fontbase ) ) {
|
||||
// builds 96 characters starting at character 32
|
||||
WriteLog( "Display Lists font used" ); //+AnsiString(glGetError())
|
||||
WriteLog( "Font init OK" ); //+AnsiString(glGetError())
|
||||
@@ -151,8 +151,8 @@ ui_layer::render_progress() {
|
||||
Global::iWindowWidth );
|
||||
float const heightratio =
|
||||
( screenratio >= ( 4.0f / 3.0f ) ?
|
||||
Global::iWindowHeight / 768.0 :
|
||||
Global::iWindowHeight / 768.0 * screenratio / ( 4.0f / 3.0f ) );
|
||||
Global::iWindowHeight / 768.f :
|
||||
Global::iWindowHeight / 768.f * screenratio / ( 4.0f / 3.0f ) );
|
||||
float const height = 768.0f * heightratio;
|
||||
|
||||
::glColor4f( 216.0f / 255.0f, 216.0f / 255.0f, 216.0f / 255.0f, 1.0f );
|
||||
@@ -176,8 +176,8 @@ ui_layer::render_panels() {
|
||||
glPushAttrib( GL_ENABLE_BIT );
|
||||
glDisable( GL_TEXTURE_2D );
|
||||
|
||||
float const width = std::min( 4.0f / 3.0f, static_cast<float>(Global::iWindowWidth) / std::max( 1, Global::iWindowHeight ) ) * Global::iWindowHeight;
|
||||
float const height = Global::iWindowHeight / 768.0;
|
||||
float const width = std::min( 4.f / 3.f, static_cast<float>(Global::iWindowWidth) / std::max( 1, Global::iWindowHeight ) ) * Global::iWindowHeight;
|
||||
float const height = Global::iWindowHeight / 768.f;
|
||||
|
||||
for( auto const &panel : m_panels ) {
|
||||
|
||||
@@ -186,8 +186,8 @@ ui_layer::render_panels() {
|
||||
|
||||
::glColor4fv( &line.color.x );
|
||||
::glRasterPos2f(
|
||||
0.5 * ( Global::iWindowWidth - width ) + panel->origin_x * height,
|
||||
panel->origin_y * height + 20.0 * lineidx );
|
||||
0.5f * ( Global::iWindowWidth - width ) + panel->origin_x * height,
|
||||
panel->origin_y * height + 20.f * lineidx );
|
||||
print( line.data );
|
||||
++lineidx;
|
||||
}
|
||||
@@ -255,14 +255,14 @@ ui_layer::quad( float4 const &Coordinates, float4 const &Color ) {
|
||||
|
||||
float const screenratio = static_cast<float>( Global::iWindowWidth ) / Global::iWindowHeight;
|
||||
float const width =
|
||||
( screenratio >= (4.0f/3.0f) ?
|
||||
( 4.0f / 3.0f ) * Global::iWindowHeight :
|
||||
( screenratio >= ( 4.f / 3.f ) ?
|
||||
( 4.f / 3.f ) * Global::iWindowHeight :
|
||||
Global::iWindowWidth );
|
||||
float const heightratio =
|
||||
( screenratio >= ( 4.0f / 3.0f ) ?
|
||||
Global::iWindowHeight / 768.0 :
|
||||
Global::iWindowHeight / 768.0 * screenratio / ( 4.0f / 3.0f ) );
|
||||
float const height = 768.0f * heightratio;
|
||||
( screenratio >= ( 4.f / 3.f ) ?
|
||||
Global::iWindowHeight / 768.f :
|
||||
Global::iWindowHeight / 768.f * screenratio / ( 4.f / 3.f ) );
|
||||
float const height = 768.f * heightratio;
|
||||
/*
|
||||
float const heightratio = Global::iWindowHeight / 768.0f;
|
||||
float const height = 768.0f * heightratio;
|
||||
@@ -272,10 +272,10 @@ ui_layer::quad( float4 const &Coordinates, float4 const &Color ) {
|
||||
|
||||
glBegin( GL_TRIANGLE_STRIP );
|
||||
|
||||
glTexCoord2f( 0.0f, 1.0f ); glVertex2f( 0.5 * ( Global::iWindowWidth - width ) + Coordinates.x * heightratio, 0.5 * ( Global::iWindowHeight - height ) + Coordinates.y * heightratio );
|
||||
glTexCoord2f( 0.0f, 0.0f ); glVertex2f( 0.5 * ( Global::iWindowWidth - width ) + Coordinates.x * heightratio, 0.5 * ( Global::iWindowHeight - height ) + Coordinates.w * heightratio );
|
||||
glTexCoord2f( 1.0f, 1.0f ); glVertex2f( 0.5 * ( Global::iWindowWidth - width ) + Coordinates.z * heightratio, 0.5 * ( Global::iWindowHeight - height ) + Coordinates.y * heightratio );
|
||||
glTexCoord2f( 1.0f, 0.0f ); glVertex2f( 0.5 * ( Global::iWindowWidth - width ) + Coordinates.z * heightratio, 0.5 * ( Global::iWindowHeight - height ) + Coordinates.w * heightratio );
|
||||
glTexCoord2f( 0.f, 1.f ); glVertex2f( 0.5f * ( Global::iWindowWidth - width ) + Coordinates.x * heightratio, 0.5f * ( Global::iWindowHeight - height ) + Coordinates.y * heightratio );
|
||||
glTexCoord2f( 0.f, 0.f ); glVertex2f( 0.5f * ( Global::iWindowWidth - width ) + Coordinates.x * heightratio, 0.5f * ( Global::iWindowHeight - height ) + Coordinates.w * heightratio );
|
||||
glTexCoord2f( 1.f, 1.f ); glVertex2f( 0.5f * ( Global::iWindowWidth - width ) + Coordinates.z * heightratio, 0.5f * ( Global::iWindowHeight - height ) + Coordinates.y * heightratio );
|
||||
glTexCoord2f( 1.f, 0.f ); glVertex2f( 0.5f * ( Global::iWindowWidth - width ) + Coordinates.z * heightratio, 0.5f * ( Global::iWindowHeight - height ) + Coordinates.w * heightratio );
|
||||
|
||||
glEnd();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user