16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-24 09:49:18 +02:00

fixed some potential memory leaks and other errors detected by cppcheck

This commit is contained in:
tmj-fstate
2017-01-16 13:26:36 +01:00
parent 15cf3d73a8
commit 68e5dd84e0
18 changed files with 202 additions and 155 deletions

View File

@@ -60,11 +60,13 @@ void TAdvancedSound::Load(cParser &Parser, vector3 const &pPosition)
{ {
std::string nameon, name, nameoff; std::string nameon, name, nameoff;
double attenuation; double attenuation;
Parser.getTokens( 4 ); Parser.getTokens( 3, true, "\n\t ;," ); // samples separated with commas
Parser Parser
>> nameon >> nameon
>> name >> name
>> nameoff >> nameoff;
Parser.getTokens( 1, false );
Parser
>> attenuation; >> attenuation;
Init( nameon, name, nameoff, attenuation, pPosition ); Init( nameon, name, nameoff, attenuation, pPosition );
} }

View File

@@ -752,10 +752,10 @@ void TAnimModel::AnimationVND(void *pData, double a, double b, double c, double
} }
*/ */
int i, j, k, idx; /* int i, j, k, idx;
std::string name; */ std::string name;
TAnimContainer *pSub; 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())) if (strcmp(pAdvanced->pMovementData[i].cBone, name.c_str()))
{ // jeśli pozycja w tabelce nie była wyszukiwana w submodelach { // jeśli pozycja w tabelce nie była wyszukiwana w submodelach

View File

@@ -248,35 +248,35 @@ void Console::BitsUpdate(int mask)
if (PoKeys55[0]) if (PoKeys55[0])
{ // pewnie trzeba będzie to dodatkowo buforować i oczekiwać na potwierdzenie { // pewnie trzeba będzie to dodatkowo buforować i oczekiwać na potwierdzenie
if (mask & 0x0001) // b0 gdy SHP 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 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 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) 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 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 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 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" 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 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 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 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 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 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 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 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; break;
} }

View File

@@ -138,7 +138,7 @@ bool TPoKeys55::Connect()
DeviceIDFromRegistry = reinterpret_cast<char*>(PropertyValueBuffer); DeviceIDFromRegistry = reinterpret_cast<char*>(PropertyValueBuffer);
// free(PropertyValueBuffer); //No longer need the PropertyValueBuffer,free the memory to // free(PropertyValueBuffer); //No longer need the PropertyValueBuffer,free the memory to
// prevent potential memory leaks // 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 // prevent potential memory leaks
// Convert both strings to lower case. This makes the code more robust/portable accross OS // Convert both strings to lower case. This makes the code more robust/portable accross OS
// Versions // Versions

View File

@@ -2167,9 +2167,8 @@ void TController::SetDriverPsyche()
bool TController::PrepareEngine() bool TController::PrepareEngine()
{ // odpalanie silnika { // odpalanie silnika
bool OK; bool OK = false,
bool voltfront, voltrear; voltfront = false,
voltfront = false;
voltrear = false; voltrear = false;
LastReactionTime = 0.0; LastReactionTime = 0.0;
ReactionTime = PrepareTime; ReactionTime = PrepareTime;
@@ -2596,7 +2595,6 @@ bool TController::IncSpeed()
OK = mvControlling->IncMainCtrl(1); OK = mvControlling->IncMainCtrl(1);
} }
break; break;
break;
case WheelsDriven: case WheelsDriven:
if (!mvControlling->CabNo) if (!mvControlling->CabNo)
mvControlling->CabActivisation(); mvControlling->CabActivisation();
@@ -2751,7 +2749,7 @@ void TController::SpeedSet()
break; break;
case ElectricSeriesMotor: case ElectricSeriesMotor:
if ((!mvControlling->StLinFlag) && (!mvControlling->DelayCtrlFlag) && 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 // if (iDrivigFlags&moveIncSpeed) {} //je<6A>li czeka na za<7A><61>czenie liniowych
// else // else
while (DecSpeed()) 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); mvOccupied->PutCommand("Emergency_brake", 1.0, 1.0, mvOccupied->Loc);
return true; // za<7A>atwione 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 { // 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 NewCommand = NewCommand.erase(0, 10); // zostanie nazwa pliku z rozk<7A>adem
#if LOGSTOPS #if LOGSTOPS

View File

@@ -2915,6 +2915,7 @@ bool TDynamicObject::Update(double dt, double dt1)
delete[] PrzekrF; delete[] PrzekrF;
delete[] FzED; delete[] FzED;
delete[] FzEP; delete[] FzEP;
delete[] FmaxEP;
} }
// yB: cos (AI) tu jest nie kompatybilne z czyms (hamulce) // yB: cos (AI) tu jest nie kompatybilne z czyms (hamulce)

View File

@@ -1012,7 +1012,7 @@ char bezogonkowo[] = "E?,?\"_++?%S<STZZ?`'\"\".--??s>stzz"
std::string Global::Bezogonkow(std::string str, bool _) std::string Global::Bezogonkow(std::string str, bool _)
{ // wyciêcie liter z ogonkami, bo OpenGL nie umie wyœwietliæ { // 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) if (str[i] & 0x80)
str[i] = bezogonkowo[str[i] & 0x7F]; str[i] = bezogonkowo[str[i] & 0x7F];
else if (str[i] < ' ') // znaki steruj¹ce nie s¹ obs³ugiwane else if (str[i] < ' ') // znaki steruj¹ce nie s¹ obs³ugiwane

View File

@@ -1504,9 +1504,9 @@ void TGround::RaTriangleDivider(TGroundNode *node)
ntri->Vertices[1] = node->Vertices[1]; // wierzcho³ek B przechodzi do nowego 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 // node->Vertices[1].HalfSet(node->Vertices[0],node->Vertices[1]); //na razie D tak
if (divide & 4) 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 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 ntri->Vertices[0] = node->Vertices[1]; // wierzcho³ek D jest wspólny
break; break;
case 1: // podzia³ BC (1-2) -> ABD i ADC 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 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 // node->Vertices[2].HalfSet(node->Vertices[1],node->Vertices[2]); //na razie D tak
if (divide & 4) 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 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 ntri->Vertices[1] = node->Vertices[2]; // wierzcho³ek D jest wspólny
break; break;
case 2: // podzia³ CA (2-0) -> ABD i DBC 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 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 // node->Vertices[2].HalfSet(node->Vertices[2],node->Vertices[0]); //na razie D tak
if (divide & 4) 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 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 ntri->Vertices[0] = node->Vertices[2]; // wierzcho³ek D jest wspólny
break; break;
} }
@@ -2269,11 +2269,10 @@ void TGround::FirstInit()
srGlobal.NodeAdd(Current); // dodanie do globalnego obiektu srGlobal.NodeAdd(Current); // dodanie do globalnego obiektu
else if (i == TP_TERRAIN) else if (i == TP_TERRAIN)
{ // specjalne przetwarzanie terenu wczytanego z pliku E3D { // specjalne przetwarzanie terenu wczytanego z pliku E3D
string xxxzzz; // nazwa kwadratu
TGroundRect *gr; TGroundRect *gr;
for (j = 1; j < Current->iCount; ++j) for (j = 1; j < Current->iCount; ++j)
{ // od 1 do koñca s¹ zestawy trójk¹tów { // 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), gr = GetRect(1000 * (stol_def(xxxzzz.substr(0, 3),0) - 500),
1000 * (stol_def(xxxzzz.substr(3, 3),0) - 500)); 1000 * (stol_def(xxxzzz.substr(3, 3),0) - 500));
if (Global::bUseVBO) if (Global::bUseVBO)
@@ -2851,9 +2850,9 @@ bool TGround::Init(std::string asFile, HDC hDC)
else // jak liczba to na pewno b³¹d else // jak liczba to na pewno b³¹d
Error("Unrecognized command: " + str); Error("Unrecognized command: " + str);
} }
else if (str == "") /* else if (str == "")
break; break;
*/
// LastNode=NULL; // LastNode=NULL;
token = ""; token = "";

View File

@@ -293,12 +293,12 @@ TMoverParameters::TMoverParameters(double VelInitial, std::string TypeNameInit,
EngineType = None; EngineType = None;
EnginePowerSource = TPowerParameters(); EnginePowerSource = TPowerParameters();
SystemPowerSource = TPowerParameters(); SystemPowerSource = TPowerParameters();
for (b = 0; b <= ResArraySize + 1; b++) for (b = 0; b < ResArraySize + 1; ++b)
{ {
RList[b] = TScheme(); RList[b] = TScheme();
} }
RlistSize = 0; RlistSize = 0;
for (b = 0; b <= MotorParametersArraySize + 1; b++) for (b = 0; b < MotorParametersArraySize + 1; ++b)
MotorParam[b] = TMotorParameters(); MotorParam[b] = TMotorParameters();
WheelDiameter = 1.0; WheelDiameter = 1.0;
@@ -5841,10 +5841,10 @@ int Pos(std::string str_find, std::string in)
// ************************************************************************************************* // *************************************************************************************************
// Q: 20160717 // Q: 20160717
// ************************************************************************************************* // *************************************************************************************************
bool issection(std::string name) bool issection(std::string const &name)
{ {
sectionname = name; sectionname = name;
if (xline.find(name) != std::string::npos) if (xline.compare(0, name.size(), name) == 0)
{ {
lastsectionname = name; lastsectionname = name;
return true; return true;
@@ -5943,9 +5943,10 @@ bool TMoverParameters::readMPT(int ln, std::string line)
x = Split(line); x = Split(line);
int s = x.size(); 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++; MPTLINE++;
return false; 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 x = Split(xxx); // split je wskaznik na char jak i std::string
int s = x.size(); 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; delete[] xxx;
RLISTLINE++; RLISTLINE++;
return false; return false;
@@ -6041,7 +6043,7 @@ bool TMoverParameters::readBPT(int ln, std::string line)
int s = x.size(); int s = x.size();
if (s != 5) 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; delete[] xxx;
return false; return false;
} }
@@ -6215,8 +6217,6 @@ TPowerType TMoverParameters::PowerDecode(std::string s)
{ {
if (s == "BioPower") if (s == "BioPower")
return BioPower; return BioPower;
else if (s == "BioPower")
return BioPower;
else if (s == "MechPower") else if (s == "MechPower")
return MechPower; return MechPower;
else if (s == "ElectricPower") else if (s == "ElectricPower")
@@ -6360,24 +6360,33 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
// Zbieranie danych zawartych w pliku FIZ // Zbieranie danych zawartych w pliku FIZ
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
while (getline(in, wers)) while (std::getline(in, wers))
{ {
// wers.find('#'); // wers.find('#');
xline = wers.c_str(); xline = wers;
ishash = xline.find("#"); bool comment = ( ( xline.find('#') != std::string::npos )
|| ( xline.compare( 0, 2, "//" ) == 0 ) );
// if ((ishash == 1)) WriteLog("zakomentowane " + xline); // if ((ishash == 1)) WriteLog("zakomentowane " + xline);
if ((ishash == std::string::npos)) if( false == comment )
{ {
if( xline.length() == 0 ) {
if (xline.length() == 0) startBPT = false;
startBPT = false; // Tablica parametyrow hamulca nie ma znacznika konca :( continue;
if (issection("END-MPT")) }
if( issection( "END-MPT" ) ) {
startBPT = false;
startMPT = false; startMPT = false;
if (issection("END-RL")) continue;
}
if( issection( "END-RL" ) ) {
startBPT = false;
startRLIST = false; startRLIST = false;
continue;
}
if (issection("Param.")) if (issection("Param."))
{ {
startBPT = false;
secParam = true; secParam = true;
SetFlag(OKFlag, param_ok); SetFlag(OKFlag, param_ok);
aCategory = getkeyval(1, "Category"); aCategory = getkeyval(1, "Category");
@@ -6389,10 +6398,12 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
aSandCap = atoi(getkeyval(2, "SandCap").c_str()); aSandCap = atoi(getkeyval(2, "SandCap").c_str());
aHeatingP = atof(getkeyval(3, "HeatingP").c_str()); aHeatingP = atof(getkeyval(3, "HeatingP").c_str());
aLightP = atof(getkeyval(3, "LightP").c_str()); aLightP = atof(getkeyval(3, "LightP").c_str());
continue;
} }
if (issection("Load:")) if (issection("Load:"))
{ {
startBPT = false;
secLoad = true; secLoad = true;
bMaxLoad = atoi(getkeyval(2, "MaxLoad").c_str()); bMaxLoad = atoi(getkeyval(2, "MaxLoad").c_str());
bLoadQ = getkeyval(1, "LoadQ"); bLoadQ = getkeyval(1, "LoadQ");
@@ -6400,10 +6411,12 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
bLoadSpeed = atof(getkeyval(3, "LoadSpeed").c_str()); bLoadSpeed = atof(getkeyval(3, "LoadSpeed").c_str());
bUnLoadSpeed = atof(getkeyval(3, "UnLoadSpeed").c_str()); bUnLoadSpeed = atof(getkeyval(3, "UnLoadSpeed").c_str());
bOverLoadFactor = atof(getkeyval(3, "OverLoadFactor").c_str()); bOverLoadFactor = atof(getkeyval(3, "OverLoadFactor").c_str());
continue;
} }
if (issection("Dimensions:")) if (issection("Dimensions:"))
{ {
startBPT = false;
secDimensions = true; secDimensions = true;
SetFlag(OKFlag, dimensions_ok); SetFlag(OKFlag, dimensions_ok);
cL = atof(getkeyval(3, "L").c_str()); cL = atof(getkeyval(3, "L").c_str());
@@ -6411,10 +6424,12 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
cW = atof(getkeyval(3, "W").c_str()); cW = atof(getkeyval(3, "W").c_str());
cCx = atof(getkeyval(3, "Cx").c_str()); cCx = atof(getkeyval(3, "Cx").c_str());
cFloor = atof(getkeyval(3, "Floor").c_str()); cFloor = atof(getkeyval(3, "Floor").c_str());
continue;
} }
if (issection("Wheels:")) if (issection("Wheels:"))
{ {
startBPT = false;
secWheels = true; secWheels = true;
dD = atof(getkeyval(3, "D").c_str()); dD = atof(getkeyval(3, "D").c_str());
dDl = atof(getkeyval(3, "Dl").c_str()); dDl = atof(getkeyval(3, "Dl").c_str());
@@ -6426,10 +6441,12 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
dBd = atof(getkeyval(3, "Bd").c_str()); dBd = atof(getkeyval(3, "Bd").c_str());
dRmin = atof(getkeyval(3, "Rmin").c_str()); dRmin = atof(getkeyval(3, "Rmin").c_str());
dBearingType = getkeyval(1, "BearingType"); dBearingType = getkeyval(1, "BearingType");
continue;
} }
if (issection("Brake:")) if (issection("Brake:"))
{ {
startBPT = false;
secBrake = true; secBrake = true;
eBrakeValve = getkeyval(1, "BrakeValve"); eBrakeValve = getkeyval(1, "BrakeValve");
eNBpA = atoi(getkeyval(2, "NBpA").c_str()); eNBpA = atoi(getkeyval(2, "NBpA").c_str());
@@ -6460,10 +6477,12 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
eLoPP = atof(getkeyval(3, "LoPP").c_str()); eLoPP = atof(getkeyval(3, "LoPP").c_str());
eCompressorSpeed = atof(getkeyval(3, "CompressorSpeed").c_str()); eCompressorSpeed = atof(getkeyval(3, "CompressorSpeed").c_str());
eCompressorPower = atof(getkeyval(1, "CompressorPower").c_str()); eCompressorPower = atof(getkeyval(1, "CompressorPower").c_str());
continue;
} }
if (issection("BuffCoupl.") || issection("BuffCoupl1.")) if (issection("BuffCoupl.") || issection("BuffCoupl1."))
{ {
startBPT = false;
secBuffCoupl = true; secBuffCoupl = true;
fCType = (getkeyval(1, "CType")); fCType = (getkeyval(1, "CType"));
fkB = atof(getkeyval(3, "kB").c_str()); fkB = atof(getkeyval(3, "kB").c_str());
@@ -6474,39 +6493,12 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
fFmaxC = atof(getkeyval(3, "FmaxC").c_str()); fFmaxC = atof(getkeyval(3, "FmaxC").c_str());
fbeta = atof(getkeyval(3, "beta").c_str()); fbeta = atof(getkeyval(3, "beta").c_str());
fAllowedFlag = atoi(getkeyval(2, "AllowedFlag").c_str()); fAllowedFlag = atoi(getkeyval(2, "AllowedFlag").c_str());
} continue;
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());
} }
if (issection("Security:")) if (issection("Security:"))
{ {
startBPT = false;
secSecurity = true; secSecurity = true;
hAwareSystem = (getkeyval(1, "AwareSystem")); hAwareSystem = (getkeyval(1, "AwareSystem"));
hAwareMinSpeed = atof(getkeyval(3, "AwareMinSpeed").c_str()); hAwareMinSpeed = atof(getkeyval(3, "AwareMinSpeed").c_str());
@@ -6514,19 +6506,23 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
hSoundSignalDelay = atof(getkeyval(3, "SoundSignalDelay").c_str()); hSoundSignalDelay = atof(getkeyval(3, "SoundSignalDelay").c_str());
hEmergencyBrakeDelay = atof(getkeyval(3, "EmergencyBrakeDelay").c_str()); hEmergencyBrakeDelay = atof(getkeyval(3, "EmergencyBrakeDelay").c_str());
hRadioStop = (getkeyval(1, "RadioStop")); hRadioStop = (getkeyval(1, "RadioStop"));
continue;
} }
if (issection("Light:")) if (issection("Light:"))
{ {
startBPT = false;
secLight = true; secLight = true;
iLight = (getkeyval(1, "Light")); iLight = (getkeyval(1, "Light"));
iLGeneratorEngine = (getkeyval(1, "LGeneratorEngine")); iLGeneratorEngine = (getkeyval(1, "LGeneratorEngine"));
iLMaxVoltage = atof(getkeyval(3, "LMaxVoltage").c_str()); iLMaxVoltage = atof(getkeyval(3, "LMaxVoltage").c_str());
iLMaxCurrent = atof(getkeyval(3, "LMaxCurrent").c_str()); iLMaxCurrent = atof(getkeyval(3, "LMaxCurrent").c_str());
continue;
} }
if (issection("Power:")) if (issection("Power:"))
{ {
startBPT = false;
secPower = true; secPower = true;
jEnginePower = (getkeyval(1, "EnginePower")); jEnginePower = (getkeyval(1, "EnginePower"));
jSystemPower = (getkeyval(1, "SystemPower")); jSystemPower = (getkeyval(1, "SystemPower"));
@@ -6540,39 +6536,54 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
jMinV = atof(getkeyval(3, "MinV").c_str()); jMinV = atof(getkeyval(3, "MinV").c_str());
jMinPress = atof(getkeyval(3, "MinPress").c_str()); jMinPress = atof(getkeyval(3, "MinPress").c_str());
jMaxPress = atof(getkeyval(3, "MaxPress").c_str()); jMaxPress = atof(getkeyval(3, "MaxPress").c_str());
continue;
} }
if (issection("Engine:")) if (issection("Engine:"))
{ {
startBPT = false;
secEngine = true; secEngine = true;
kEngineType = (getkeyval(1, "EngineType")); kEngineType = (getkeyval(1, "EngineType"));
kTrans = (getkeyval(1, "Trans")); kTrans = (getkeyval(1, "Trans"));
kVolt = atof(getkeyval(3, "Volt").c_str()); kVolt = atof(getkeyval(3, "Volt").c_str());
kWindingRes = atof(getkeyval(3, "WindingRes").c_str()); kWindingRes = atof(getkeyval(3, "WindingRes").c_str());
knmax = atof(getkeyval(3, "nmax").c_str()); knmax = atof(getkeyval(3, "nmax").c_str());
continue;
} }
if (issection("Circuit:")) if (issection("Circuit:"))
{ {
startBPT = false;
secCircuit = true; secCircuit = true;
lCircuitRes = atof(getkeyval(3, "CircuitRes").c_str()); lCircuitRes = atof(getkeyval(3, "CircuitRes").c_str());
lImaxLo = atoi(getkeyval(2, "ImaxLo").c_str()); lImaxLo = atoi(getkeyval(2, "ImaxLo").c_str());
lImaxHi = atoi(getkeyval(2, "ImaxHi").c_str()); lImaxHi = atoi(getkeyval(2, "ImaxHi").c_str());
lIminLo = atoi(getkeyval(2, "IminLo").c_str()); lIminLo = atoi(getkeyval(2, "IminLo").c_str());
lIminHi = atoi(getkeyval(2, "IminHi").c_str()); lIminHi = atoi(getkeyval(2, "IminHi").c_str());
continue;
} }
if (issection("RList:")) if (issection("RList:"))
{ {
startBPT = false;
secRList = true; secRList = true;
mSize = atoi(getkeyval(2, "Size").c_str()); mSize = atoi(getkeyval(2, "Size").c_str());
mRVent = (getkeyval(1, "RVent")); mRVent = (getkeyval(1, "RVent"));
mRVentnmax = atof(getkeyval(3, "RVentnmax").c_str()); mRVentnmax = atof(getkeyval(3, "RVentnmax").c_str());
mRVentCutOff = atof(getkeyval(3, "RVentCutOff").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:" ) )
{ {
startBPT = false;
secDList = true; secDList = true;
nMmax = atof(getkeyval(3, "Mmax").c_str()); nMmax = atof(getkeyval(3, "Mmax").c_str());
nnMmax = atof(getkeyval(3, "nMmax").c_str()); nnMmax = atof(getkeyval(3, "nMmax").c_str());
@@ -6581,43 +6592,76 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
nnominalfill = atof(getkeyval(3, "nominalfill").c_str()); nnominalfill = atof(getkeyval(3, "nominalfill").c_str());
nMstand = atof(getkeyval(3, "Mstand").c_str()); nMstand = atof(getkeyval(3, "Mstand").c_str());
nSize = atoi(getkeyval(2, "Size").c_str()); nSize = atoi(getkeyval(2, "Size").c_str());
continue;
} }
if (issection("WWList:")) if (issection("WWList:"))
{ {
startBPT = false;
secWWList = true; secWWList = true;
getkeyval(2, "Size"); getkeyval(2, "Size");
continue;
} }
if (issection("ffList:")) if (issection("ffList:"))
{ {
startBPT = false;
secffList = true; secffList = true;
getkeyval(2, "Size"); getkeyval(2, "Size");
continue;
} }
if (issection("TurboPos:")) if (issection("TurboPos:"))
{ {
startBPT = false;
secTurboPos = true; secTurboPos = true;
getkeyval(2, "TurboPos"); getkeyval(2, "TurboPos");
} continue;
if (issection("Cntrl.") || startBPT)
{
secBPT = true;
if (gBCPN > 0)
readBPT(BPTLINE, xline); // np wagony nie maja BPT
} }
if (issection("MotorParamTable0:") || startMPT) if (issection("MotorParamTable0:") || startMPT)
{ {
startBPT = false;
secMotorParamTable0 = true; secMotorParamTable0 = true;
readMPT(MPTLINE, xline); readMPT(MPTLINE, xline);
continue;
} }
if (issection("RList:") || startRLIST) if( issection( "Cntrl." ) ) {
{ startBPT = false;
secRList = true; secCntrl = true;
readRLIST(RLISTLINE, xline); 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 } // is hash
} // while line } // while line

View File

@@ -208,7 +208,7 @@ std::string TrimSpace(std::string &s, int Just)
char* TrimAndReduceSpaces(const char* s) char* TrimAndReduceSpaces(const char* s)
{ // redukuje spacje pomiedzy znakami do jednej { // redukuje spacje pomiedzy znakami do jednej
char* tmp; char* tmp = nullptr;
if (s) if (s)
{ {
@@ -422,11 +422,11 @@ int stol_def(const std::string &str, const int &DefaultValue)
std::strncpy(s, str.c_str(), len); std::strncpy(s, str.c_str(), len);
char *p; char *p;
int result = strtol(s, &p, 0); int result = strtol(s, &p, 0);
if ((*p != '\0') || (errno != 0)) delete[] s;
if( ( *p != '\0' ) || ( errno != 0 ) )
{ {
return DefaultValue; return DefaultValue;
} }
delete s;
return result; return result;
} }

View File

@@ -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æ else // dla pozosta³ych modeli blokujemy zapalone œwiat³a, które mog¹ byæ
// nieobs³ugiwane // 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 iVisible = 0; // to domyœlnie wy³¹czyæ, ¿eby siê nie nak³ada³o z obiektem
// "Light_Off" // "Light_Off"

View File

@@ -105,7 +105,7 @@ void TRealSound::Play(double Volume, int Looping, bool ListenerInside, vector3 N
if (!pSound) if (!pSound)
return; return;
long int vol; long int vol;
double dS; double dS = 0.0;
// double Distance; // double Distance;
DWORD stat; DWORD stat;
if ((Global::bSoundEnabled) && (AM != 0)) if ((Global::bSoundEnabled) && (AM != 0))

View File

@@ -58,7 +58,7 @@ void ResourceManager::Sweep(double currentTime)
WriteLog("Releasing resources"); WriteLog("Releasing resources");
#endif #endif
for (Resources::iterator iter = begin; iter != _resources.end(); iter++) for (Resources::iterator iter = begin; iter != _resources.end(); ++iter)
(*iter)->Release(); (*iter)->Release();
#ifdef RESOURCE_REPORTING #ifdef RESOURCE_REPORTING

View File

@@ -200,33 +200,29 @@ double TSegment::RombergIntegral(double fA, double fB)
double TSegment::GetTFromS(double s) double TSegment::GetTFromS(double s)
{ {
// initial guess for Newton's method // initial guess for Newton's method
int it = 0;
double fTolerance = 0.001; double fTolerance = 0.001;
double fRatio = s / RombergIntegral(0, 1); double fRatio = s / RombergIntegral(0, 1);
double fOmRatio = 1.0 - fRatio; double fOmRatio = 1.0 - fRatio;
double fTime = fOmRatio * 0 + fRatio * 1; double fTime = fOmRatio * 0 + fRatio * 1;
int iteration = 0;
// for (int i = 0; i < iIterations; i++) do {
while (true) double fDifference = RombergIntegral(0, fTime) - s;
{ if( ( fDifference > 0 ? fDifference : -fDifference ) < fTolerance ) {
it++;
if (it > 10)
{
ErrorLog("Bad geometry: Too many iterations at " + Where(Point1));
// MessageBox(0,"Too many iterations","GetTFromS",MB_OK);
return fTime; return fTime;
} }
double fDifference = RombergIntegral(0, fTime) - s;
if ((fDifference > 0 ? fDifference : -fDifference) < fTolerance)
return fTime;
fTime -= fDifference / GetFirstDerivative(fTime).Length(); fTime -= fDifference / GetFirstDerivative(fTime).Length();
++iteration;
} }
while( iteration < 10 ); // arbitrary limit
// Newton's method failed. If this happens, increase iterations or // Newton's method failed. If this happens, increase iterations or
// tolerance or integration accuracy. // tolerance or integration accuracy.
// return -1; //Ra: tu nigdy nie dojdzie // 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) vector3 TSegment::RaInterpolate(double t)

View File

@@ -56,8 +56,8 @@ TSoundContainer::TSoundContainer(LPDIRECTSOUND pDS, const char *Directory, const
if (FAILED(pWaveSoundRead->Open(strdup(strFileName)))) if (FAILED(pWaveSoundRead->Open(strdup(strFileName))))
{ {
// SetFileUI( hDlg, TEXT("Bad wave file.") ); // SetFileUI( hDlg, TEXT("Bad wave file.") );
ErrorLog( "Missed sound: " + std::string( strFileName ) );
return; return;
ErrorLog( "Missed sound: " + std::string(strFileName) );
} }
strcpy(Name, ToLower(strFileName).c_str()); strcpy(Name, ToLower(strFileName).c_str());
@@ -108,16 +108,20 @@ TSoundContainer::TSoundContainer(LPDIRECTSOUND pDS, const char *Directory, const
return; // E_OUTOFMEMORY; return; // E_OUTOFMEMORY;
// if (FAILED(hr=pWaveSoundRead->Read( nWaveFileSize,pbWavData,&cbWavSize))) // if (FAILED(hr=pWaveSoundRead->Read( nWaveFileSize,pbWavData,&cbWavSize)))
if (FAILED(hr = pWaveSoundRead->Read(nWaveFileSize, pbWavData, &cbWavSize))) if( FAILED( hr = pWaveSoundRead->Read( nWaveFileSize, pbWavData, &cbWavSize ) ) ) {
delete[] pbWavData;
return; return;
}
// Reset the file to the beginning // Reset the file to the beginning
pWaveSoundRead->Reset(); pWaveSoundRead->Reset();
// Lock the buffer down // 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,0)))
if (FAILED(hr = DSBuffer->Lock(0, dwBufferBytes, &pbData, &dwLength, &pbData2, &dwLength2, 0L))) if( FAILED( hr = DSBuffer->Lock( 0, dwBufferBytes, &pbData, &dwLength, &pbData2, &dwLength2, 0L ) ) ) {
delete[] pbWavData;
return; return;
}
// Copy the memory to it. // Copy the memory to it.
memcpy(pbData, pbWavData, dwBufferBytes); memcpy(pbData, pbWavData, dwBufferBytes);

View File

@@ -868,7 +868,7 @@ void TTexturesManager::Free()
{ // usuniêcie wszyskich tekstur (bez usuwania struktury) { // usuniêcie wszyskich tekstur (bez usuwania struktury)
// for (Names::iterator iter = _names.begin(); iter != _names.end(); iter++) // for (Names::iterator iter = _names.begin(); iter != _names.end(); iter++)
if( false == _names.empty() ) { if( false == _names.empty() ) {
for( auto texture : _names ) { for( auto const &texture : _names ) {
glDeleteTextures( 1, &texture.second ); glDeleteTextures( 1, &texture.second );
} }
} }
@@ -876,8 +876,8 @@ void TTexturesManager::Free()
std::string TTexturesManager::GetName(GLuint id) std::string TTexturesManager::GetName(GLuint id)
{ // pobranie nazwy tekstury { // pobranie nazwy tekstury
for (Names::iterator iter = _names.begin(); iter != _names.end(); iter++) for( auto const &pair : _names ) {
if (iter->second == id) if( pair.second == id ) { return pair.first; }
return iter->first; }
return ""; return "";
}; };

View File

@@ -668,7 +668,9 @@ bool TWorld::Init(HWND NhWnd, HDC hDC)
light = TTexturesManager::GetTextureID(szTexturePath, szSceneryPath, "smuga2.tga"); light = TTexturesManager::GetTextureID(szTexturePath, szSceneryPath, "smuga2.tga");
// Camera.Reset(); // Camera.Reset();
Timer::ResetTimers(); 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 (DebugModeFlag) // w Debugmode automatyczne w³¹czenie AI
if (Train) if (Train)
if (Train->Dynamic()->Mechanik) if (Train->Dynamic()->Mechanik)
@@ -2078,7 +2080,7 @@ bool TWorld::Update()
std::string flags = "bwaccmlshhhoibsgvdp; "; // flagi AI (definicja w Driver.h) std::string flags = "bwaccmlshhhoibsgvdp; "; // flagi AI (definicja w Driver.h)
for (int i = 0, j = 1; i < 19; ++i, j <<= 1) for (int i = 0, j = 1; i < 19; ++i, j <<= 1)
if (tmp->Mechanik->DrivigFlags() & j) // jak bit ustawiony 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 = flags;
OutText4 += OutText4 +=
("Driver: Vd=") + ("Driver: Vd=") +

View File

@@ -158,7 +158,8 @@ std::string cParser::readToken(bool ToLower, const char *Break)
// if (trtest=="x") //jeœli nie wczytywaæ drutów // if (trtest=="x") //jeœli nie wczytywaæ drutów
// trtest2=includefile; //kopiowanie œcie¿ki do pliku // trtest2=includefile; //kopiowanie œcie¿ki do pliku
std::string parameter = readToken(false); // w parametrach nie zmniejszamy 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); parameters.push_back(parameter);
parameter = readToken(ToLower); parameter = readToken(ToLower);