mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
fixed some potential memory leaks and other errors detected by cppcheck
This commit is contained in:
@@ -60,11 +60,13 @@ void TAdvancedSound::Load(cParser &Parser, vector3 const &pPosition)
|
||||
{
|
||||
std::string nameon, name, nameoff;
|
||||
double attenuation;
|
||||
Parser.getTokens( 4 );
|
||||
Parser.getTokens( 3, true, "\n\t ;," ); // samples separated with commas
|
||||
Parser
|
||||
>> nameon
|
||||
>> name
|
||||
>> nameoff
|
||||
>> nameoff;
|
||||
Parser.getTokens( 1, false );
|
||||
Parser
|
||||
>> attenuation;
|
||||
Init( nameon, name, nameoff, attenuation, pPosition );
|
||||
}
|
||||
|
||||
@@ -752,10 +752,10 @@ void TAnimModel::AnimationVND(void *pData, double a, double b, double c, double
|
||||
}
|
||||
*/
|
||||
|
||||
int i, j, k, idx;
|
||||
std::string name;
|
||||
/* int i, j, k, idx;
|
||||
*/ std::string name;
|
||||
TAnimContainer *pSub;
|
||||
for (i = 0; i < pAdvanced->iMovements; ++i)
|
||||
for (int i = 0; i < pAdvanced->iMovements; ++i)
|
||||
{
|
||||
if (strcmp(pAdvanced->pMovementData[i].cBone, name.c_str()))
|
||||
{ // jeśli pozycja w tabelce nie była wyszukiwana w submodelach
|
||||
|
||||
30
Console.cpp
30
Console.cpp
@@ -248,35 +248,35 @@ void Console::BitsUpdate(int mask)
|
||||
if (PoKeys55[0])
|
||||
{ // pewnie trzeba będzie to dodatkowo buforować i oczekiwać na potwierdzenie
|
||||
if (mask & 0x0001) // b0 gdy SHP
|
||||
PoKeys55[0]->Write(0x40, 23 - 1, iBits & 0x0001 ? 1 : 0);
|
||||
PoKeys55[0]->Write(0x40, 23 - 1, (iBits & 0x0001) ? 1 : 0);
|
||||
if (mask & 0x0002) // b1 gdy zmieniony CA
|
||||
PoKeys55[0]->Write(0x40, 24 - 1, iBits & 0x0002 ? 1 : 0);
|
||||
PoKeys55[0]->Write(0x40, 24 - 1, (iBits & 0x0002) ? 1 : 0);
|
||||
if (mask & 0x0004) // b2 gdy jazda na oporach
|
||||
PoKeys55[0]->Write(0x40, 32 - 1, iBits & 0x0004 ? 1 : 0);
|
||||
PoKeys55[0]->Write(0x40, 32 - 1, (iBits & 0x0004) ? 1 : 0);
|
||||
if (mask & 0x0008) // b3 Lampka WS (wyłącznika szybkiego)
|
||||
PoKeys55[0]->Write(0x40, 25 - 1, iBits & 0x0008 ? 1 : 0);
|
||||
PoKeys55[0]->Write(0x40, 25 - 1, (iBits & 0x0008) ? 1 : 0);
|
||||
if (mask & 0x0010) // b4 Lampka przekaźnika nadmiarowego silników trakcyjnych
|
||||
PoKeys55[0]->Write(0x40, 27 - 1, iBits & 0x0010 ? 1 : 0);
|
||||
PoKeys55[0]->Write(0x40, 27 - 1, (iBits & 0x0010) ? 1 : 0);
|
||||
if (mask & 0x0020) // b5 Lampka styczników liniowych
|
||||
PoKeys55[0]->Write(0x40, 29 - 1, iBits & 0x0020 ? 1 : 0);
|
||||
PoKeys55[0]->Write(0x40, 29 - 1, (iBits & 0x0020) ? 1 : 0);
|
||||
if (mask & 0x0040) // b6 Lampka poślizgu
|
||||
PoKeys55[0]->Write(0x40, 30 - 1, iBits & 0x0040 ? 1 : 0);
|
||||
PoKeys55[0]->Write(0x40, 30 - 1, (iBits & 0x0040) ? 1 : 0);
|
||||
if (mask & 0x0080) // b7 Lampka "przetwornicy"
|
||||
PoKeys55[0]->Write(0x40, 28 - 1, iBits & 0x0080 ? 1 : 0);
|
||||
PoKeys55[0]->Write(0x40, 28 - 1, (iBits & 0x0080) ? 1 : 0);
|
||||
if (mask & 0x0100) // b8 Kontrolka przekaźnika nadmiarowego sprężarki
|
||||
PoKeys55[0]->Write(0x40, 33 - 1, iBits & 0x0100 ? 1 : 0);
|
||||
PoKeys55[0]->Write(0x40, 33 - 1, (iBits & 0x0100) ? 1 : 0);
|
||||
if (mask & 0x0200) // b9 Kontrolka sygnalizacji wentylatorów i oporów
|
||||
PoKeys55[0]->Write(0x40, 26 - 1, iBits & 0x0200 ? 1 : 0);
|
||||
PoKeys55[0]->Write(0x40, 26 - 1, (iBits & 0x0200) ? 1 : 0);
|
||||
if (mask & 0x0400) // b10 Kontrolka wysokiego rozruchu
|
||||
PoKeys55[0]->Write(0x40, 31 - 1, iBits & 0x0400 ? 1 : 0);
|
||||
PoKeys55[0]->Write(0x40, 31 - 1, (iBits & 0x0400) ? 1 : 0);
|
||||
if (mask & 0x0800) // b11 Kontrolka ogrzewania pociągu
|
||||
PoKeys55[0]->Write(0x40, 34 - 1, iBits & 0x0800 ? 1 : 0);
|
||||
PoKeys55[0]->Write(0x40, 34 - 1, (iBits & 0x0800) ? 1 : 0);
|
||||
if (mask & 0x1000) // b12 Ciśnienie w cylindrach do odbijania w haslerze
|
||||
PoKeys55[0]->Write(0x40, 52 - 1, iBits & 0x1000 ? 1 : 0);
|
||||
PoKeys55[0]->Write(0x40, 52 - 1, (iBits & 0x1000) ? 1 : 0);
|
||||
if (mask & 0x2000) // b13 Prąd na silnikach do odbijania w haslerze
|
||||
PoKeys55[0]->Write(0x40, 53 - 1, iBits & 0x2000 ? 1 : 0);
|
||||
PoKeys55[0]->Write(0x40, 53 - 1, (iBits & 0x2000) ? 1 : 0);
|
||||
if (mask & 0x4000) // b14 Brzęczyk SHP lub CA
|
||||
PoKeys55[0]->Write(0x40, 16 - 1, iBits & 0x4000 ? 1 : 0);
|
||||
PoKeys55[0]->Write(0x40, 16 - 1, (iBits & 0x4000) ? 1 : 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ bool TPoKeys55::Connect()
|
||||
DeviceIDFromRegistry = reinterpret_cast<char*>(PropertyValueBuffer);
|
||||
// free(PropertyValueBuffer); //No longer need the PropertyValueBuffer,free the memory to
|
||||
// prevent potential memory leaks
|
||||
delete PropertyValueBuffer; // No longer need the PropertyValueBuffer,free the memory to
|
||||
delete[] PropertyValueBuffer; // No longer need the PropertyValueBuffer,free the memory to
|
||||
// prevent potential memory leaks
|
||||
// Convert both strings to lower case. This makes the code more robust/portable accross OS
|
||||
// Versions
|
||||
|
||||
12
Driver.cpp
12
Driver.cpp
@@ -2167,10 +2167,9 @@ void TController::SetDriverPsyche()
|
||||
|
||||
bool TController::PrepareEngine()
|
||||
{ // odpalanie silnika
|
||||
bool OK;
|
||||
bool voltfront, voltrear;
|
||||
voltfront = false;
|
||||
voltrear = false;
|
||||
bool OK = false,
|
||||
voltfront = false,
|
||||
voltrear = false;
|
||||
LastReactionTime = 0.0;
|
||||
ReactionTime = PrepareTime;
|
||||
iDrivigFlags |= moveActive; // mo<6D>e skanowa<77> sygna<6E>y i reagowa<77> na komendy
|
||||
@@ -2596,7 +2595,6 @@ bool TController::IncSpeed()
|
||||
OK = mvControlling->IncMainCtrl(1);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case WheelsDriven:
|
||||
if (!mvControlling->CabNo)
|
||||
mvControlling->CabActivisation();
|
||||
@@ -2751,7 +2749,7 @@ void TController::SpeedSet()
|
||||
break;
|
||||
case ElectricSeriesMotor:
|
||||
if ((!mvControlling->StLinFlag) && (!mvControlling->DelayCtrlFlag) &&
|
||||
(!iDrivigFlags & moveIncSpeed)) // styczniki liniowe roz<6F><7A>czone yBARC
|
||||
(!(iDrivigFlags & moveIncSpeed))) // styczniki liniowe roz<6F><7A>czone yBARC
|
||||
// if (iDrivigFlags&moveIncSpeed) {} //je<6A>li czeka na za<7A><61>czenie liniowych
|
||||
// else
|
||||
while (DecSpeed())
|
||||
@@ -2928,7 +2926,7 @@ bool TController::PutCommand(std::string NewCommand, double NewValue1, double Ne
|
||||
mvOccupied->PutCommand("Emergency_brake", 1.0, 1.0, mvOccupied->Loc);
|
||||
return true; // za<7A>atwione
|
||||
}
|
||||
else if (NewCommand.find("Timetable:") == 0)
|
||||
else if (NewCommand.compare(0, 10, "Timetable:") == 0)
|
||||
{ // przypisanie nowego rozk<7A>adu jazdy, r<>wnie<69> prowadzonemu przez u<>ytkownika
|
||||
NewCommand = NewCommand.erase(0, 10); // zostanie nazwa pliku z rozk<7A>adem
|
||||
#if LOGSTOPS
|
||||
|
||||
@@ -2915,6 +2915,7 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
delete[] PrzekrF;
|
||||
delete[] FzED;
|
||||
delete[] FzEP;
|
||||
delete[] FmaxEP;
|
||||
}
|
||||
|
||||
// yB: cos (AI) tu jest nie kompatybilne z czyms (hamulce)
|
||||
|
||||
@@ -1012,7 +1012,7 @@ char bezogonkowo[] = "E?,?\"_++?%S<STZZ?`'\"\".--??s>stzz"
|
||||
|
||||
std::string Global::Bezogonkow(std::string str, bool _)
|
||||
{ // wyciêcie liter z ogonkami, bo OpenGL nie umie wyœwietliæ
|
||||
for (unsigned int i = 1; i <= str.length(); ++i)
|
||||
for (unsigned int i = 1; i < str.length(); ++i)
|
||||
if (str[i] & 0x80)
|
||||
str[i] = bezogonkowo[str[i] & 0x7F];
|
||||
else if (str[i] < ' ') // znaki steruj¹ce nie s¹ obs³ugiwane
|
||||
|
||||
19
Ground.cpp
19
Ground.cpp
@@ -1504,9 +1504,9 @@ void TGround::RaTriangleDivider(TGroundNode *node)
|
||||
ntri->Vertices[1] = node->Vertices[1]; // wierzcho³ek B przechodzi do nowego
|
||||
// node->Vertices[1].HalfSet(node->Vertices[0],node->Vertices[1]); //na razie D tak
|
||||
if (divide & 4)
|
||||
node->Vertices[1].SetByZ(node->Vertices[0], node->Vertices[1], divide & 8 ? z1 : z0);
|
||||
node->Vertices[1].SetByZ(node->Vertices[0], node->Vertices[1], (divide & 8) ? z1 : z0);
|
||||
else
|
||||
node->Vertices[1].SetByX(node->Vertices[0], node->Vertices[1], divide & 8 ? x1 : x0);
|
||||
node->Vertices[1].SetByX(node->Vertices[0], node->Vertices[1], (divide & 8) ? x1 : x0);
|
||||
ntri->Vertices[0] = node->Vertices[1]; // wierzcho³ek D jest wspólny
|
||||
break;
|
||||
case 1: // podzia³ BC (1-2) -> ABD i ADC
|
||||
@@ -1514,9 +1514,9 @@ void TGround::RaTriangleDivider(TGroundNode *node)
|
||||
ntri->Vertices[2] = node->Vertices[2]; // wierzcho³ek C przechodzi do nowego
|
||||
// node->Vertices[2].HalfSet(node->Vertices[1],node->Vertices[2]); //na razie D tak
|
||||
if (divide & 4)
|
||||
node->Vertices[2].SetByZ(node->Vertices[1], node->Vertices[2], divide & 8 ? z1 : z0);
|
||||
node->Vertices[2].SetByZ(node->Vertices[1], node->Vertices[2], (divide & 8) ? z1 : z0);
|
||||
else
|
||||
node->Vertices[2].SetByX(node->Vertices[1], node->Vertices[2], divide & 8 ? x1 : x0);
|
||||
node->Vertices[2].SetByX(node->Vertices[1], node->Vertices[2], (divide & 8) ? x1 : x0);
|
||||
ntri->Vertices[1] = node->Vertices[2]; // wierzcho³ek D jest wspólny
|
||||
break;
|
||||
case 2: // podzia³ CA (2-0) -> ABD i DBC
|
||||
@@ -1524,9 +1524,9 @@ void TGround::RaTriangleDivider(TGroundNode *node)
|
||||
ntri->Vertices[2] = node->Vertices[2]; // wierzcho³ek C przechodzi do nowego
|
||||
// node->Vertices[2].HalfSet(node->Vertices[2],node->Vertices[0]); //na razie D tak
|
||||
if (divide & 4)
|
||||
node->Vertices[2].SetByZ(node->Vertices[2], node->Vertices[0], divide & 8 ? z1 : z0);
|
||||
node->Vertices[2].SetByZ(node->Vertices[2], node->Vertices[0], (divide & 8) ? z1 : z0);
|
||||
else
|
||||
node->Vertices[2].SetByX(node->Vertices[2], node->Vertices[0], divide & 8 ? x1 : x0);
|
||||
node->Vertices[2].SetByX(node->Vertices[2], node->Vertices[0], (divide & 8) ? x1 : x0);
|
||||
ntri->Vertices[0] = node->Vertices[2]; // wierzcho³ek D jest wspólny
|
||||
break;
|
||||
}
|
||||
@@ -2269,11 +2269,10 @@ void TGround::FirstInit()
|
||||
srGlobal.NodeAdd(Current); // dodanie do globalnego obiektu
|
||||
else if (i == TP_TERRAIN)
|
||||
{ // specjalne przetwarzanie terenu wczytanego z pliku E3D
|
||||
string xxxzzz; // nazwa kwadratu
|
||||
TGroundRect *gr;
|
||||
for (j = 1; j < Current->iCount; ++j)
|
||||
{ // od 1 do koñca s¹ zestawy trójk¹tów
|
||||
xxxzzz = string(Current->nNode[j].smTerrain->pName); // pobranie nazwy
|
||||
std::string xxxzzz = Current->nNode[j].smTerrain->pName; // pobranie nazwy
|
||||
gr = GetRect(1000 * (stol_def(xxxzzz.substr(0, 3),0) - 500),
|
||||
1000 * (stol_def(xxxzzz.substr(3, 3),0) - 500));
|
||||
if (Global::bUseVBO)
|
||||
@@ -2851,9 +2850,9 @@ bool TGround::Init(std::string asFile, HDC hDC)
|
||||
else // jak liczba to na pewno b³¹d
|
||||
Error("Unrecognized command: " + str);
|
||||
}
|
||||
else if (str == "")
|
||||
/* else if (str == "")
|
||||
break;
|
||||
|
||||
*/
|
||||
// LastNode=NULL;
|
||||
|
||||
token = "";
|
||||
|
||||
@@ -293,12 +293,12 @@ TMoverParameters::TMoverParameters(double VelInitial, std::string TypeNameInit,
|
||||
EngineType = None;
|
||||
EnginePowerSource = TPowerParameters();
|
||||
SystemPowerSource = TPowerParameters();
|
||||
for (b = 0; b <= ResArraySize + 1; b++)
|
||||
for (b = 0; b < ResArraySize + 1; ++b)
|
||||
{
|
||||
RList[b] = TScheme();
|
||||
}
|
||||
RlistSize = 0;
|
||||
for (b = 0; b <= MotorParametersArraySize + 1; b++)
|
||||
for (b = 0; b < MotorParametersArraySize + 1; ++b)
|
||||
MotorParam[b] = TMotorParameters();
|
||||
|
||||
WheelDiameter = 1.0;
|
||||
@@ -5841,10 +5841,10 @@ int Pos(std::string str_find, std::string in)
|
||||
// *************************************************************************************************
|
||||
// Q: 20160717
|
||||
// *************************************************************************************************
|
||||
bool issection(std::string name)
|
||||
bool issection(std::string const &name)
|
||||
{
|
||||
sectionname = name;
|
||||
if (xline.find(name) != std::string::npos)
|
||||
if (xline.compare(0, name.size(), name) == 0)
|
||||
{
|
||||
lastsectionname = name;
|
||||
return true;
|
||||
@@ -5943,9 +5943,10 @@ bool TMoverParameters::readMPT(int ln, std::string line)
|
||||
x = Split(line);
|
||||
|
||||
int s = x.size();
|
||||
if ( s < 7 && s > 8)
|
||||
if ( (s < 7)
|
||||
|| (s > 8) )
|
||||
{
|
||||
WriteLog("Read MPT: wrong argument number of arguments in line " + to_string(ln -1));
|
||||
WriteLog( "Read MPT: wrong number of arguments (" + std::to_string( s ) + ") in line " + std::to_string( ln - 1 ) );
|
||||
MPTLINE++;
|
||||
return false;
|
||||
}
|
||||
@@ -5991,9 +5992,10 @@ bool TMoverParameters::readRLIST(int ln, std::string line)
|
||||
x = Split(xxx); // split je wskaznik na char jak i std::string
|
||||
|
||||
int s = x.size();
|
||||
if ( s < 5 && s > 6)
|
||||
if ( ( s < 5 )
|
||||
|| ( s > 6 ))
|
||||
{
|
||||
WriteLog("Read RLIST: wrong argument number of arguments in line " + to_string(ln - 1));
|
||||
WriteLog("Read RLIST: wrong number of arguments (" + std::to_string(s) + ") in line " + std::to_string(ln - 1));
|
||||
delete[] xxx;
|
||||
RLISTLINE++;
|
||||
return false;
|
||||
@@ -6041,7 +6043,7 @@ bool TMoverParameters::readBPT(int ln, std::string line)
|
||||
int s = x.size();
|
||||
if (s != 5)
|
||||
{
|
||||
WriteLog("Read BPT: wrong argument number of arguments in line " + to_string(ln - 1));
|
||||
WriteLog( "Read BPT: wrong number of arguments (" + std::to_string( s ) + ") in line " + std::to_string( ln - 1 ) );
|
||||
delete[] xxx;
|
||||
return false;
|
||||
}
|
||||
@@ -6215,8 +6217,6 @@ TPowerType TMoverParameters::PowerDecode(std::string s)
|
||||
{
|
||||
if (s == "BioPower")
|
||||
return BioPower;
|
||||
else if (s == "BioPower")
|
||||
return BioPower;
|
||||
else if (s == "MechPower")
|
||||
return MechPower;
|
||||
else if (s == "ElectricPower")
|
||||
@@ -6360,25 +6360,34 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
|
||||
// Zbieranie danych zawartych w pliku FIZ
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
while (getline(in, wers))
|
||||
while (std::getline(in, wers))
|
||||
{
|
||||
// wers.find('#');
|
||||
xline = wers.c_str();
|
||||
ishash = xline.find("#");
|
||||
xline = wers;
|
||||
bool comment = ( ( xline.find('#') != std::string::npos )
|
||||
|| ( xline.compare( 0, 2, "//" ) == 0 ) );
|
||||
// if ((ishash == 1)) WriteLog("zakomentowane " + xline);
|
||||
if ((ishash == std::string::npos))
|
||||
if( false == comment )
|
||||
{
|
||||
|
||||
if (xline.length() == 0)
|
||||
startBPT = false; // Tablica parametyrow hamulca nie ma znacznika konca :(
|
||||
if (issection("END-MPT"))
|
||||
startMPT = false;
|
||||
if (issection("END-RL"))
|
||||
startRLIST = false;
|
||||
if( xline.length() == 0 ) {
|
||||
startBPT = false;
|
||||
continue;
|
||||
}
|
||||
if( issection( "END-MPT" ) ) {
|
||||
startBPT = false;
|
||||
startMPT = false;
|
||||
continue;
|
||||
}
|
||||
if( issection( "END-RL" ) ) {
|
||||
startBPT = false;
|
||||
startRLIST = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (issection("Param."))
|
||||
{
|
||||
secParam = true;
|
||||
startBPT = false;
|
||||
secParam = true;
|
||||
SetFlag(OKFlag, param_ok);
|
||||
aCategory = getkeyval(1, "Category");
|
||||
aType = ToUpper(getkeyval(1, "Type"));
|
||||
@@ -6389,33 +6398,39 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
aSandCap = atoi(getkeyval(2, "SandCap").c_str());
|
||||
aHeatingP = atof(getkeyval(3, "HeatingP").c_str());
|
||||
aLightP = atof(getkeyval(3, "LightP").c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (issection("Load:"))
|
||||
{
|
||||
secLoad = true;
|
||||
startBPT = false;
|
||||
secLoad = true;
|
||||
bMaxLoad = atoi(getkeyval(2, "MaxLoad").c_str());
|
||||
bLoadQ = getkeyval(1, "LoadQ");
|
||||
bLoadAccepted = getkeyval(1, "LoadAccepted");
|
||||
bLoadSpeed = atof(getkeyval(3, "LoadSpeed").c_str());
|
||||
bUnLoadSpeed = atof(getkeyval(3, "UnLoadSpeed").c_str());
|
||||
bOverLoadFactor = atof(getkeyval(3, "OverLoadFactor").c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (issection("Dimensions:"))
|
||||
{
|
||||
secDimensions = true;
|
||||
startBPT = false;
|
||||
secDimensions = true;
|
||||
SetFlag(OKFlag, dimensions_ok);
|
||||
cL = atof(getkeyval(3, "L").c_str());
|
||||
cH = atof(getkeyval(3, "H").c_str());
|
||||
cW = atof(getkeyval(3, "W").c_str());
|
||||
cCx = atof(getkeyval(3, "Cx").c_str());
|
||||
cFloor = atof(getkeyval(3, "Floor").c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (issection("Wheels:"))
|
||||
{
|
||||
secWheels = true;
|
||||
startBPT = false;
|
||||
secWheels = true;
|
||||
dD = atof(getkeyval(3, "D").c_str());
|
||||
dDl = atof(getkeyval(3, "Dl").c_str());
|
||||
dDt = atof(getkeyval(3, "Dt").c_str());
|
||||
@@ -6426,11 +6441,13 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
dBd = atof(getkeyval(3, "Bd").c_str());
|
||||
dRmin = atof(getkeyval(3, "Rmin").c_str());
|
||||
dBearingType = getkeyval(1, "BearingType");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (issection("Brake:"))
|
||||
{
|
||||
secBrake = true;
|
||||
startBPT = false;
|
||||
secBrake = true;
|
||||
eBrakeValve = getkeyval(1, "BrakeValve");
|
||||
eNBpA = atoi(getkeyval(2, "NBpA").c_str());
|
||||
eMBF = atof(getkeyval(3, "MBF").c_str());
|
||||
@@ -6460,11 +6477,13 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
eLoPP = atof(getkeyval(3, "LoPP").c_str());
|
||||
eCompressorSpeed = atof(getkeyval(3, "CompressorSpeed").c_str());
|
||||
eCompressorPower = atof(getkeyval(1, "CompressorPower").c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (issection("BuffCoupl.") || issection("BuffCoupl1."))
|
||||
{
|
||||
secBuffCoupl = true;
|
||||
startBPT = false;
|
||||
secBuffCoupl = true;
|
||||
fCType = (getkeyval(1, "CType"));
|
||||
fkB = atof(getkeyval(3, "kB").c_str());
|
||||
fDmaxB = atof(getkeyval(3, "DmaxB").c_str());
|
||||
@@ -6474,60 +6493,37 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
fFmaxC = atof(getkeyval(3, "FmaxC").c_str());
|
||||
fbeta = atof(getkeyval(3, "beta").c_str());
|
||||
fAllowedFlag = atoi(getkeyval(2, "AllowedFlag").c_str());
|
||||
}
|
||||
|
||||
if (issection("Cntrl."))
|
||||
{
|
||||
secCntrl = true;
|
||||
gBrakeSystem = (getkeyval(1, "BrakeSystem"));
|
||||
gBCPN = atoi(getkeyval(2, "BCPN").c_str());
|
||||
gBDelay1 = atoi(getkeyval(2, "BDelay1").c_str());
|
||||
gBDelay2 = atoi(getkeyval(2, "BDelay2").c_str());
|
||||
gBDelay3 = atoi(getkeyval(2, "BDelay3").c_str());
|
||||
gBDelay4 = atoi(getkeyval(2, "BDelay4").c_str());
|
||||
gASB = (getkeyval(1, "ASB"));
|
||||
gLocalBrake = (getkeyval(1, "LocalBrake"));
|
||||
gDynamicBrake = (getkeyval(1, "DynamicBrake"));
|
||||
// gManualBrake = (getkeyval(1, "ManualBrake"));
|
||||
gFSCircuit = (getkeyval(1, "FSCircuit").c_str());
|
||||
gMCPN = atoi(getkeyval(2, "MCPN").c_str());
|
||||
gSCPN = atoi(getkeyval(2, "SCPN").c_str());
|
||||
gSCIM = atoi(getkeyval(2, "SCIM").c_str());
|
||||
gScndS = (getkeyval(1, "ScndS"));
|
||||
gCoupledCtrl = (getkeyval(1, "CoupledCtrl"));
|
||||
gAutoRelay = (getkeyval(1, "AutoRelay"));
|
||||
gIniCDelay = atof(getkeyval(3, "IniCDelay").c_str());
|
||||
gSCDelay = atof(getkeyval(3, "SCDelay").c_str());
|
||||
gSCDDelay = atof(getkeyval(3, "SCDDelay").c_str());
|
||||
gBrakeDelays = (getkeyval(1, "BrakeDelays"));
|
||||
gBrakeHandle = (getkeyval(1, "BrakeHandle"));
|
||||
gLocBrakeHandle = (getkeyval(1, "LocBrakeHandle"));
|
||||
gMaxBPMass = atof(getkeyval(3, "MaxBPMass").c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (issection("Security:"))
|
||||
{
|
||||
secSecurity = true;
|
||||
startBPT = false;
|
||||
secSecurity = true;
|
||||
hAwareSystem = (getkeyval(1, "AwareSystem"));
|
||||
hAwareMinSpeed = atof(getkeyval(3, "AwareMinSpeed").c_str());
|
||||
hAwareDelay = atof(getkeyval(3, "AwareDelay").c_str());
|
||||
hSoundSignalDelay = atof(getkeyval(3, "SoundSignalDelay").c_str());
|
||||
hEmergencyBrakeDelay = atof(getkeyval(3, "EmergencyBrakeDelay").c_str());
|
||||
hRadioStop = (getkeyval(1, "RadioStop"));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (issection("Light:"))
|
||||
{
|
||||
secLight = true;
|
||||
startBPT = false;
|
||||
secLight = true;
|
||||
iLight = (getkeyval(1, "Light"));
|
||||
iLGeneratorEngine = (getkeyval(1, "LGeneratorEngine"));
|
||||
iLMaxVoltage = atof(getkeyval(3, "LMaxVoltage").c_str());
|
||||
iLMaxCurrent = atof(getkeyval(3, "LMaxCurrent").c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (issection("Power:"))
|
||||
{
|
||||
secPower = true;
|
||||
startBPT = false;
|
||||
secPower = true;
|
||||
jEnginePower = (getkeyval(1, "EnginePower"));
|
||||
jSystemPower = (getkeyval(1, "SystemPower"));
|
||||
jCollectorsNo = atoi(getkeyval(2, "CollectorsNo").c_str());
|
||||
@@ -6540,40 +6536,55 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
jMinV = atof(getkeyval(3, "MinV").c_str());
|
||||
jMinPress = atof(getkeyval(3, "MinPress").c_str());
|
||||
jMaxPress = atof(getkeyval(3, "MaxPress").c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (issection("Engine:"))
|
||||
{
|
||||
secEngine = true;
|
||||
startBPT = false;
|
||||
secEngine = true;
|
||||
kEngineType = (getkeyval(1, "EngineType"));
|
||||
kTrans = (getkeyval(1, "Trans"));
|
||||
kVolt = atof(getkeyval(3, "Volt").c_str());
|
||||
kWindingRes = atof(getkeyval(3, "WindingRes").c_str());
|
||||
knmax = atof(getkeyval(3, "nmax").c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (issection("Circuit:"))
|
||||
{
|
||||
secCircuit = true;
|
||||
startBPT = false;
|
||||
secCircuit = true;
|
||||
lCircuitRes = atof(getkeyval(3, "CircuitRes").c_str());
|
||||
lImaxLo = atoi(getkeyval(2, "ImaxLo").c_str());
|
||||
lImaxHi = atoi(getkeyval(2, "ImaxHi").c_str());
|
||||
lIminLo = atoi(getkeyval(2, "IminLo").c_str());
|
||||
lIminHi = atoi(getkeyval(2, "IminHi").c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (issection("RList:"))
|
||||
{
|
||||
secRList = true;
|
||||
startBPT = false;
|
||||
secRList = true;
|
||||
mSize = atoi(getkeyval(2, "Size").c_str());
|
||||
mRVent = (getkeyval(1, "RVent"));
|
||||
mRVentnmax = atof(getkeyval(3, "RVentnmax").c_str());
|
||||
mRVentCutOff = atof(getkeyval(3, "RVentCutOff").c_str());
|
||||
// don't close loop yet, init data table
|
||||
}
|
||||
|
||||
if (issection("DList:"))
|
||||
if( issection( "RList:" ) || startRLIST ) {
|
||||
startBPT = false;
|
||||
secRList = true;
|
||||
readRLIST( RLISTLINE, xline );
|
||||
continue;
|
||||
}
|
||||
|
||||
if( issection( "DList:" ) )
|
||||
{
|
||||
secDList = true;
|
||||
startBPT = false;
|
||||
secDList = true;
|
||||
nMmax = atof(getkeyval(3, "Mmax").c_str());
|
||||
nnMmax = atof(getkeyval(3, "nMmax").c_str());
|
||||
nMnmax = atof(getkeyval(3, "Mnmax").c_str());
|
||||
@@ -6581,45 +6592,78 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
nnominalfill = atof(getkeyval(3, "nominalfill").c_str());
|
||||
nMstand = atof(getkeyval(3, "Mstand").c_str());
|
||||
nSize = atoi(getkeyval(2, "Size").c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (issection("WWList:"))
|
||||
{
|
||||
secWWList = true;
|
||||
startBPT = false;
|
||||
secWWList = true;
|
||||
getkeyval(2, "Size");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (issection("ffList:"))
|
||||
{
|
||||
secffList = true;
|
||||
startBPT = false;
|
||||
secffList = true;
|
||||
getkeyval(2, "Size");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (issection("TurboPos:"))
|
||||
{
|
||||
secTurboPos = true;
|
||||
startBPT = false;
|
||||
secTurboPos = true;
|
||||
getkeyval(2, "TurboPos");
|
||||
}
|
||||
|
||||
if (issection("Cntrl.") || startBPT)
|
||||
{
|
||||
secBPT = true;
|
||||
if (gBCPN > 0)
|
||||
readBPT(BPTLINE, xline); // np wagony nie maja BPT
|
||||
continue;
|
||||
}
|
||||
|
||||
if (issection("MotorParamTable0:") || startMPT)
|
||||
{
|
||||
secMotorParamTable0 = true;
|
||||
startBPT = false;
|
||||
secMotorParamTable0 = true;
|
||||
readMPT(MPTLINE, xline);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (issection("RList:") || startRLIST)
|
||||
{
|
||||
secRList = true;
|
||||
readRLIST(RLISTLINE, xline);
|
||||
}
|
||||
} // is hash
|
||||
if( issection( "Cntrl." ) ) {
|
||||
startBPT = false;
|
||||
secCntrl = true;
|
||||
gBrakeSystem = ( getkeyval( 1, "BrakeSystem" ) );
|
||||
gBCPN = atoi( getkeyval( 2, "BCPN" ).c_str() );
|
||||
gBDelay1 = atoi( getkeyval( 2, "BDelay1" ).c_str() );
|
||||
gBDelay2 = atoi( getkeyval( 2, "BDelay2" ).c_str() );
|
||||
gBDelay3 = atoi( getkeyval( 2, "BDelay3" ).c_str() );
|
||||
gBDelay4 = atoi( getkeyval( 2, "BDelay4" ).c_str() );
|
||||
gASB = ( getkeyval( 1, "ASB" ) );
|
||||
gLocalBrake = ( getkeyval( 1, "LocalBrake" ) );
|
||||
gDynamicBrake = ( getkeyval( 1, "DynamicBrake" ) );
|
||||
// gManualBrake = (getkeyval(1, "ManualBrake"));
|
||||
gFSCircuit = ( getkeyval( 1, "FSCircuit" ).c_str() );
|
||||
gMCPN = atoi( getkeyval( 2, "MCPN" ).c_str() );
|
||||
gSCPN = atoi( getkeyval( 2, "SCPN" ).c_str() );
|
||||
gSCIM = atoi( getkeyval( 2, "SCIM" ).c_str() );
|
||||
gScndS = ( getkeyval( 1, "ScndS" ) );
|
||||
gCoupledCtrl = ( getkeyval( 1, "CoupledCtrl" ) );
|
||||
gAutoRelay = ( getkeyval( 1, "AutoRelay" ) );
|
||||
gIniCDelay = atof( getkeyval( 3, "IniCDelay" ).c_str() );
|
||||
gSCDelay = atof( getkeyval( 3, "SCDelay" ).c_str() );
|
||||
gSCDDelay = atof( getkeyval( 3, "SCDDelay" ).c_str() );
|
||||
gBrakeDelays = ( getkeyval( 1, "BrakeDelays" ) );
|
||||
gBrakeHandle = ( getkeyval( 1, "BrakeHandle" ) );
|
||||
gLocBrakeHandle = ( getkeyval( 1, "LocBrakeHandle" ) );
|
||||
gMaxBPMass = atof( getkeyval( 3, "MaxBPMass" ).c_str() );
|
||||
// don't break yet, init (optional) data table
|
||||
}
|
||||
|
||||
if( issection( "Cntrl." ) || startBPT ) {
|
||||
secBPT = true;
|
||||
if( gBCPN > 0 )
|
||||
readBPT( BPTLINE, xline ); // np wagony nie maja BPT
|
||||
continue;
|
||||
}
|
||||
} // is hash
|
||||
} // while line
|
||||
in.close();
|
||||
// Sprawdzenie poprawnosci wczytanych parametrow
|
||||
|
||||
@@ -208,7 +208,7 @@ std::string TrimSpace(std::string &s, int Just)
|
||||
|
||||
char* TrimAndReduceSpaces(const char* s)
|
||||
{ // redukuje spacje pomiedzy znakami do jednej
|
||||
char* tmp;
|
||||
char* tmp = nullptr;
|
||||
if (s)
|
||||
{
|
||||
|
||||
@@ -422,11 +422,11 @@ int stol_def(const std::string &str, const int &DefaultValue)
|
||||
std::strncpy(s, str.c_str(), len);
|
||||
char *p;
|
||||
int result = strtol(s, &p, 0);
|
||||
if ((*p != '\0') || (errno != 0))
|
||||
delete[] s;
|
||||
if( ( *p != '\0' ) || ( errno != 0 ) )
|
||||
{
|
||||
return DefaultValue;
|
||||
}
|
||||
delete s;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -287,7 +287,7 @@ int TSubModel::Load(cParser &parser, TModel3d *Model, int Pos, bool dynamic)
|
||||
}
|
||||
else // dla pozosta³ych modeli blokujemy zapalone œwiat³a, które mog¹ byæ
|
||||
// nieobs³ugiwane
|
||||
if (token.find("Light_On") == 0) // jeœli nazwa zaczyna siê od "Light_On"
|
||||
if (token.compare(0, 8, "Light_On") == 0) // jeœli nazwa zaczyna siê od "Light_On"
|
||||
iVisible = 0; // to domyœlnie wy³¹czyæ, ¿eby siê nie nak³ada³o z obiektem
|
||||
// "Light_Off"
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ void TRealSound::Play(double Volume, int Looping, bool ListenerInside, vector3 N
|
||||
if (!pSound)
|
||||
return;
|
||||
long int vol;
|
||||
double dS;
|
||||
double dS = 0.0;
|
||||
// double Distance;
|
||||
DWORD stat;
|
||||
if ((Global::bSoundEnabled) && (AM != 0))
|
||||
|
||||
@@ -58,7 +58,7 @@ void ResourceManager::Sweep(double currentTime)
|
||||
WriteLog("Releasing resources");
|
||||
#endif
|
||||
|
||||
for (Resources::iterator iter = begin; iter != _resources.end(); iter++)
|
||||
for (Resources::iterator iter = begin; iter != _resources.end(); ++iter)
|
||||
(*iter)->Release();
|
||||
|
||||
#ifdef RESOURCE_REPORTING
|
||||
|
||||
26
Segment.cpp
26
Segment.cpp
@@ -200,33 +200,29 @@ double TSegment::RombergIntegral(double fA, double fB)
|
||||
double TSegment::GetTFromS(double s)
|
||||
{
|
||||
// initial guess for Newton's method
|
||||
int it = 0;
|
||||
double fTolerance = 0.001;
|
||||
double fRatio = s / RombergIntegral(0, 1);
|
||||
double fOmRatio = 1.0 - fRatio;
|
||||
double fTime = fOmRatio * 0 + fRatio * 1;
|
||||
int iteration = 0;
|
||||
|
||||
// for (int i = 0; i < iIterations; i++)
|
||||
while (true)
|
||||
{
|
||||
it++;
|
||||
if (it > 10)
|
||||
{
|
||||
ErrorLog("Bad geometry: Too many iterations at " + Where(Point1));
|
||||
// MessageBox(0,"Too many iterations","GetTFromS",MB_OK);
|
||||
return fTime;
|
||||
}
|
||||
|
||||
do {
|
||||
double fDifference = RombergIntegral(0, fTime) - s;
|
||||
if ((fDifference > 0 ? fDifference : -fDifference) < fTolerance)
|
||||
return fTime;
|
||||
if( ( fDifference > 0 ? fDifference : -fDifference ) < fTolerance ) {
|
||||
return fTime;
|
||||
}
|
||||
|
||||
fTime -= fDifference / GetFirstDerivative(fTime).Length();
|
||||
}
|
||||
++iteration;
|
||||
}
|
||||
while( iteration < 10 ); // arbitrary limit
|
||||
|
||||
// Newton's method failed. If this happens, increase iterations or
|
||||
// tolerance or integration accuracy.
|
||||
// return -1; //Ra: tu nigdy nie dojdzie
|
||||
ErrorLog( "Bad geometry: Too many iterations at " + Where( Point1 ) );
|
||||
// MessageBox(0,"Too many iterations","GetTFromS",MB_OK);
|
||||
return fTime;
|
||||
};
|
||||
|
||||
vector3 TSegment::RaInterpolate(double t)
|
||||
|
||||
16
Sound.cpp
16
Sound.cpp
@@ -56,8 +56,8 @@ TSoundContainer::TSoundContainer(LPDIRECTSOUND pDS, const char *Directory, const
|
||||
if (FAILED(pWaveSoundRead->Open(strdup(strFileName))))
|
||||
{
|
||||
// SetFileUI( hDlg, TEXT("Bad wave file.") );
|
||||
return;
|
||||
ErrorLog( "Missed sound: " + std::string(strFileName) );
|
||||
ErrorLog( "Missed sound: " + std::string( strFileName ) );
|
||||
return;
|
||||
}
|
||||
|
||||
strcpy(Name, ToLower(strFileName).c_str());
|
||||
@@ -108,16 +108,20 @@ TSoundContainer::TSoundContainer(LPDIRECTSOUND pDS, const char *Directory, const
|
||||
return; // E_OUTOFMEMORY;
|
||||
|
||||
// if (FAILED(hr=pWaveSoundRead->Read( nWaveFileSize,pbWavData,&cbWavSize)))
|
||||
if (FAILED(hr = pWaveSoundRead->Read(nWaveFileSize, pbWavData, &cbWavSize)))
|
||||
return;
|
||||
if( FAILED( hr = pWaveSoundRead->Read( nWaveFileSize, pbWavData, &cbWavSize ) ) ) {
|
||||
delete[] pbWavData;
|
||||
return;
|
||||
}
|
||||
|
||||
// Reset the file to the beginning
|
||||
pWaveSoundRead->Reset();
|
||||
|
||||
// Lock the buffer down
|
||||
// if (FAILED(hr=DSBuffer->Lock(0,dwBufferBytes,&pbData,&dwLength,&pbData2,&dwLength2,0)))
|
||||
if (FAILED(hr = DSBuffer->Lock(0, dwBufferBytes, &pbData, &dwLength, &pbData2, &dwLength2, 0L)))
|
||||
return;
|
||||
if( FAILED( hr = DSBuffer->Lock( 0, dwBufferBytes, &pbData, &dwLength, &pbData2, &dwLength2, 0L ) ) ) {
|
||||
delete[] pbWavData;
|
||||
return;
|
||||
}
|
||||
|
||||
// Copy the memory to it.
|
||||
memcpy(pbData, pbWavData, dwBufferBytes);
|
||||
|
||||
@@ -868,7 +868,7 @@ void TTexturesManager::Free()
|
||||
{ // usuniêcie wszyskich tekstur (bez usuwania struktury)
|
||||
// for (Names::iterator iter = _names.begin(); iter != _names.end(); iter++)
|
||||
if( false == _names.empty() ) {
|
||||
for( auto texture : _names ) {
|
||||
for( auto const &texture : _names ) {
|
||||
glDeleteTextures( 1, &texture.second );
|
||||
}
|
||||
}
|
||||
@@ -876,8 +876,8 @@ void TTexturesManager::Free()
|
||||
|
||||
std::string TTexturesManager::GetName(GLuint id)
|
||||
{ // pobranie nazwy tekstury
|
||||
for (Names::iterator iter = _names.begin(); iter != _names.end(); iter++)
|
||||
if (iter->second == id)
|
||||
return iter->first;
|
||||
for( auto const &pair : _names ) {
|
||||
if( pair.second == id ) { return pair.first; }
|
||||
}
|
||||
return "";
|
||||
};
|
||||
|
||||
@@ -668,7 +668,9 @@ bool TWorld::Init(HWND NhWnd, HDC hDC)
|
||||
light = TTexturesManager::GetTextureID(szTexturePath, szSceneryPath, "smuga2.tga");
|
||||
// Camera.Reset();
|
||||
Timer::ResetTimers();
|
||||
WriteLog( "Load time: " + std::to_string( ( std::chrono::system_clock::now() - timestart ).count() ) + " seconds");
|
||||
WriteLog( "Load time: " +
|
||||
std::to_string( std::chrono::duration_cast<std::chrono::seconds>(( std::chrono::system_clock::now() - timestart )).count() )
|
||||
+ " seconds");
|
||||
if (DebugModeFlag) // w Debugmode automatyczne w³¹czenie AI
|
||||
if (Train)
|
||||
if (Train->Dynamic()->Mechanik)
|
||||
@@ -2078,7 +2080,7 @@ bool TWorld::Update()
|
||||
std::string flags = "bwaccmlshhhoibsgvdp; "; // flagi AI (definicja w Driver.h)
|
||||
for (int i = 0, j = 1; i < 19; ++i, j <<= 1)
|
||||
if (tmp->Mechanik->DrivigFlags() & j) // jak bit ustawiony
|
||||
toupper(flags[i + 1]); // ^= 0x20; // to zmiana na wielk¹ literê
|
||||
flags[i + 1] = std::toupper(flags[i + 1]); // ^= 0x20; // to zmiana na wielk¹ literê
|
||||
OutText4 = flags;
|
||||
OutText4 +=
|
||||
("Driver: Vd=") +
|
||||
|
||||
@@ -158,7 +158,8 @@ std::string cParser::readToken(bool ToLower, const char *Break)
|
||||
// if (trtest=="x") //jeœli nie wczytywaæ drutów
|
||||
// trtest2=includefile; //kopiowanie œcie¿ki do pliku
|
||||
std::string parameter = readToken(false); // w parametrach nie zmniejszamy
|
||||
while (parameter.compare("end") != 0)
|
||||
while( (parameter.empty() == false)
|
||||
&& (parameter.compare("end") != 0) )
|
||||
{
|
||||
parameters.push_back(parameter);
|
||||
parameter = readToken(ToLower);
|
||||
|
||||
Reference in New Issue
Block a user