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

Merge pull request #18 from tmj-fstate/mover_in_c++

Poprawki do stabilności działania i wycieków pamięci.
This commit is contained in:
firleju
2017-01-24 11:33:20 +01:00
committed by GitHub
43 changed files with 1809 additions and 2085 deletions

View File

@@ -10,7 +10,6 @@ http://mozilla.org/MPL/2.0/.
#ifndef AdvSoundH #ifndef AdvSoundH
#define AdvSoundH #define AdvSoundH
#include "Sound.h"
#include "RealSound.h" #include "RealSound.h"
#include "parser.h" #include "parser.h"

View File

@@ -11,21 +11,21 @@ http://mozilla.org/MPL/2.0/.
Copyright (C) 2001-2004 Marcin Wozniak, Maciej Czapkiewicz and others Copyright (C) 2001-2004 Marcin Wozniak, Maciej Czapkiewicz and others
*/ */
#include "stdafx.h" #include "stdafx.h"
#include "Driver.h" #include "Driver.h"
#include <direct.h>
#include "Globals.h"
#include "Logs.h"
#include "mtable.h"
#include "DynObj.h" #include "DynObj.h"
#include "Event.h" #include "Event.h"
#include "Globals.h"
#include "Ground.h" #include "Ground.h"
#include "Logs.h"
#include "McZapkie/MOVER.h"
#include "McZapkie/mctools.h"
#include "MemCell.h" #include "MemCell.h"
#include "World.h" #include "World.h"
#include "mtable.h" #include "McZapkie/mctools.h"
#include <direct.h> #include "McZapkie/MOVER.h"
#define LOGVELOCITY 0 #define LOGVELOCITY 0
#define LOGORDERS 0 #define LOGORDERS 0
@@ -149,7 +149,7 @@ void TSpeedPos::CommandCheck()
case cm_SectionVelocity: case cm_SectionVelocity:
// odcinek z ograniczeniem prędkości // odcinek z ograniczeniem prędkości
fVelNext = value1; fVelNext = value1;
fSectionVelocityDist = value2; fSectionVelocityDist = value2;
iFlags |= spSectionVel; iFlags |= spSectionVel;
break; break;
case cm_RoadVelocity: case cm_RoadVelocity:
@@ -166,9 +166,9 @@ void TSpeedPos::CommandCheck()
break; break;
case cm_SetProximityVelocity: case cm_SetProximityVelocity:
// musi zostać gdyż inaczej nie działają manewry // musi zostać gdyż inaczej nie działają manewry
fVelNext = -1; fVelNext = -1;
iFlags |= spProximityVelocity; iFlags |= spProximityVelocity;
// fSectionVelocityDist = value2; // fSectionVelocityDist = value2;
break; break;
case cm_OutsideStation: case cm_OutsideStation:
// w trybie manewrowym: skanować od niej wstecz i stanąć po wyjechaniu za sygnalizator i // w trybie manewrowym: skanować od niej wstecz i stanąć po wyjechaniu za sygnalizator i
@@ -177,7 +177,7 @@ void TSpeedPos::CommandCheck()
fVelNext = -1; fVelNext = -1;
iFlags |= spOutsideStation; // W5 iFlags |= spOutsideStation; // W5
break; break;
default: default:
// inna komenda w evencie skanowanym powoduje zatrzymanie i wysłanie tej komendy // inna komenda w evencie skanowanym powoduje zatrzymanie i wysłanie tej komendy
iFlags &= ~(spShuntSemaphor | spPassengerStopPoint | iFlags &= ~(spShuntSemaphor | spPassengerStopPoint |
spStopOnSBL); // nie manewrowa, nie przystanek, nie zatrzymać na SBL spStopOnSBL); // nie manewrowa, nie przystanek, nie zatrzymać na SBL
@@ -242,12 +242,12 @@ bool TSpeedPos::Update(vector3 *p, vector3 *dir, double &len)
// ograniczona w skrzyżowaniu (velocity z ujemną wartością) // ograniczona w skrzyżowaniu (velocity z ujemną wartością)
if ((iFlags & spElapsed) == 0) // jeśli nie wjechał if ((iFlags & spElapsed) == 0) // jeśli nie wjechał
if (trTrack->iNumDynamics > 0) // a skrzyżowanie zawiera pojazd if (trTrack->iNumDynamics > 0) // a skrzyżowanie zawiera pojazd
{ {
if (Global::iWriteLogEnabled & 8) if (Global::iWriteLogEnabled & 8)
WriteLog("Tor " + trTrack->NameGet() + " zajety przed pojazdem. Num=" + std::to_string(trTrack->iNumDynamics) + "Dist= " + std::to_string(fDist)); WriteLog("Tor " + trTrack->NameGet() + " zajety przed pojazdem. Num=" + std::to_string(trTrack->iNumDynamics) + "Dist= " + std::to_string(fDist));
fVelNext = fVelNext =
0.0; // to zabronić wjazdu (chyba że ten z przodu też jedzie prosto) 0.0; // to zabronić wjazdu (chyba że ten z przodu też jedzie prosto)
} }
} }
if (iFlags & spSwitch) // jeśli odcinek zmienny if (iFlags & spSwitch) // jeśli odcinek zmienny
{ {
@@ -263,16 +263,16 @@ bool TSpeedPos::Update(vector3 *p, vector3 *dir, double &len)
} }
// poniższe nie dotyczy trybu łączenia? // poniższe nie dotyczy trybu łączenia?
if ((iFlags & spElapsed) ? false : if ((iFlags & spElapsed) ? false :
trTrack->iNumDynamics > trTrack->iNumDynamics >
0) // jeśli jeszcze nie wjechano na tor, a coś na nim jest 0) // jeśli jeszcze nie wjechano na tor, a coś na nim jest
{ {
if (Global::iWriteLogEnabled & 8) if (Global::iWriteLogEnabled & 8)
WriteLog("Rozjazd " + trTrack->NameGet() + " zajety przed pojazdem. Num=" + std::to_string(trTrack->iNumDynamics) + "Dist= "+std::to_string(fDist)); WriteLog("Rozjazd " + trTrack->NameGet() + " zajety przed pojazdem. Num=" + std::to_string(trTrack->iNumDynamics) + "Dist= "+std::to_string(fDist));
//fDist -= 30.0; //fDist -= 30.0;
fVelNext = 0.0; // to niech stanie w zwiększonej odległości fVelNext = 0.0; // to niech stanie w zwiększonej odległości
// else if (fVelNext==0.0) //jeśli została wyzerowana // else if (fVelNext==0.0) //jeśli została wyzerowana
// fVelNext=trTrack->VelocityGet(); //odczyt prędkości // fVelNext=trTrack->VelocityGet(); //odczyt prędkości
} }
} }
} }
} }
@@ -287,20 +287,19 @@ bool TSpeedPos::Update(vector3 *p, vector3 *dir, double &len)
std::string TSpeedPos::GetName() std::string TSpeedPos::GetName()
{ {
if (iFlags & spTrack) // jeśli tor if (iFlags & spTrack) // jeśli tor
return trTrack->NameGet(); return trTrack->NameGet();
else if (iFlags & spEvent) // jeśli event else if (iFlags & spEvent) // jeśli event
return evEvent->asName; return evEvent->asName;
} }
std::string TSpeedPos::TableText() std::string TSpeedPos::TableText()
{ // pozycja tabelki pr?dko?ci { // pozycja tabelki pr?dko?ci
if (iFlags & spEnabled) if (iFlags & spEnabled)
{ // o ile pozycja istotna { // o ile pozycja istotna
return "Flags=#" + to_hex_str(iFlags, 8) + ", Dist=" + to_string(fDist, 1, 7) + return "Flags=" + to_hex_str(iFlags, 6) + ", Dist=" + to_string(fDist, 1, 7) +
", Vel=" + std::to_string(fVelNext) + ", Name=" + GetName(); ", Vel=" + std::to_string(fVelNext) + ", Name=" + GetName();
// if (iFlags & spTrack) // je?li tor //if (iFlags & spTrack) // jeśli tor
// return "Flags=#" + IntToHex(iFlags, 8) + ", Dist=" + FloatToStrF(fDist, ffFixed, 7, 1) // return "Flags=#" + IntToHex(iFlags, 8) + ", Dist=" + FloatToStrF(fDist, ffFixed, 7, 1) +
// +
// ", Vel=" + AnsiString(fVelNext) + ", Track=" + trTrack->NameGet(); // ", Vel=" + AnsiString(fVelNext) + ", Track=" + trTrack->NameGet();
//else if (iFlags & spEvent) // jeśli event //else if (iFlags & spEvent) // jeśli event
// return "Flags=#" + IntToHex(iFlags, 8) + ", Dist=" + FloatToStrF(fDist, ffFixed, 7, 1) + // return "Flags=#" + IntToHex(iFlags, 8) + ", Dist=" + FloatToStrF(fDist, ffFixed, 7, 1) +
@@ -312,17 +311,17 @@ std::string TSpeedPos::TableText()
bool TSpeedPos::IsProperSemaphor(TOrders order) bool TSpeedPos::IsProperSemaphor(TOrders order)
{ // sprawdzenie czy semafor jest zgodny z trybem jazdy { // sprawdzenie czy semafor jest zgodny z trybem jazdy
if (order < 0x40) // Wait_for_orders, Prepare_engine, Change_direction, Connect, Disconnect, Shunt if (order < 0x40) // Wait_for_orders, Prepare_engine, Change_direction, Connect, Disconnect, Shunt
{ {
if (iFlags & (spSemaphor | spShuntSemaphor)) if (iFlags & (spSemaphor | spShuntSemaphor))
return true; return true;
else if (iFlags & spOutsideStation) else if (iFlags & spOutsideStation)
return true; return true;
} }
else if (order & Obey_train) else if (order & Obey_train)
{ {
if (iFlags & spSemaphor) if (iFlags & spSemaphor)
return true; return true;
} }
return false; // true gdy zatrzymanie, wtedy nie ma po co skanować dalej return false; // true gdy zatrzymanie, wtedy nie ma po co skanować dalej
} }
@@ -337,17 +336,17 @@ bool TSpeedPos::Set(TEvent *event, double dist, TOrders order)
// jeśli wskazuje stop wtedy wystawiamy true jako koniec sprawdzania // jeśli wskazuje stop wtedy wystawiamy true jako koniec sprawdzania
// WriteLog("EventSet: Vel=" + AnsiString(fVelNext) + " iFlags=" + AnsiString(iFlags) + " order="+AnsiString(order)); // WriteLog("EventSet: Vel=" + AnsiString(fVelNext) + " iFlags=" + AnsiString(iFlags) + " order="+AnsiString(order));
if (order < 0x40) // Wait_for_orders, Prepare_engine, Change_direction, Connect, Disconnect, Shunt if (order < 0x40) // Wait_for_orders, Prepare_engine, Change_direction, Connect, Disconnect, Shunt
{ {
if (iFlags & (spSemaphor | spShuntSemaphor) && fVelNext == 0.0) if (iFlags & (spSemaphor | spShuntSemaphor) && fVelNext == 0.0)
return true; return true;
else if (iFlags & spOutsideStation) else if (iFlags & spOutsideStation)
return true; return true;
} }
else if (order & Obey_train) else if (order & Obey_train)
{ {
if (iFlags & spSemaphor && fVelNext == 0.0) if (iFlags & spSemaphor && fVelNext == 0.0)
return true; return true;
} }
return false; // true gdy zatrzymanie, wtedy nie ma po co skanować dalej return false; // true gdy zatrzymanie, wtedy nie ma po co skanować dalej
}; };
@@ -417,19 +416,19 @@ bool TController::TableNotFound(TEvent *e)
for (int i = iFirst; i != j; i = (i + 1) % iSpeedTableSize) for (int i = iFirst; i != j; i = (i + 1) % iSpeedTableSize)
if ((sSpeedTable[i].iFlags & (spEnabled | spEvent)) == (spEnabled | if ((sSpeedTable[i].iFlags & (spEnabled | spEvent)) == (spEnabled |
spEvent)) // o ile używana pozycja spEvent)) // o ile używana pozycja
if (sSpeedTable[i].evEvent == e) if (sSpeedTable[i].evEvent == e)
{ {
if (Global::iWriteLogEnabled & 8) if (Global::iWriteLogEnabled & 8)
WriteLog("TableNotFound: Event already in SpeedTable: " + sSpeedTable[i].evEvent->asName); WriteLog("TableNotFound: Event already in SpeedTable: " + sSpeedTable[i].evEvent->asName);
return false; // już jest, drugi raz dodawać nie ma po co return false; // już jest, drugi raz dodawać nie ma po co
} }
return true; // nie ma, czyli można dodać return true; // nie ma, czyli można dodać
}; };
void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle) void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle)
{ // skanowanie trajektorii na odległość (fDistance) od (pVehicle) w kierunku przodu składu i { // skanowanie trajektorii na odległość (fDistance) od (pVehicle) w kierunku przodu składu i
// uzupełnianie tabelki // uzupełnianie tabelki
// WriteLog("Starting TableTraceRoute"); // WriteLog("Starting TableTraceRoute");
if (!iDirection) // kierunek pojazdu z napędem if (!iDirection) // kierunek pojazdu z napędem
{ // jeśli kierunek jazdy nie jest okreslony { // jeśli kierunek jazdy nie jest okreslony
iTableDirection = 0; // czekamy na ustawienie kierunku iTableDirection = 0; // czekamy na ustawienie kierunku
@@ -458,34 +457,34 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle)
} }
else else
{ // kontynuacja skanowania od ostatnio sprawdzonego toru (w ostatniej pozycji zawsze jest tor) { // kontynuacja skanowania od ostatnio sprawdzonego toru (w ostatniej pozycji zawsze jest tor)
// WriteLog("TableTraceRoute: check last track"); // WriteLog("TableTraceRoute: check last track");
if (sSpeedTable[iLast].iFlags & spEndOfTable) // zatkanie if (sSpeedTable[iLast].iFlags & spEndOfTable) // zatkanie
{ // jeśli zapełniła się tabelka { // jeśli zapełniła się tabelka
if ((iLast + 1) % iSpeedTableSize == iFirst) // jeśli nadal jest zapełniona if ((iLast + 1) % iSpeedTableSize == iFirst) // jeśli nadal jest zapełniona
{ {
TablePurger(); // nic się nie da zrobić TablePurger(); // nic się nie da zrobić
return; return;
} }
if ((iLast + 2) % iSpeedTableSize == iFirst) // musi być jeszcze miejsce wolne na if ((iLast + 2) % iSpeedTableSize == iFirst) // musi być jeszcze miejsce wolne na
// ewentualny event, bo tor jeszcze nie // ewentualny event, bo tor jeszcze nie
// sprawdzony // sprawdzony
{ {
TablePurger(); TablePurger();
return; // już lepiej, ale jeszcze nie tym razem return; // już lepiej, ale jeszcze nie tym razem
} }
sSpeedTable[iLast].iFlags &= 0xBE; // kontynuować próby doskanowania sSpeedTable[iLast].iFlags &= 0xBE; // kontynuować próby doskanowania
} }
// znaleziono semafor lub tarczę lub tor z prędkością zero // znaleziono semafor lub tarczę lub tor z prędkością zero
// trzeba sprawdzić czy to nadał semafor // trzeba sprawdzić czy to nadał semafor
// WriteLog("TableTraceRoute: "+OwnerName()+" check semaphor... "); // WriteLog("TableTraceRoute: "+OwnerName()+" check semaphor... ");
// if (sSemNext) // if (sSemNext)
// WriteLog(sSemNext->TableText()); // WriteLog(sSemNext->TableText());
if (sSemNextStop && if (sSemNextStop &&
sSemNextStop->fVelNext == sSemNextStop->fVelNext ==
0.0) // jeśli jest następny semafor to sprawdzamy czy to on nadał zero 0.0) // jeśli jest następny semafor to sprawdzamy czy to on nadał zero
{ {
// WriteLog("TableTraceRoute: "+sSemNext->TableText()); // WriteLog("TableTraceRoute: "+sSemNext->TableText());
if ((OrderCurrentGet() & Obey_train) && (sSemNextStop->iFlags & spSemaphor)) if ((OrderCurrentGet() & Obey_train) && (sSemNextStop->iFlags & spSemaphor))
return; return;
else if ((OrderCurrentGet() < 0x40) && else if ((OrderCurrentGet() < 0x40) &&
(sSemNextStop->iFlags & (spSemaphor | spShuntSemaphor | spOutsideStation))) (sSemNextStop->iFlags & (spSemaphor | spShuntSemaphor | spOutsideStation)))
@@ -494,12 +493,9 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle)
pTrack = sSpeedTable[iLast].trTrack; // ostatnio sprawdzony tor pTrack = sSpeedTable[iLast].trTrack; // ostatnio sprawdzony tor
if (!pTrack) if (!pTrack)
return; // koniec toru, to nie ma co sprawdzać (nie ma prawa tak być) return; // koniec toru, to nie ma co sprawdzać (nie ma prawa tak być)
fLastDir = sSpeedTable[iLast].iFlags & spReverse ? fLastDir = (sSpeedTable[iLast].iFlags & spReverse) ? -1.0 : 1.0; // flaga ustawiona, gdy Point2 toru jest bli<6C>ej
-1.0 : fCurrentDistance = sSpeedTable[iLast].fDist; // aktualna odleg<65>o<EFBFBD><6F> do jego Point1
1.0; // flaga ustawiona, gdy Point2 toru jest bliżej fTrackLength = (sSpeedTable[iLast].iFlags & (spElapsed | spEnd)) ? 0.0 : pTrack->Length(); // nie dolicza<7A> d<>ugo<67>ci gdy:
fCurrentDistance = sSpeedTable[iLast].fDist; // aktualna odległość do jego Point1
fTrackLength =
sSpeedTable[iLast].iFlags & (spElapsed | spEnd) ? 0.0 : pTrack->Length(); // nie doliczać długości gdy:
// 32-minięty początek, // 32-minięty początek,
// 64-jazda do końca toru // 64-jazda do końca toru
} }
@@ -521,27 +517,27 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle)
if (TableNotFound(pEvent)) // jeśli nie ma if (TableNotFound(pEvent)) // jeśli nie ma
if (TableAddNew()) if (TableAddNew())
{ {
if (Global::iWriteLogEnabled & 8) if (Global::iWriteLogEnabled & 8)
WriteLog("TableTraceRoute: new event found " + pEvent->asName + " by " + OwnerName()); WriteLog("TableTraceRoute: new event found " + pEvent->asName + " by " + OwnerName());
if (sSpeedTable[iLast].Set( pEvent, fCurrentDistance, OrderCurrentGet())) // dodanie odczytu sygnału if (sSpeedTable[iLast].Set( pEvent, fCurrentDistance, OrderCurrentGet())) // dodanie odczytu sygnału
{ {
fDistance = fCurrentDistance; // jeśli sygnał stop, to nie ma fDistance = fCurrentDistance; // jeśli sygnał stop, to nie ma
// potrzeby dalej skanować // potrzeby dalej skanować
sSemNextStop = &sSpeedTable[iLast]; sSemNextStop = &sSpeedTable[iLast];
if (!sSemNext) if (!sSemNext)
sSemNext = &sSpeedTable[iLast]; sSemNext = &sSpeedTable[iLast];
if (Global::iWriteLogEnabled & 8) if (Global::iWriteLogEnabled & 8)
WriteLog("Signal stop. Next Semaphor ", false); WriteLog("Signal stop. Next Semaphor ", false);
if (sSemNextStop) if (sSemNextStop)
{ {
if (Global::iWriteLogEnabled & 8) if (Global::iWriteLogEnabled & 8)
WriteLog(sSemNextStop->GetName()); WriteLog(sSemNextStop->GetName());
} }
else else
{ {
if (Global::iWriteLogEnabled & 8) if (Global::iWriteLogEnabled & 8)
WriteLog("none"); WriteLog("none");
} }
} }
else else
{ {
@@ -549,18 +545,18 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle)
sSemNext == NULL) sSemNext == NULL)
sSemNext = sSemNext =
&sSpeedTable[iLast]; // sprawdzamy czy pierwszy na drodze &sSpeedTable[iLast]; // sprawdzamy czy pierwszy na drodze
if (Global::iWriteLogEnabled & 8) if (Global::iWriteLogEnabled & 8)
WriteLog("Signal forward. Next Semaphor ", false); WriteLog("Signal forward. Next Semaphor ", false);
if (sSemNext) if (sSemNext)
{ {
if (Global::iWriteLogEnabled & 8) if (Global::iWriteLogEnabled & 8)
WriteLog(sSemNext->GetName()); WriteLog(sSemNext->GetName());
} }
else else
{ {
if (Global::iWriteLogEnabled & 8) if (Global::iWriteLogEnabled & 8)
WriteLog("none"); WriteLog("none");
} }
} }
} }
} // event dodajemy najpierw, żeby móc sprawdzić, czy tor został dodany po } // event dodajemy najpierw, żeby móc sprawdzić, czy tor został dodany po
@@ -605,7 +601,7 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle)
sSpeedTable[iLast].Set(pTrack, fCurrentDistance, sSpeedTable[iLast].Set(pTrack, fCurrentDistance,
fLastDir < 0 ? 0x85 : fLastDir < 0 ? 0x85 :
0x81); // dodanie odcinka do tabelki 0x81); // dodanie odcinka do tabelki
// 0x85 = spEnabled, spReverse, SpCurve // 0x85 = spEnabled, spReverse, SpCurve
} }
} }
fCurrentDistance += fCurrentDistance +=
@@ -709,24 +705,24 @@ void TController::TableCheck(double fDistance)
{ {
if (sSpeedTable[i].Update(&pos, &dir, len)) if (sSpeedTable[i].Update(&pos, &dir, len))
{ {
if (Global::iWriteLogEnabled & 8) if (Global::iWriteLogEnabled & 8)
WriteLog("TableCheck: Switch change. Delete next entries. (" + sSpeedTable[i].trTrack->NameGet() + ")"); WriteLog("TableCheck: Switch change. Delete next entries. (" + sSpeedTable[i].trTrack->NameGet() + ")");
int k = (iLast + 1) % iSpeedTableSize; // skanujemy razem z ostatnią pozycją int k = (iLast + 1) % iSpeedTableSize; // skanujemy razem z ostatnią pozycją
for (int j = (i+1) % iSpeedTableSize; j != k; j = (j + 1) % iSpeedTableSize) for (int j = (i+1) % iSpeedTableSize; j != k; j = (j + 1) % iSpeedTableSize)
{ // kasowanie wszystkich rekordów za zmienioną zwrotnicą { // kasowanie wszystkich rekordów za zmienioną zwrotnicą
if (Global::iWriteLogEnabled & 8) if (Global::iWriteLogEnabled & 8)
WriteLog("TableCheck: Delete from table: " + sSpeedTable[j].GetName()); WriteLog("TableCheck: Delete from table: " + sSpeedTable[j].GetName());
sSpeedTable[j].iFlags = 0; sSpeedTable[j].iFlags = 0;
if (&sSpeedTable[j] == sSemNext) if (&sSpeedTable[j] == sSemNext)
sSemNext = NULL; // przy kasowaniu tabelki zrzucamy także semafor sSemNext = NULL; // przy kasowaniu tabelki zrzucamy także semafor
if (&sSpeedTable[j] == sSemNextStop) if (&sSpeedTable[j] == sSemNextStop)
sSemNextStop = NULL; // przy kasowaniu tabelki zrzucamy także semafor sSemNextStop = NULL; // przy kasowaniu tabelki zrzucamy także semafor
} }
if (Global::iWriteLogEnabled & 8) if (Global::iWriteLogEnabled & 8)
{ {
WriteLog("TableCheck: Delete entries OK."); WriteLog("TableCheck: Delete entries OK.");
WriteLog("TableCheck: New last element: " + sSpeedTable[i].GetName()); WriteLog("TableCheck: New last element: " + sSpeedTable[i].GetName());
} }
iLast = i; // pokazujemy gdzie jest ostatni kawałek iLast = i; // pokazujemy gdzie jest ostatni kawałek
break; // nie kontynuujemy pętli, trzeba doskanować ciąg dalszy break; // nie kontynuujemy pętli, trzeba doskanować ciąg dalszy
} }
@@ -740,11 +736,11 @@ void TController::TableCheck(double fDistance)
else if ((sSpeedTable[i].iFlags & 0xF0000028) == else if ((sSpeedTable[i].iFlags & 0xF0000028) ==
spElapsed) // jest z tyłu (najechany) i nie jest zwrotnicą ani skrzyżowaniem spElapsed) // jest z tyłu (najechany) i nie jest zwrotnicą ani skrzyżowaniem
if (sSpeedTable[i].fVelNext < 0) // a nie ma ograniczenia prędkości if (sSpeedTable[i].fVelNext < 0) // a nie ma ograniczenia prędkości
{ {
sSpeedTable[i].iFlags = sSpeedTable[i].iFlags =
0; // to nie ma go po co trzymać (odtykacz usunie ze środka) 0; // to nie ma go po co trzymać (odtykacz usunie ze środka)
// WriteLog("TableCheck: Track without speed. Delete from table: " + sSpeedTable[i].trTrack->NameGet()); // WriteLog("TableCheck: Track without speed. Delete from table: " + sSpeedTable[i].trTrack->NameGet());
} }
} }
else if (sSpeedTable[i].iFlags & spEvent) // jeśli event else if (sSpeedTable[i].iFlags & spEvent) // jeśli event
{ {
@@ -756,7 +752,7 @@ void TController::TableCheck(double fDistance)
{ // pociąg staje zawsze, a samochód tylko jeśli nie przejedzie całą { // pociąg staje zawsze, a samochód tylko jeśli nie przejedzie całą
// długością (może być zaskoczony zmianą) // długością (może być zaskoczony zmianą)
// WriteLog("TableCheck: Event is behind. Delete from table: " + sSpeedTable[i].evEvent->asName); // WriteLog("TableCheck: Event is behind. Delete from table: " + sSpeedTable[i].evEvent->asName);
sSpeedTable[i].iFlags &= ~1; // degradacja pozycji dla samochodu; sSpeedTable[i].iFlags &= ~1; // degradacja pozycji dla samochodu;
// semafory usuwane tylko przy sprawdzaniu, // semafory usuwane tylko przy sprawdzaniu,
// bo wysyłają komendy // bo wysyłają komendy
} }
@@ -830,9 +826,8 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
// już semafora) // już semafora)
#if LOGSTOPS #if LOGSTOPS
WriteLog(pVehicle->asName + " as " + TrainParams->TrainName + ": at " + WriteLog(pVehicle->asName + " as " + TrainParams->TrainName + ": at " +
std::to_string(GlobalTime->hh) + ":" + std::to_string(GlobalTime->hh) + ":" + std::to_string(GlobalTime->mm) +
std::to_string(GlobalTime->mm) + " skipped " + " skipped " + asNextStop); // informacja
asNextStop); // informacja
#endif #endif
fLastStopExpDist = mvOccupied->DistCounter + 0.250 + fLastStopExpDist = mvOccupied->DistCounter + 0.250 +
0.001 * fLength; // przy jakim dystansie (stanie 0.001 * fLength; // przy jakim dystansie (stanie
@@ -840,7 +835,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
// następny postój // następny postój
TrainParams->UpdateMTable( TrainParams->UpdateMTable(
GlobalTime->hh, GlobalTime->mm, GlobalTime->hh, GlobalTime->mm,
asNextStop.substr(19, asNextStop.length())); asNextStop.substr(19, asNextStop.length()));
TrainParams->StationIndexInc(); // przejście do następnej TrainParams->StationIndexInc(); // przejście do następnej
asNextStop = asNextStop =
TrainParams->NextStop(); // pobranie kolejnego miejsca zatrzymania TrainParams->NextStop(); // pobranie kolejnego miejsca zatrzymania
@@ -985,11 +980,11 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
} }
if (TrainParams->StationIndex < TrainParams->StationCount) if (TrainParams->StationIndex < TrainParams->StationCount)
{ // jeśli są dalsze stacje, czekamy do godziny odjazdu { // jeśli są dalsze stacje, czekamy do godziny odjazdu
if (TrainParams->IsTimeToGo(GlobalTime->hh, GlobalTime->mm)) if (TrainParams->IsTimeToGo(GlobalTime->hh, GlobalTime->mm))
{ // z dalszą akcją czekamy do godziny odjazdu { // z dalszą akcją czekamy do godziny odjazdu
/* potencjalny problem z ruszaniem z w4 /* potencjalny problem z ruszaniem z w4
if (TrainParams->CheckTrainLatency() < 0) if (TrainParams->CheckTrainLatency() < 0)
WaitingSet(20); //Jak spóźniony to czeka 20s WaitingSet(20); //Jak spóźniony to czeka 20s
*/ */
// iDrivigFlags|=moveLate1; //oflagować, gdy odjazd ze // iDrivigFlags|=moveLate1; //oflagować, gdy odjazd ze
@@ -1008,10 +1003,10 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
std::to_string(GlobalTime->mm) + " next " + std::to_string(GlobalTime->mm) + " next " +
asNextStop); // informacja asNextStop); // informacja
#endif #endif
if (int(floor(sSpeedTable[i].evEvent->ValueGet(1))) & 1) if (int(floor(sSpeedTable[i].evEvent->ValueGet(1))) & 1)
iDrivigFlags |= moveStopHere; // nie podjeżdżać do semafora, iDrivigFlags |= moveStopHere; // nie podjeżdżać do semafora,
// jeśli droga nie jest wolna // jeśli droga nie jest wolna
else else
iDrivigFlags &= ~moveStopHere; //po czasie jedź dalej iDrivigFlags &= ~moveStopHere; //po czasie jedź dalej
iDrivigFlags |= moveStopCloser; // do następnego W4 podjechać iDrivigFlags |= moveStopCloser; // do następnego W4 podjechać
// blisko (z dociąganiem) // blisko (z dociąganiem)
@@ -1074,14 +1069,14 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
// sprawdzanie eventów pasywnych miniętych // sprawdzanie eventów pasywnych miniętych
if (sSpeedTable[i].fDist < 0.0 && sSemNext == &sSpeedTable[i]) if (sSpeedTable[i].fDist < 0.0 && sSemNext == &sSpeedTable[i])
{ {
if (Global::iWriteLogEnabled & 8) if (Global::iWriteLogEnabled & 8)
WriteLog("TableUpdate: semaphor " + sSemNext->GetName() + " passed by " + OwnerName()); WriteLog("TableUpdate: semaphor " + sSemNext->GetName() + " passed by " + OwnerName());
sSemNext = NULL; // jeśli minęliśmy semafor od ograniczenia to go kasujemy ze sSemNext = NULL; // jeśli minęliśmy semafor od ograniczenia to go kasujemy ze
// zmiennej sprawdzającej dla skanowania w przód // zmiennej sprawdzającej dla skanowania w przód
} }
if (sSpeedTable[i].fDist < 0.0 && sSemNextStop == &sSpeedTable[i]) if (sSpeedTable[i].fDist < 0.0 && sSemNextStop == &sSpeedTable[i])
{ {
if (Global::iWriteLogEnabled & 8) if (Global::iWriteLogEnabled & 8)
WriteLog("TableUpdate: semaphor " + sSemNextStop->GetName() + " passed by " + OwnerName()); WriteLog("TableUpdate: semaphor " + sSemNextStop->GetName() + " passed by " + OwnerName());
sSemNextStop = NULL; // jeśli minęliśmy semafor od ograniczenia to go kasujemy ze sSemNextStop = NULL; // jeśli minęliśmy semafor od ograniczenia to go kasujemy ze
// zmiennej sprawdzającej dla skanowania w przód // zmiennej sprawdzającej dla skanowania w przód
@@ -1095,13 +1090,13 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
// semafor a wcześniej // semafor a wcześniej
// byl nowy to go dorzucamy do zmiennej, żeby cały // byl nowy to go dorzucamy do zmiennej, żeby cały
// czas widział najbliższy // czas widział najbliższy
if (Global::iWriteLogEnabled & 8) if (Global::iWriteLogEnabled & 8)
WriteLog("TableUpdate: Next semaphor: " + sSemNext->GetName() + " by " + OwnerName()); WriteLog("TableUpdate: Next semaphor: " + sSemNext->GetName() + " by " + OwnerName());
} }
if (!sSemNextStop || (sSemNextStop && sSemNextStop->fVelNext != 0 && if (!sSemNextStop || (sSemNextStop && sSemNextStop->fVelNext != 0 &&
sSpeedTable[i].fVelNext == 0)) sSpeedTable[i].fVelNext == 0))
sSemNextStop = &sSpeedTable[i]; sSemNextStop = &sSpeedTable[i];
} }
if (sSpeedTable[i].iFlags & spOutsideStation) if (sSpeedTable[i].iFlags & spOutsideStation)
{ // jeśli W5, to reakcja zależna od trybu jazdy { // jeśli W5, to reakcja zależna od trybu jazdy
if (OrderCurrentGet() & Obey_train) if (OrderCurrentGet() & Obey_train)
@@ -1148,17 +1143,13 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
} }
else if (sSpeedTable[i].IsProperSemaphor(OrderCurrentGet())) else if (sSpeedTable[i].IsProperSemaphor(OrderCurrentGet()))
{ // to semaphor { // to semaphor
if (sSpeedTable[i].fDist < 0) if (sSpeedTable[i].fDist < 0)
VelSignalLast = sSpeedTable[i].fVelNext; //minięty daje prędkość obowiązującą VelSignalLast = sSpeedTable[i].fVelNext; //minięty daje prędkość obowiązującą
else else
{ {
iDrivigFlags |= moveSemaphorFound; //jeśli z przodu to dajemy falgę, że jest iDrivigFlags |= moveSemaphorFound; //jeśli z przodu to dajemy falgę, że jest
d_to_next_sem = Min0R(sSpeedTable[i].fDist, d_to_next_sem); d_to_next_sem = Min0R(sSpeedTable[i].fDist, d_to_next_sem);
} }
if (sSpeedTable[i].fDist <= d_to_next_sem)
{
VelSignalNext = sSpeedTable[i].fVelNext;
}
} }
else if (sSpeedTable[i].iFlags & spRoadVel) else if (sSpeedTable[i].iFlags & spRoadVel)
{ // to W6 { // to W6
@@ -1171,7 +1162,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
{ {
if (sSpeedTable[i].fSectionVelocityDist == 0.0) if (sSpeedTable[i].fSectionVelocityDist == 0.0)
{ {
if (Global::iWriteLogEnabled & 8) if (Global::iWriteLogEnabled & 8)
WriteLog("TableUpdate: Event is behind. SVD = 0: " + sSpeedTable[i].evEvent->asName); WriteLog("TableUpdate: Event is behind. SVD = 0: " + sSpeedTable[i].evEvent->asName);
sSpeedTable[i].iFlags = 0; // jeśli punktowy to kasujemy i nie dajemy ograniczenia na stałe sSpeedTable[i].iFlags = 0; // jeśli punktowy to kasujemy i nie dajemy ograniczenia na stałe
} }
@@ -1185,7 +1176,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
else if (sSpeedTable[i].fDist < -fLength) else if (sSpeedTable[i].fDist < -fLength)
{ // jeśli większe to musi wyjechać za poprzednie { // jeśli większe to musi wyjechać za poprzednie
VelLimitLast = sSpeedTable[i].fVelNext; VelLimitLast = sSpeedTable[i].fVelNext;
if (Global::iWriteLogEnabled & 8) if (Global::iWriteLogEnabled & 8)
WriteLog("TableUpdate: Event is behind. SVD < 0: " + sSpeedTable[i].evEvent->asName); WriteLog("TableUpdate: Event is behind. SVD < 0: " + sSpeedTable[i].evEvent->asName);
sSpeedTable[i].iFlags = 0; // wyjechaliśmy poza poprzednie, można skasować sSpeedTable[i].iFlags = 0; // wyjechaliśmy poza poprzednie, można skasować
} }
@@ -1204,7 +1195,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
else if (sSpeedTable[i].fDist < -fLength - sSpeedTable[i].fSectionVelocityDist) else if (sSpeedTable[i].fDist < -fLength - sSpeedTable[i].fSectionVelocityDist)
{ // { //
VelLimitLast = -1.0; VelLimitLast = -1.0;
if (Global::iWriteLogEnabled & 8) if (Global::iWriteLogEnabled & 8)
WriteLog("TableUpdate: Event is behind. SVD > 0: " + sSpeedTable[i].evEvent->asName); WriteLog("TableUpdate: Event is behind. SVD > 0: " + sSpeedTable[i].evEvent->asName);
sSpeedTable[i].iFlags = 0; // wyjechaliśmy poza poprzednie, można skasować sSpeedTable[i].iFlags = 0; // wyjechaliśmy poza poprzednie, można skasować
} }
@@ -1252,24 +1243,24 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
} }
else if (!(sSpeedTable[i].iFlags & spSectionVel)) //jeśli jakiś event pasywny ale nie ograniczenie else if (!(sSpeedTable[i].iFlags & spSectionVel)) //jeśli jakiś event pasywny ale nie ograniczenie
if (go == cm_Unknown) // jeśli nie było komendy wcześniej - pierwsza się liczy if (go == cm_Unknown) // jeśli nie było komendy wcześniej - pierwsza się liczy
// - ustawianie VelSignal // - ustawianie VelSignal
if (v < 0.0 ? true : v >= 1.0) // bo wartość 0.1 służy do hamowania tylko if (v < 0.0 ? true : v >= 1.0) // bo wartość 0.1 służy do hamowania tylko
{ {
go = cm_SetVelocity; // może odjechać go = cm_SetVelocity; // może odjechać
// Ra 2014-06: (VelSignal) nie może być tu ustawiane, bo semafor może // Ra 2014-06: (VelSignal) nie może być tu ustawiane, bo semafor może
// być daleko // być daleko
// VelSignal=v; //nie do końca tak, to jest druga prędkość; -1 nie // VelSignal=v; //nie do końca tak, to jest druga prędkość; -1 nie
// wpisywać... // wpisywać...
if (VelSignal == 0.0) if (VelSignal == 0.0)
VelSignal = -1.0; // aby stojący ruszył VelSignal = -1.0; // aby stojący ruszył
if (sSpeedTable[i].fDist < 0.0) // jeśli przejechany if (sSpeedTable[i].fDist < 0.0) // jeśli przejechany
{ {
if (v != 0 ? VelSignal = -1.0 : VelSignal = 0.0) if (v != 0 ? VelSignal = -1.0 : VelSignal = 0.0)
; // ustawienie, gdy przejechany jest lepsze niż ; // ustawienie, gdy przejechany jest lepsze niż
// wcale, ale to jeszcze nie to // wcale, ale to jeszcze nie to
if (sSpeedTable[i].iFlags & spEvent) // jeśli event if (sSpeedTable[i].iFlags & spEvent) // jeśli event
if ((sSpeedTable[i].evEvent != eSignSkip) ? if ((sSpeedTable[i].evEvent != eSignSkip) ?
true : true :
(sSpeedTable[i].fVelNext != 0.0)) // ale inny niż ten, (sSpeedTable[i].fVelNext != 0.0)) // ale inny niż ten,
// na którym minięto // na którym minięto
// S1, chyba że się // S1, chyba że się
@@ -1277,29 +1268,29 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
iDrivigFlags &= ~moveVisibility; // sygnał zezwalający na iDrivigFlags &= ~moveVisibility; // sygnał zezwalający na
// jazdę wyłącza jazdę na // jazdę wyłącza jazdę na
// widoczność (S1 na SBL) // widoczność (S1 na SBL)
// usunąć jeśli nie jest ograniczeniem prędkości // usunąć jeśli nie jest ograniczeniem prędkości
sSpeedTable[i].iFlags = sSpeedTable[i].iFlags =
0; // to można usunąć (nie mogą być usuwane w skanowaniu) 0; // to można usunąć (nie mogą być usuwane w skanowaniu)
}
} }
} else if (sSpeedTable[i].evEvent->StopCommand())
else if (sSpeedTable[i].evEvent->StopCommand())
{ // jeśli prędkość jest zerowa, a komórka zawiera komendę { // jeśli prędkość jest zerowa, a komórka zawiera komendę
eSignNext = sSpeedTable[i].evEvent; // dla informacji eSignNext = sSpeedTable[i].evEvent; // dla informacji
if (iDrivigFlags & if (iDrivigFlags &
moveStopHere) // jeśli ma stać, dostaje komendę od razu moveStopHere) // jeśli ma stać, dostaje komendę od razu
go = cm_Command; // komenda z komórki, do wykonania po zatrzymaniu go = cm_Command; // komenda z komórki, do wykonania po zatrzymaniu
else if (sSpeedTable[i].fDist <= 20.0) // jeśli ma dociągnąć, to niech else if (sSpeedTable[i].fDist <= 20.0) // jeśli ma dociągnąć, to niech
// dociąga (moveStopCloser // dociąga (moveStopCloser
// dotyczy dociągania do W4, nie // dotyczy dociągania do W4, nie
// semafora) // semafora)
go = cm_Command; // komenda z komórki, do wykonania po zatrzymaniu go = cm_Command; // komenda z komórki, do wykonania po zatrzymaniu
} }
} // jeśli nie ma zawalidrogi } // jeśli nie ma zawalidrogi
} // jeśli event } // jeśli event
if (v >= 0.0) if (v >= 0.0)
{ // pozycje z prędkością -1 można spokojnie pomijać { // pozycje z prędkością -1 można spokojnie pomijać
d = sSpeedTable[i].fDist; d = sSpeedTable[i].fDist;
if ((sSpeedTable[i].iFlags & spElapsed) ? if ((sSpeedTable[i].iFlags & spElapsed) ?
false : false :
d > 0.0) // sygnał lub ograniczenie z przodu (+32=przejechane) d > 0.0) // sygnał lub ograniczenie z przodu (+32=przejechane)
@@ -1355,7 +1346,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
} // if (v>=0.0) } // if (v>=0.0)
if (fNext >= 0.0) if (fNext >= 0.0)
{ // jeśli ograniczenie { // jeśli ograniczenie
if ((sSpeedTable[i].iFlags & (spEnabled | spEvent)) == if ((sSpeedTable[i].iFlags & (spEnabled | spEvent)) ==
(spEnabled | spEvent)) // tylko sygnał przypisujemy (spEnabled | spEvent)) // tylko sygnał przypisujemy
if (!eSignNext) // jeśli jeszcze nic nie zapisane tam if (!eSignNext) // jeśli jeszcze nic nie zapisane tam
eSignNext = sSpeedTable[i].evEvent; // dla informacji eSignNext = sSpeedTable[i].evEvent; // dla informacji
@@ -1365,25 +1356,25 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
} // if (sSpeedTable[i].iFlags&1) } // if (sSpeedTable[i].iFlags&1)
} // for } // for
if (VelSignalLast >= 0.0 && !(iDrivigFlags & (moveSemaphorFound | moveSwitchFound)) && if (VelSignalLast >= 0.0 && !(iDrivigFlags & (moveSemaphorFound | moveSwitchFound)) &&
(OrderCurrentGet() & Obey_train)) (OrderCurrentGet() & Obey_train))
VelSignalLast = -1.0; // jeśli mieliśmy ograniczenie z semafora i nie ma przed nami VelSignalLast = -1.0; // jeśli mieliśmy ograniczenie z semafora i nie ma przed nami
if (VelSignalLast >= 0.0) //analiza spisanych z tabelki ograniczeń i nadpisanie aktualnego if (VelSignalLast >= 0.0) //analiza spisanych z tabelki ograniczeń i nadpisanie aktualnego
fVelDes = Min0R(fVelDes, VelSignalLast); fVelDes = Min0R(fVelDes, VelSignalLast);
if (VelLimitLast >= 0.0) if (VelLimitLast >= 0.0)
fVelDes = Min0R(fVelDes, VelLimitLast); fVelDes = Min0R(fVelDes, VelLimitLast);
if (VelRoad >= 0.0) if (VelRoad >= 0.0)
fVelDes = Min0R(fVelDes, VelRoad); fVelDes = Min0R(fVelDes, VelRoad);
// nastepnego semafora albo zwrotnicy to uznajemy, że mijamy W5 // nastepnego semafora albo zwrotnicy to uznajemy, że mijamy W5
FirstSemaphorDist = d_to_next_sem; // przepisanie znalezionej wartosci do zmiennej FirstSemaphorDist = d_to_next_sem; // przepisanie znalezionej wartosci do zmiennej
return go; return go;
}; };
void TController::TablePurger() void TController::TablePurger()
{ // odtykacz: usuwa mniej istotne pozycje ze środka tabelki, aby uniknąć zatkania { // odtykacz: usuwa mniej istotne pozycje ze środka tabelki, aby uniknąć zatkania
//(np. brak ograniczenia pomiędzy zwrotnicami, usunięte sygnały, minięte odcinki łuku) //(np. brak ograniczenia pomiędzy zwrotnicami, usunięte sygnały, minięte odcinki łuku)
if (Global::iWriteLogEnabled & 8) if (Global::iWriteLogEnabled & 8)
WriteLog("TablePurger: Czyszczenie tabelki."); WriteLog("TablePurger: Czyszczenie tabelki.");
int i, j, k = iLast - iFirst; // może być 15 albo 16 pozycji, ostatniej nie ma co sprawdzać int i, j, k = iLast - iFirst; // może być 15 albo 16 pozycji, ostatniej nie ma co sprawdzać
if (k < 0) if (k < 0)
@@ -1395,15 +1386,15 @@ void TController::TablePurger()
true) true)
{ // jeśli jest to minięty (0x20) tor (0x03) do liczenia cięciw (0x80), a nie zwrotnica { // jeśli jest to minięty (0x20) tor (0x03) do liczenia cięciw (0x80), a nie zwrotnica
// (0x08) // (0x08)
for (; k > 0; --k, i = (i + 1) % iSpeedTableSize) for (; k > 0; --k, i = (i + 1) % iSpeedTableSize)
{ {
sSpeedTable[i] = sSpeedTable[(i + 1) % iSpeedTableSize]; // skopiowanie sSpeedTable[i] = sSpeedTable[(i + 1) % iSpeedTableSize]; // skopiowanie
if (&sSpeedTable[(i + 1) % iSpeedTableSize] == sSemNext) if (&sSpeedTable[(i + 1) % iSpeedTableSize] == sSemNext)
sSemNext = &sSpeedTable[i]; // przeniesienie znacznika o semaforze sSemNext = &sSpeedTable[i]; // przeniesienie znacznika o semaforze
if (&sSpeedTable[(i + 1) % iSpeedTableSize] == sSemNextStop) if (&sSpeedTable[(i + 1) % iSpeedTableSize] == sSemNextStop)
sSemNextStop = &sSpeedTable[i]; // przeniesienie znacznika o semaforze sSemNextStop = &sSpeedTable[i]; // przeniesienie znacznika o semaforze
} }
if (Global::iWriteLogEnabled & 8) if (Global::iWriteLogEnabled & 8)
WriteLog("Odtykacz usuwa pozycję"); WriteLog("Odtykacz usuwa pozycję");
iLast = (iLast - 1 + iSpeedTableSize) % iSpeedTableSize; // cofnięcie z zawinięciem iLast = (iLast - 1 + iSpeedTableSize) % iSpeedTableSize; // cofnięcie z zawinięciem
return; return;
@@ -1428,7 +1419,7 @@ void TController::TablePurger()
delete[] sSpeedTable; // to już nie potrzebne delete[] sSpeedTable; // to już nie potrzebne
sSpeedTable = t; // bo jest nowe sSpeedTable = t; // bo jest nowe
iSpeedTableSize += 16; iSpeedTableSize += 16;
if (Global::iWriteLogEnabled & 8) if (Global::iWriteLogEnabled & 8)
WriteLog("Tabelka powiększona do "+std::to_string(iSpeedTableSize)+" pozycji"); WriteLog("Tabelka powiększona do "+std::to_string(iSpeedTableSize)+" pozycji");
}; };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@@ -1450,7 +1441,7 @@ TController::TController(bool AI, TDynamicObject *NewControll, bool InitPsyche,
HelpMeFlag = false; HelpMeFlag = false;
// fProximityDist=1; //nie używane // fProximityDist=1; //nie używane
ActualProximityDist = 1; ActualProximityDist = 1;
FirstSemaphorDist = 10000.0; FirstSemaphorDist = 10000.0;
vCommandLocation.x = 0; vCommandLocation.x = 0;
vCommandLocation.y = 0; vCommandLocation.y = 0;
vCommandLocation.z = 0; vCommandLocation.z = 0;
@@ -1531,7 +1522,7 @@ TController::TController(bool AI, TDynamicObject *NewControll, bool InitPsyche,
fLength = 0.0; fLength = 0.0;
fMass = 0.0; //[kg] fMass = 0.0; //[kg]
eSignNext = NULL; // sygnał zmieniający prędkość, do pokazania na [F2] eSignNext = NULL; // sygnał zmieniający prędkość, do pokazania na [F2]
sSemNext = NULL; // pierwszy semafor w przebiegu sSemNext = NULL; // pierwszy semafor w przebiegu
sSemNextStop = NULL; // pierwszy semafor z sygnałem stój sSemNextStop = NULL; // pierwszy semafor z sygnałem stój
fShuntVelocity = 40; // domyślna prędkość manewrowa fShuntVelocity = 40; // domyślna prędkość manewrowa
fStopTime = 0.0; // czas postoju przed dalszą jazdą (np. na przystanku) fStopTime = 0.0; // czas postoju przed dalszą jazdą (np. na przystanku)
@@ -1890,7 +1881,7 @@ bool TController::CheckVehicles(TOrders user)
{ // jeśli pojazd posiada pantograf, to przydzielamy mu maskę, którą będzie informował o { // jeśli pojazd posiada pantograf, to przydzielamy mu maskę, którą będzie informował o
// jeździe bezprądowej // jeździe bezprądowej
p->iOverheadMask = pantmask; p->iOverheadMask = pantmask;
pantmask << 1; // przesunięcie bitów, max. 32 pojazdy z pantografami w składzie pantmask = pantmask << 1; // przesunięcie bitów, max. 32 pojazdy z pantografami w składzie
} }
d = p->DirectionSet(d ? 1 : -1); // zwraca położenie następnego (1=zgodny,0=odwrócony - d = p->DirectionSet(d ? 1 : -1); // zwraca położenie następnego (1=zgodny,0=odwrócony -
// względem czoła składu) // względem czoła składu)
@@ -1910,7 +1901,7 @@ bool TController::CheckVehicles(TOrders user)
else if (OrderCurrentGet() & (Shunt | Connect)) else if (OrderCurrentGet() & (Shunt | Connect))
{ {
Lights(16, (pVehicles[1]->MoverParameters->CabNo) ? Lights(16, (pVehicles[1]->MoverParameters->CabNo) ?
1 : 1 :
0); //światła manewrowe (Tb1) na pojeździe z napędem 0); //światła manewrowe (Tb1) na pojeździe z napędem
if (OrderCurrentGet() & Connect) // jeśli łączenie, skanować dalej if (OrderCurrentGet() & Connect) // jeśli łączenie, skanować dalej
pVehicles[0]->fScanDist = pVehicles[0]->fScanDist =
@@ -2173,10 +2164,9 @@ 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;
iDrivigFlags |= moveActive; // może skanować sygnały i reagować na komendy iDrivigFlags |= moveActive; // może skanować sygnały i reagować na komendy
@@ -2320,7 +2310,7 @@ bool TController::PrepareEngine()
if (OK) if (OK)
{ {
if (eStopReason == stopSleep) // jeśli dotychczas spał if (eStopReason == stopSleep) // jeśli dotychczas spał
eStopReason == stopNone; // teraz nie ma powodu do stania eStopReason = stopNone; // teraz nie ma powodu do stania
iEngineActive = 1; iEngineActive = 1;
return true; return true;
} }
@@ -2397,10 +2387,10 @@ bool TController::IncBrake()
switch (mvOccupied->BrakeSystem) switch (mvOccupied->BrakeSystem)
{ {
case Individual: case Individual:
if (mvOccupied->LocalBrake == ManualBrake) if (mvOccupied->LocalBrake == ManualBrake)
OK = mvOccupied->IncManualBrakeLevel(1 + floor(0.5 + fabs(AccDesired))); OK = mvOccupied->IncManualBrakeLevel(1 + floor(0.5 + fabs(AccDesired)));
else else
OK = mvOccupied->IncLocalBrakeLevel(1 + floor(0.5 + fabs(AccDesired))); OK = mvOccupied->IncLocalBrakeLevel(1 + floor(0.5 + fabs(AccDesired)));
break; break;
case Pneumatic: case Pneumatic:
if ((mvOccupied->Couplers[0].Connected == NULL) && if ((mvOccupied->Couplers[0].Connected == NULL) &&
@@ -2443,11 +2433,11 @@ bool TController::IncBrake()
mvOccupied->BrakeReleaser(0); mvOccupied->BrakeReleaser(0);
break; break;
case ElectroPneumatic: case ElectroPneumatic:
if (mvOccupied->EngineType == ElectricInductionMotor) if (mvOccupied->EngineType == ElectricInductionMotor)
{ {
OK = mvOccupied->IncLocalBrakeLevel(1); OK = mvOccupied->IncLocalBrakeLevel(1);
} }
else if (mvOccupied->fBrakeCtrlPos != mvOccupied->Handle->GetPos(bh_EPB)) else if (mvOccupied->fBrakeCtrlPos != mvOccupied->Handle->GetPos(bh_EPB))
{ {
mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_EPB)); mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_EPB));
if (mvOccupied->Handle->GetPos(bh_EPR) - mvOccupied->Handle->GetPos(bh_EPN) < 0.1) if (mvOccupied->Handle->GetPos(bh_EPR) - mvOccupied->Handle->GetPos(bh_EPN) < 0.1)
@@ -2473,10 +2463,10 @@ bool TController::DecBrake()
switch (mvOccupied->BrakeSystem) switch (mvOccupied->BrakeSystem)
{ {
case Individual: case Individual:
if (mvOccupied->LocalBrake == ManualBrake) if (mvOccupied->LocalBrake == ManualBrake)
OK = mvOccupied->DecManualBrakeLevel(1 + floor(0.5 + fabs(AccDesired))); OK = mvOccupied->DecManualBrakeLevel(1 + floor(0.5 + fabs(AccDesired)));
else else
OK = mvOccupied->DecLocalBrakeLevel(1 + floor(0.5 + fabs(AccDesired))); OK = mvOccupied->DecLocalBrakeLevel(1 + floor(0.5 + fabs(AccDesired)));
break; break;
case Pneumatic: case Pneumatic:
if (mvOccupied->BrakeCtrlPos > 0) if (mvOccupied->BrakeCtrlPos > 0)
@@ -2487,11 +2477,11 @@ bool TController::DecBrake()
Need_BrakeRelease = true; Need_BrakeRelease = true;
break; break;
case ElectroPneumatic: case ElectroPneumatic:
if (mvOccupied->EngineType == ElectricInductionMotor) if (mvOccupied->EngineType == ElectricInductionMotor)
{ {
OK = mvOccupied->DecLocalBrakeLevel(1); OK = mvOccupied->DecLocalBrakeLevel(1);
} }
else if (mvOccupied->fBrakeCtrlPos != mvOccupied->Handle->GetPos(bh_EPR)) else if (mvOccupied->fBrakeCtrlPos != mvOccupied->Handle->GetPos(bh_EPR))
{ {
mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_EPR)); mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_EPR));
if (mvOccupied->Handle->GetPos(bh_EPR) - mvOccupied->Handle->GetPos(bh_EPN) < 0.1) if (mvOccupied->Handle->GetPos(bh_EPR) - mvOccupied->Handle->GetPos(bh_EPN) < 0.1)
@@ -2595,15 +2585,15 @@ bool TController::IncSpeed()
OK = mvControlling->IncScndCtrl(1); OK = mvControlling->IncScndCtrl(1);
} }
break; break;
case ElectricInductionMotor: case ElectricInductionMotor:
if (!mvControlling->FuseFlag) if (!mvControlling->FuseFlag)
if (Ready || (iDrivigFlags & movePress) || (mvOccupied->ShuntMode)) //{(BrakePress<=0.01*MaxBrakePress)} if (Ready || (iDrivigFlags & movePress) || (mvOccupied->ShuntMode)) //{(BrakePress<=0.01*MaxBrakePress)}
{ {
OK = mvControlling->IncMainCtrl(1); OK = mvControlling->IncMainCtrl(1);
} }
break;
break; break;
break; case WheelsDriven:
case WheelsDriven:
if (!mvControlling->CabNo) if (!mvControlling->CabNo)
mvControlling->CabActivisation(); mvControlling->CabActivisation();
if (sin(mvControlling->eAngle) > 0) if (sin(mvControlling->eAngle) > 0)
@@ -2653,8 +2643,8 @@ bool TController::DecSpeed(bool force)
break; break;
case Dumb: case Dumb:
case DieselElectric: case DieselElectric:
case ElectricInductionMotor: case ElectricInductionMotor:
OK = mvControlling->DecScndCtrl(2); OK = mvControlling->DecScndCtrl(2);
if (!OK) if (!OK)
OK = mvControlling->DecMainCtrl(2 + (mvControlling->MainCtrlPos / 2)); OK = mvControlling->DecMainCtrl(2 + (mvControlling->MainCtrlPos / 2));
break; break;
@@ -2817,8 +2807,8 @@ void TController::SpeedSet()
break; break;
case Dumb: case Dumb:
case DieselElectric: case DieselElectric:
case ElectricInductionMotor: case ElectricInductionMotor:
break; break;
// WheelsDriven : // WheelsDriven :
// begin // begin
// OK:=False; // OK:=False;
@@ -2955,8 +2945,7 @@ bool TController::PutCommand(std::string NewCommand, double NewValue1, double Ne
if (ConversionError == -8) if (ConversionError == -8)
ErrorLog("Missed timetable: " + NewCommand); ErrorLog("Missed timetable: " + NewCommand);
WriteLog("Cannot load timetable file " + NewCommand + "\r\nError " + WriteLog("Cannot load timetable file " + NewCommand + "\r\nError " +
std::to_string(ConversionError) + " in position " + std::to_string(ConversionError) + " in position " + std::to_string(TrainParams->StationCount));
std::to_string(TrainParams->StationCount));
NewCommand = ""; // puste, dla wymiennej tekstury NewCommand = ""; // puste, dla wymiennej tekstury
} }
else else
@@ -2970,21 +2959,20 @@ bool TController::PutCommand(std::string NewCommand, double NewValue1, double Ne
NewCommand = Global::asCurrentSceneryPath + NewCommand + ".wav"; // na razie jeden NewCommand = Global::asCurrentSceneryPath + NewCommand + ".wav"; // na razie jeden
if (FileExists(NewCommand)) if (FileExists(NewCommand))
{ // wczytanie dźwięku odjazdu podawanego bezpośrenido { // wczytanie dźwięku odjazdu podawanego bezpośrenido
tsGuardSignal = tsGuardSignal = new TTextSound(NewCommand.c_str(), 30, pVehicle->GetPosition().x,
new TTextSound(NewCommand.c_str(), 30, pVehicle->GetPosition().x, pVehicle->GetPosition().y, pVehicle->GetPosition().z,
pVehicle->GetPosition().y, pVehicle->GetPosition().z, false); false);
// rsGuardSignal->Stop(); // rsGuardSignal->Stop();
iGuardRadio = 0; // nie przez radio iGuardRadio = 0; // nie przez radio
} }
else else
{ {
NewCommand = NewCommand.insert(NewCommand.find_last_of("."), NewCommand = NewCommand.insert(NewCommand.find_last_of("."),"radio"); // wstawienie przed kropkč
"radio"); // wstawienie przed kropkč
if (FileExists(NewCommand)) if (FileExists(NewCommand))
{ // wczytanie dźwięku odjazdu w wersji radiowej (słychać tylko w kabinie) { // wczytanie dźwięku odjazdu w wersji radiowej (słychać tylko w kabinie)
tsGuardSignal = new TTextSound( tsGuardSignal = new TTextSound(NewCommand.c_str(), -1, pVehicle->GetPosition().x,
NewCommand.c_str(), -1, pVehicle->GetPosition().x, pVehicle->GetPosition().y, pVehicle->GetPosition().z,
pVehicle->GetPosition().y, pVehicle->GetPosition().z, false); false);
iGuardRadio = iRadioChannel; iGuardRadio = iRadioChannel;
} }
} }
@@ -4091,7 +4079,7 @@ bool TController::UpdateSituation(double dt)
// Ra 2F1H: z tym (fTrackBlock) to nie jest najlepszy pomysł, bo lepiej by // Ra 2F1H: z tym (fTrackBlock) to nie jest najlepszy pomysł, bo lepiej by
// było porównać z odległością od sygnalizatora z przodu // było porównać z odległością od sygnalizatora z przodu
if ((OrderList[OrderPos] & Connect) ? (pVehicles[0]->fTrackBlock > 2000 || pVehicles[0]->fTrackBlock > FirstSemaphorDist) : if ((OrderList[OrderPos] & Connect) ? (pVehicles[0]->fTrackBlock > 2000 || pVehicles[0]->fTrackBlock > FirstSemaphorDist) :
true) true)
if ((comm = BackwardScan()) != cm_Unknown) // jeśli w drugą można jechać if ((comm = BackwardScan()) != cm_Unknown) // jeśli w drugą można jechać
{ // należy sprawdzać odległość od znalezionego sygnalizatora, { // należy sprawdzać odległość od znalezionego sygnalizatora,
// aby w przypadku prędkości 0.1 wyciągnąć najpierw skład za // aby w przypadku prędkości 0.1 wyciągnąć najpierw skład za
@@ -4232,12 +4220,12 @@ bool TController::UpdateSituation(double dt)
// VelDesired=fVelMax; //ile fabryka dala (Ra: uwzględione wagony) // VelDesired=fVelMax; //ile fabryka dala (Ra: uwzględione wagony)
else if (VelSignal >= 0) // jeśli skład był zatrzymany na początku i teraz już może jechać else if (VelSignal >= 0) // jeśli skład był zatrzymany na początku i teraz już może jechać
VelDesired = Global::Min0RSpeed(VelDesired, VelSignal); VelDesired = Global::Min0RSpeed(VelDesired, VelSignal);
if (mvOccupied->RunningTrack.Velmax >= if (mvOccupied->RunningTrack.Velmax >=
0) // ograniczenie prędkości z trajektorii ruchu 0) // ograniczenie prędkości z trajektorii ruchu
VelDesired = VelDesired =
Global::Min0RSpeed(VelDesired, Global::Min0RSpeed(VelDesired,
mvOccupied->RunningTrack.Velmax); // uwaga na ograniczenia szlakowej! mvOccupied->RunningTrack.Velmax); // uwaga na ograniczenia szlakowej!
if (VelforDriver >= 0) // tu jest zero przy zmianie kierunku jazdy if (VelforDriver >= 0) // tu jest zero przy zmianie kierunku jazdy
VelDesired = Global::Min0RSpeed(VelDesired, VelforDriver); // Ra: tu może być 40, jeśli VelDesired = Global::Min0RSpeed(VelDesired, VelforDriver); // Ra: tu może być 40, jeśli
// mechanik nie ma znajomości // mechanik nie ma znajomości
@@ -4254,7 +4242,7 @@ bool TController::UpdateSituation(double dt)
if ((sSemNext && sSemNext->fVelNext != 0.0) || (iDrivigFlags & moveStopHere)==0) if ((sSemNext && sSemNext->fVelNext != 0.0) || (iDrivigFlags & moveStopHere)==0)
{ // jeśli można jechać, to odpalić dźwięk kierownika oraz zamknąć drzwi w { // jeśli można jechać, to odpalić dźwięk kierownika oraz zamknąć drzwi w
// składzie, jeśli nie mamy czekać na sygnał też trzeba odpalić // składzie, jeśli nie mamy czekać na sygnał też trzeba odpalić
if (iDrivigFlags & moveGuardSignal) if (iDrivigFlags & moveGuardSignal)
{ // komunikat od kierownika tu, bo musi być wolna droga i odczekany czas { // komunikat od kierownika tu, bo musi być wolna droga i odczekany czas
// stania // stania
@@ -4427,16 +4415,16 @@ bool TController::UpdateSituation(double dt)
if (VelNext > 0.0) if (VelNext > 0.0)
AccDesired = AccPreferred; // można jechać AccDesired = AccPreferred; // można jechać
else // jeśli daleko jechać nie można else // jeśli daleko jechać nie można
if (ActualProximityDist > if (ActualProximityDist >
fMaxProximityDist) // ale ma kawałek do sygnalizatora fMaxProximityDist) // ale ma kawałek do sygnalizatora
{ // if ((iDrivigFlags&moveStopHere)?false:AccPreferred>0) { // if ((iDrivigFlags&moveStopHere)?false:AccPreferred>0)
if (AccPreferred > 0) if (AccPreferred > 0)
AccDesired = AccPreferred; // dociagnij do semafora; AccDesired = AccPreferred; // dociagnij do semafora;
else else
VelDesired = 0.0; //,AccDesired=-fabs(fAccGravity); //stoj (hamuj z siłą VelDesired = 0.0; //,AccDesired=-fabs(fAccGravity); //stoj (hamuj z siłą
// równą składowej stycznej grawitacji) // równą składowej stycznej grawitacji)
} }
else else
VelDesired = 0.0; // VelNext=0 i stoi bliżej niż fMaxProximityDist VelDesired = 0.0; // VelNext=0 i stoi bliżej niż fMaxProximityDist
} }
else // gdy jedzie wolniej niż potrzeba, albo nie ma przeszkód na drodze else // gdy jedzie wolniej niż potrzeba, albo nie ma przeszkód na drodze
@@ -4653,7 +4641,7 @@ bool TController::UpdateSituation(double dt)
AccDesired + 0.05))) // u góry ustawia się hamowanie na fAccThreshold AccDesired + 0.05))) // u góry ustawia się hamowanie na fAccThreshold
// if not MinVelFlag) // if not MinVelFlag)
if (fBrakeTime < 0 ? true : (AccDesired < fAccGravity - 0.3) || if (fBrakeTime < 0 ? true : (AccDesired < fAccGravity - 0.3) ||
(mvOccupied->BrakeCtrlPos <= 0)) (mvOccupied->BrakeCtrlPos <= 0))
if (!IncBrake()) // jeśli upłynął czas reakcji hamulca, chyba że if (!IncBrake()) // jeśli upłynął czas reakcji hamulca, chyba że
// nagłe albo luzował // nagłe albo luzował
MinVelFlag = true; MinVelFlag = true;

View File

@@ -1,4 +1,4 @@
/* /*
This Source Code Form is subject to the This Source Code Form is subject to the
terms of the Mozilla Public License, v. terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not 2.0. If a copy of the MPL was not
@@ -1886,11 +1886,11 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424"
{ {
} }
} // koniec hamulce } // koniec hamulce
else if (ActPar.substr(0, 1) == "") // tu mozna wpisac inny prefiks i inne rzeczy /* else if (ActPar.substr(0, 1) == "") // tu mozna wpisac inny prefiks i inne rzeczy
{ {
// jakies inne prefiksy // jakies inne prefiksy
} }
*/
} // koniec while kropka } // koniec while kropka
if (MoverParameters->CategoryFlag & 2) // jeśli samochód if (MoverParameters->CategoryFlag & 2) // jeśli samochód
@@ -2522,17 +2522,23 @@ bool TDynamicObject::Update(double dt, double dt1)
// ts.R=MyTrack->fRadius; //ujemne promienie są już zamienione przy // ts.R=MyTrack->fRadius; //ujemne promienie są już zamienione przy
// wczytywaniu // wczytywaniu
if (Axle0.vAngles.z != Axle1.vAngles.z) if (Axle0.vAngles.z != Axle1.vAngles.z)
{ // wyliczenie promienia z obrotów { // wyliczenie promienia z obrotów osi - modyfikację zgłosił youBy
// osi - modyfikację zgłosił youBy
ts.R = Axle0.vAngles.z - Axle1.vAngles.z; // różnica może dawać stałą ±M_2PI ts.R = Axle0.vAngles.z - Axle1.vAngles.z; // różnica może dawać stałą ±M_2PI
if (ts.R > M_PI) if( ( ts.R > 15000.0 ) || ( ts.R < -15000.0 ) ) {
ts.R -= M_2PI else if (ts.R < -M_PI) ts.R += M_2PI; // normalizacja // szkoda czasu na zbyt duże promienie, 4km to promień nie wymagający przechyłki
ts.R = 0.0;
}
else {
// normalizacja
if( ts.R > M_PI ) { ts.R -= M_2PI; }
else if( ts.R < -M_PI ) { ts.R += M_2PI; }
if( ts.R != 0.0 ) {
// sin(0) results in division by zero
// ts.R=fabs(0.5*MoverParameters->BDist/sin(ts.R*0.5)); // ts.R=fabs(0.5*MoverParameters->BDist/sin(ts.R*0.5));
ts.R = -0.5 * MoverParameters->BDist / sin(ts.R * 0.5); ts.R = -0.5 * MoverParameters->BDist / sin( ts.R * 0.5 );
if ((ts.R > 15000.0) || (ts.R < -15000.0)) }
ts.R = 0.0; // szkoda czasu na zbyt duże promienie, 4km to promień nie }
// wymagający
// przechyłki
} }
else else
ts.R = 0.0; ts.R = 0.0;
@@ -2840,7 +2846,7 @@ bool TDynamicObject::Update(double dt, double dt1)
i = 0; i = 0;
przek = przek / (np - nPrzekrF); przek = przek / (np - nPrzekrF);
for (TDynamicObject *p = GetFirstDynamic(MoverParameters->ActiveCab < 0 ? 1 : 0, 4); p; for (TDynamicObject *p = GetFirstDynamic(MoverParameters->ActiveCab < 0 ? 1 : 0, 4); p;
(kier > 0 ? p = p->NextC(4) : p = p->PrevC(4))) (true == kier ? p = p->NextC(4) : p = p->PrevC(4)))
{ {
if (!PrzekrF[i]) if (!PrzekrF[i])
{ {
@@ -2851,7 +2857,7 @@ bool TDynamicObject::Update(double dt, double dt1)
} }
i = 0; i = 0;
for (TDynamicObject *p = GetFirstDynamic(MoverParameters->ActiveCab < 0 ? 1 : 0, 4); p; for (TDynamicObject *p = GetFirstDynamic(MoverParameters->ActiveCab < 0 ? 1 : 0, 4); p;
(kier > 0 ? p = p->NextC(4) : p = p->PrevC(4))) (true == kier ? p = p->NextC(4) : p = p->PrevC(4)))
{ {
float Nmax = ((p->MoverParameters->P2FTrans * p->MoverParameters->MaxBrakePress[0] - float Nmax = ((p->MoverParameters->P2FTrans * p->MoverParameters->MaxBrakePress[0] -
p->MoverParameters->BrakeCylSpring) * p->MoverParameters->BrakeCylSpring) *
@@ -3389,24 +3395,24 @@ bool TDynamicObject::Update(double dt, double dt1)
// NBMX Obsluga drzwi, MC: zuniwersalnione // NBMX Obsluga drzwi, MC: zuniwersalnione
if ((dDoorMoveL < MoverParameters->DoorMaxShiftL) && (MoverParameters->DoorLeftOpened)) if ((dDoorMoveL < MoverParameters->DoorMaxShiftL) && (MoverParameters->DoorLeftOpened))
{ {
rsDoorOpen.Play(1, 0, MechInside, vPosition); rsDoorOpen.Play(vol, 0, MechInside, vPosition);
dDoorMoveL += dt1 * 0.5 * MoverParameters->DoorOpenSpeed; dDoorMoveL += dt1 * 0.5 * MoverParameters->DoorOpenSpeed;
} }
if ((dDoorMoveL > 0) && (!MoverParameters->DoorLeftOpened)) if ((dDoorMoveL > 0) && (!MoverParameters->DoorLeftOpened))
{ {
rsDoorClose.Play(1, 0, MechInside, vPosition); rsDoorClose.Play(vol, 0, MechInside, vPosition);
dDoorMoveL -= dt1 * MoverParameters->DoorCloseSpeed; dDoorMoveL -= dt1 * MoverParameters->DoorCloseSpeed;
if (dDoorMoveL < 0) if (dDoorMoveL < 0)
dDoorMoveL = 0; dDoorMoveL = 0;
} }
if ((dDoorMoveR < MoverParameters->DoorMaxShiftR) && (MoverParameters->DoorRightOpened)) if ((dDoorMoveR < MoverParameters->DoorMaxShiftR) && (MoverParameters->DoorRightOpened))
{ {
rsDoorOpen.Play(1, 0, MechInside, vPosition); rsDoorOpen.Play(vol, 0, MechInside, vPosition);
dDoorMoveR += dt1 * 0.5 * MoverParameters->DoorOpenSpeed; dDoorMoveR += dt1 * 0.5 * MoverParameters->DoorOpenSpeed;
} }
if ((dDoorMoveR > 0) && (!MoverParameters->DoorRightOpened)) if ((dDoorMoveR > 0) && (!MoverParameters->DoorRightOpened))
{ {
rsDoorClose.Play(1, 0, MechInside, vPosition); rsDoorClose.Play(vol, 0, MechInside, vPosition);
dDoorMoveR -= dt1 * MoverParameters->DoorCloseSpeed; dDoorMoveR -= dt1 * MoverParameters->DoorCloseSpeed;
if (dDoorMoveR < 0) if (dDoorMoveR < 0)
dDoorMoveR = 0; dDoorMoveR = 0;
@@ -3769,7 +3775,7 @@ void TDynamicObject::RenderSounds()
vol = rsSilnik.AM * MoverParameters->dizel_fill + rsSilnik.AA; vol = rsSilnik.AM * MoverParameters->dizel_fill + rsSilnik.AA;
else else
vol = vol =
rsSilnik.AM * fabs(MoverParameters->enrot / MoverParameters->nmax) + rsSilnik.AM * fabs(MoverParameters->enrot / MoverParameters->dizel_nmax) +
rsSilnik.AA * 0.9; rsSilnik.AA * 0.9;
} }
else else
@@ -4245,10 +4251,10 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
iMultiTex = 0; // czy jest wiele tekstur wymiennych? iMultiTex = 0; // czy jest wiele tekstur wymiennych?
parser.getTokens(); parser.getTokens();
parser >> asModel; parser >> asModel;
if (asModel.find('#') == asModel.length()) // Ra 2015-01: nie podoba mi się to if( asModel[asModel.size() - 1] == '#' ) // Ra 2015-01: nie podoba mi siê to
{ // model wymaga wielu tekstur wymiennych { // model wymaga wielu tekstur wymiennych
iMultiTex = 1; iMultiTex = 1;
asModel = asModel.substr(0, asModel.length() - 1); asModel.erase( asModel.length() - 1 );
} }
if ((i = asModel.find(',')) != std::string::npos) if ((i = asModel.find(',')) != std::string::npos)
{ // Ra 2015-01: może szukać przecinka w { // Ra 2015-01: może szukać przecinka w
@@ -4266,6 +4272,7 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
// modele w dynamics/basedir // modele w dynamics/basedir
Global::asCurrentTexturePath = BaseDir; // biezaca sciezka do tekstur to dynamic/... Global::asCurrentTexturePath = BaseDir; // biezaca sciezka do tekstur to dynamic/...
mdModel = TModelsManager::GetModel(asModel, true); mdModel = TModelsManager::GetModel(asModel, true);
assert( mdModel != nullptr ); // TODO: handle this more gracefully than all going to shit
if (ReplacableSkin != "none") if (ReplacableSkin != "none")
{ // tekstura wymienna jest raczej jedynie w "dynamic\" { // tekstura wymienna jest raczej jedynie w "dynamic\"
ReplacableSkin = ReplacableSkin =
@@ -4451,7 +4458,7 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
iAnimations = 0; iAnimations = 0;
do do
{ // kolejne liczby to ilość animacj, -1 to znacznik końca { // kolejne liczby to ilość animacj, -1 to znacznik końca
parser.getTokens( 1, false ); parser.getTokens( 1, false );
parser >> ile; // ilość danego typu parser >> ile; // ilość danego typu
// animacji // animacji
// if (co==ANIM_PANTS) // if (co==ANIM_PANTS)
@@ -4527,7 +4534,7 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
} }
if( token == "brakemode:" ) { if( token == "brakemode:" ) {
// Ra 15-01: gaďż˝ka nastawy hamulca // Ra 15-01: gałka nastawy hamulca
parser.getTokens(); parser.getTokens();
parser >> asAnimName; parser >> asAnimName;
smBrakeMode = mdModel->GetFromName(asAnimName.c_str()); smBrakeMode = mdModel->GetFromName(asAnimName.c_str());
@@ -4589,22 +4596,17 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
// układy // układy
if ((k >= 'A') && (k <= 'J')) // 10 chyba maksimum? if ((k >= 'A') && (k <= 'J')) // 10 chyba maksimum?
{ {
pAnimations[i++].dWheelAngle = pAnimations[i++].dWheelAngle = dWheelAngle + 1; // obrót osi napędzających
dWheelAngle + 1; // obrót osi napędzających --k; // następna będzie albo taka sama, albo bierzemy kolejny znak
--k; // następna będzie albo taka sama, albo bierzemy kolejny
// znak
m = 2; // następujące toczne będą miały inną średnicę m = 2; // następujące toczne będą miały inną średnicę
} }
else if ((k >= '1') && (k <= '9')) else if ((k >= '1') && (k <= '9'))
{ {
pAnimations[i++].dWheelAngle = dWheelAngle + m; // obrót osi pAnimations[i++].dWheelAngle = dWheelAngle + m; // obrót osi tocznych
// tocznych --k; // następna będzie albo taka sama, albo bierzemy kolejny znak
--k; // następna będzie albo taka sama, albo bierzemy kolejny
// znak
} }
else else
k = MoverParameters->AxleArangement[j++]; // pobranie kolejnego k = MoverParameters->AxleArangement[j++]; // pobranie kolejnego znaku
// znaku
} }
} }
} }
@@ -4773,9 +4775,8 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
m = float4x4( m = float4x4(
*sm->GetMatrix()); // skopiowanie, bo będziemy mnożyć *sm->GetMatrix()); // skopiowanie, bo będziemy mnożyć
m( 3 )[ 1 ] = m( 3 )[ 1 ] =
m[3][1] + 0.054; // w górę o wysokość ślizgu (na razie tak) m[ 3 ][ 1 ] + 0.054; // w górę o wysokość ślizgu (na razie tak)
while (sm->Parent) while( sm->Parent ) {
{
if( sm->Parent->GetMatrix() ) if( sm->Parent->GetMatrix() )
m = *sm->Parent->GetMatrix() * m; m = *sm->Parent->GetMatrix() * m;
sm = sm->Parent; sm = sm->Parent;
@@ -5749,19 +5750,10 @@ int TDynamicObject::RouteWish(TTrack *tr)
std::string TDynamicObject::TextureTest(std::string const &name) std::string TDynamicObject::TextureTest(std::string const &name)
{ // Ra 2015-01: sprawdzenie dostępności tekstury o podanej nazwie { // Ra 2015-01: sprawdzenie dostępności tekstury o podanej nazwie
std::string x = name + ".dds"; // na razie prymitywnie std::vector<std::string> extensions = { ".dds", ".tga", ".bmp" };
if (FileExists(x.c_str())) for( auto const &extension : extensions ) {
return x; if( true == FileExists( name + extension ) ) {
else return name + extension;
{
x = name + ".tga"; // w zasadzie to należałoby uwzględnić deklarowaną kolejność
if (FileExists(x.c_str()))
return x;
else
{
x = name + ".bmp";
if (FileExists(x.c_str()))
return x;
} }
} }
return ""; // nie znaleziona return ""; // nie znaleziona

View File

@@ -26,8 +26,9 @@ Stele, firleju, szociu, hunter, ZiomalCl, OLI_EU and others
#include "opengl/ARB_Multisample.h" #include "opengl/ARB_Multisample.h"
#include "Globals.h" #include "Globals.h"
#include "Console.h"
#include "Logs.h" #include "Logs.h"
#include "Console.h"
#include "PyInt.h"
#include "World.h" #include "World.h"
#include "Mover.h" #include "Mover.h"
@@ -58,8 +59,8 @@ LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration For WndProc
int InitGL(GLvoid) // All Setup For OpenGL Goes Here int InitGL(GLvoid) // All Setup For OpenGL Goes Here
{ {
_clear87(); // _clear87();
_control87(MCW_EM, MCW_EM); // _control87(MCW_EM, MCW_EM);
glewInit(); glewInit();
// hunter-271211: przeniesione // hunter-271211: przeniesione
// AllocConsole(); // AllocConsole();
@@ -571,8 +572,14 @@ int WINAPI WinMain(HINSTANCE hInstance, // instance
LPSTR lpCmdLine, // command line parameters LPSTR lpCmdLine, // command line parameters
int nCmdShow) // window show state int nCmdShow) // window show state
{ {
#ifdef _MSC_VER #if defined(_MSC_VER) && defined (_DEBUG)
// memory leaks
_CrtSetDbgFlag( _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ) | _CRTDBG_LEAK_CHECK_DF ); _CrtSetDbgFlag( _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ) | _CRTDBG_LEAK_CHECK_DF );
// floating point operation errors
auto state = _clearfp();
state = _control87( 0, 0 );
// this will turn on FPE for #IND and zerodiv
state = _control87( state & ~( _EM_ZERODIVIDE | _EM_INVALID ), _MCW_EM );
#endif #endif
MSG msg; // windows message structure MSG msg; // windows message structure
@@ -582,7 +589,7 @@ int WINAPI WinMain(HINSTANCE hInstance, // instance
Global::LoadIniFile("eu07.ini"); // teraz dopiero można przejrzeć plik z ustawieniami Global::LoadIniFile("eu07.ini"); // teraz dopiero można przejrzeć plik z ustawieniami
Global::InitKeys("keys.ini"); // wczytanie mapowania klawiszy - jest na stałe Global::InitKeys("keys.ini"); // wczytanie mapowania klawiszy - jest na stałe
// hunter-271211: ukrywanie konsoli // hunter-271211: ukrywanie konsoli
if (Global::iWriteLogEnabled & 2) if (Global::iWriteLogEnabled & 2)
{ {
AllocConsole(); AllocConsole();
@@ -701,6 +708,8 @@ int WINAPI WinMain(HINSTANCE hInstance, // instance
SystemParametersInfo(SPI_SETKEYBOARDSPEED, iOldSpeed, NULL, 0); SystemParametersInfo(SPI_SETKEYBOARDSPEED, iOldSpeed, NULL, 0);
SystemParametersInfo(SPI_SETKEYBOARDDELAY, iOldDelay, NULL, 0); SystemParametersInfo(SPI_SETKEYBOARDDELAY, iOldDelay, NULL, 0);
delete pConsole; // deaktywania sterownika delete pConsole; // deaktywania sterownika
TPythonInterpreter::killInstance();
// shutdown // shutdown
KillGLWindow(); // kill the window KillGLWindow(); // kill the window
return (msg.wParam); // exit the program return (msg.wParam); // exit the program

View File

@@ -72,6 +72,9 @@ TEvent::~TEvent()
delete[] Params[8].asPointer; // zwolnić obszar delete[] Params[8].asPointer; // zwolnić obszar
case tp_GetValues: // nic case tp_GetValues: // nic
break; break;
case tp_PutValues: // params[0].astext stores the token
SafeDeleteArray( Params[ 0 ].asText );
break;
} }
evJoined = NULL; // nie usuwać podczepionych tutaj evJoined = NULL; // nie usuwać podczepionych tutaj
}; };
@@ -87,6 +90,7 @@ void TEvent::Conditions(cParser *parser, string s)
std::string token, str; std::string token, str;
if (!asNodeName.empty()) if (!asNodeName.empty())
{ // podczepienie łańcucha, jeśli nie jest pusty { // podczepienie łańcucha, jeśli nie jest pusty
// BUG: source of a memory leak -- the array never gets deleted. fix the destructor
Params[9].asText = new char[asNodeName.length() + 1]; // usuwane i zamieniane na Params[9].asText = new char[asNodeName.length() + 1]; // usuwane i zamieniane na
// wskaźnik // wskaźnik
strcpy(Params[9].asText, asNodeName.c_str()); strcpy(Params[9].asText, asNodeName.c_str());
@@ -457,34 +461,43 @@ void TEvent::Load(cParser *parser, vector3 *org)
{ // obrót względem osi { // obrót względem osi
parser->getTokens(); parser->getTokens();
*parser >> token; *parser >> token;
Params[9].asText = new char[255]; // nazwa submodelu Params[9].asText = new char[token.size() + 1]; // nazwa submodelu
strcpy(Params[9].asText, token.c_str()); std::strcpy(Params[9].asText, token.c_str());
Params[0].asInt = 1; Params[0].asInt = 1;
parser->getTokens(4); parser->getTokens(4);
*parser >> Params[1].asdouble >> Params[2].asdouble >> Params[3].asdouble >> *parser
Params[4].asdouble; >> Params[1].asdouble
>> Params[2].asdouble
>> Params[3].asdouble
>> Params[4].asdouble;
} }
else if (token.compare("translate") == 0) else if (token.compare("translate") == 0)
{ // przesuw o wektor { // przesuw o wektor
parser->getTokens(); parser->getTokens();
*parser >> token; *parser >> token;
Params[9].asText = new char[255]; // nazwa submodelu Params[9].asText = new char[token.size() + 1]; // nazwa submodelu
strcpy(Params[9].asText, token.c_str()); std::strcpy(Params[9].asText, token.c_str());
Params[0].asInt = 2; Params[0].asInt = 2;
parser->getTokens(4); parser->getTokens(4);
*parser >> Params[1].asdouble >> Params[2].asdouble >> Params[3].asdouble >> *parser
Params[4].asdouble; >> Params[1].asdouble
>> Params[2].asdouble
>> Params[3].asdouble
>> Params[4].asdouble;
} }
else if (token.compare("digital") == 0) else if (token.compare("digital") == 0)
{ // licznik cyfrowy { // licznik cyfrowy
parser->getTokens(); parser->getTokens();
*parser >> token; *parser >> token;
Params[9].asText = new char[255]; // nazwa submodelu Params[9].asText = new char[token.size() + 1]; // nazwa submodelu
strcpy(Params[9].asText, token.c_str()); std::strcpy(Params[9].asText, token.c_str());
Params[0].asInt = 8; Params[0].asInt = 8;
parser->getTokens(4); // jaki ma być sens tych parametrów? parser->getTokens(4); // jaki ma być sens tych parametrów?
*parser >> Params[1].asdouble >> Params[2].asdouble >> Params[3].asdouble >> *parser
Params[4].asdouble; >> Params[1].asdouble
>> Params[2].asdouble
>> Params[3].asdouble
>> Params[4].asdouble;
} }
else if (token.substr(token.length() - 4, 4) == ".vmd") // na razie tu, może będzie inaczej else if (token.substr(token.length() - 4, 4) == ".vmd") // na razie tu, może będzie inaczej
{ // animacja z pliku VMD { // animacja z pliku VMD
@@ -499,12 +512,15 @@ void TEvent::Load(cParser *parser, vector3 *org)
} }
parser->getTokens(); parser->getTokens();
*parser >> token; *parser >> token;
Params[9].asText = new char[255]; // nazwa submodelu Params[9].asText = new char[token.size() + 1]; // nazwa submodelu
strcpy(Params[9].asText, token.c_str()); std::strcpy(Params[9].asText, token.c_str());
Params[0].asInt = 4; // rodzaj animacji Params[0].asInt = 4; // rodzaj animacji
parser->getTokens(4); parser->getTokens(4);
*parser >> Params[1].asdouble >> Params[2].asdouble >> Params[3].asdouble >> *parser
Params[4].asdouble; >> Params[1].asdouble
>> Params[2].asdouble
>> Params[3].asdouble
>> Params[4].asdouble;
} }
parser->getTokens(); parser->getTokens();
*parser >> token; *parser >> token;

View File

@@ -187,7 +187,7 @@ int Global::iBpp = 32; // chyba już nie używa się kart, na których 16bpp co
// maciek001: konfiguracja wstępna portu COM // maciek001: konfiguracja wstępna portu COM
bool Global::bMWDdebugEnable = false; bool Global::bMWDdebugEnable = false;
bool Global::bMWDInputDataEnable = false; bool Global::bMWDInputDataEnable = false;
unsigned long int Global::iMWDBaudrate = 500000; unsigned int Global::iMWDBaudrate = 500000;
std::string Global::sMWDPortId = "COM1"; // nazwa portu z którego korzystamy - na razie nie działa std::string Global::sMWDPortId = "COM1"; // nazwa portu z którego korzystamy - na razie nie działa
bool Global::bMWDBreakEnable = false; // zmienić na FALSE!!! jak już będzie działać wczytywanie z *.ini bool Global::bMWDBreakEnable = false; // zmienić na FALSE!!! jak już będzie działać wczytywanie z *.ini
double Global::fMWDAnalogCalib[4][3] = {{1023, 0, 1023},{1023, 0, 1023},{1023, 0, 1023},{1023, 0, 1023}}; // wartość max potencjometru, wartość min potencjometru, rozdzielczość (max. wartość jaka może być -1) double Global::fMWDAnalogCalib[4][3] = {{1023, 0, 1023},{1023, 0, 1023},{1023, 0, 1023},{1023, 0, 1023}}; // wartość max potencjometru, wartość min potencjometru, rozdzielczość (max. wartość jaka może być -1)
@@ -1247,7 +1247,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

@@ -42,7 +42,6 @@ http://mozilla.org/MPL/2.0/.
#define _PROBLEND 1 #define _PROBLEND 1
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
#pragma package(smart_init)
bool bCondition; // McZapkie: do testowania warunku na event multiple bool bCondition; // McZapkie: do testowania warunku na event multiple
string LogComment; string LogComment;
@@ -77,7 +76,7 @@ TGroundNode::TGroundNode()
asName = ""; asName = "";
// Color= TMaterialColor(1); // Color= TMaterialColor(1);
// fAngle=0; //obrót dla modelu // fAngle=0; //obrót dla modelu
// fLineThickness=1.0; //mm dla linii fLineThickness=1.0; //mm dla linii
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
{ {
Ambient[i] = Global::whiteLight[i] * 255; Ambient[i] = Global::whiteLight[i] * 255;
@@ -117,6 +116,9 @@ TGroundNode::~TGroundNode()
delete Model; delete Model;
Model = NULL; Model = NULL;
break; break;
case TP_SOUND:
SafeDelete(tsStaticSound);
break;
case TP_TERRAIN: case TP_TERRAIN:
{ // pierwsze nNode zawiera model E3D, reszta to trójkąty { // pierwsze nNode zawiera model E3D, reszta to trójkąty
for (int i = 1; i < iCount; ++i) for (int i = 1; i < iCount; ++i)
@@ -681,22 +683,12 @@ void TGroundNode::RenderAlphaDL()
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
//------------------ Podstawowy pojemnik terenu - sektor ----------------------- //------------------ Podstawowy pojemnik terenu - sektor -----------------------
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
TSubRect::TSubRect()
{
nRootNode = NULL; // lista wszystkich obiektów jest pusta
nRenderHidden = nRenderRect = nRenderRectAlpha = nRender = nRenderMixed = nRenderAlpha =
nRenderWires = NULL;
tTrackAnim = NULL; // nic nie animujemy
tTracks = NULL; // nie ma jeszcze torów
nRootMesh = nMeshed = NULL; // te listy też są puste
iNodeCount = 0; // licznik obiektów
iTracks = 0; // licznik torów
}
TSubRect::~TSubRect() TSubRect::~TSubRect()
{ {
if (Global::bManageNodes) // Ra: tu się coś sypie if (Global::bManageNodes) // Ra: tu się coś sypie
ResourceManager::Unregister(this); // wyrejestrowanie ze sprzątacza ResourceManager::Unregister(this); // wyrejestrowanie ze sprzątacza
// TODO: usunąć obiekty z listy (nRootMesh), bo są one tworzone dla sektora // TODO: usunąć obiekty z listy (nRootMesh), bo są one tworzone dla sektora
delete[] tTracks;
} }
void TSubRect::NodeAdd(TGroundNode *Node) void TSubRect::NodeAdd(TGroundNode *Node)
@@ -735,7 +727,7 @@ void TSubRect::NodeAdd(TGroundNode *Node)
{ {
if (t && (Node->TextureID != t)) if (t && (Node->TextureID != t))
{ // jeśli są dwie różne tekstury, dodajemy drugi obiekt dla danego toru { // jeśli są dwie różne tekstury, dodajemy drugi obiekt dla danego toru
TGroundNode *n = new TGroundNode(); TGroundNode *n = new TGroundNode(); // BUG: source of a memory leak here
n->iType = TP_DUMMYTRACK; // obiekt renderujący siatki dla tekstury n->iType = TP_DUMMYTRACK; // obiekt renderujący siatki dla tekstury
n->TextureID = t; n->TextureID = t;
n->pTrack = Node->pTrack; // wskazuje na ten sam tor n->pTrack = Node->pTrack; // wskazuje na ten sam tor
@@ -958,7 +950,7 @@ void TSubRect::Sort()
if (t < n1->TextureID) // jeśli (n1) ma inną teksturę niż poprzednie if (t < n1->TextureID) // jeśli (n1) ma inną teksturę niż poprzednie
{ // można zrobić obiekt renderujący { // można zrobić obiekt renderujący
t = n1->TextureID; t = n1->TextureID;
n2 = new TGroundNode(); n2 = new TGroundNode(); // BUG: source of a memory leak here
n2->nNext2 = nRootMesh; n2->nNext2 = nRootMesh;
nRootMesh = n2; // podczepienie na początku listy nRootMesh = n2; // podczepienie na początku listy
nRootMesh->iType = TP_MESH; // obiekt renderujący siatki dla tekstury nRootMesh->iType = TP_MESH; // obiekt renderujący siatki dla tekstury
@@ -1303,6 +1295,9 @@ void TGround::MoveGroundNode(vector3 pPosition)
*/ */
} }
TGroundVertex TempVerts[ 10000 ]; // tu wczytywane s¹ trójk¹ty
BYTE TempConnectionType[ 200 ]; // Ra: sprzêgi w sk³adzie; ujemne, gdy odwrotnie
TGround::TGround() TGround::TGround()
{ {
// RootNode=NULL; // RootNode=NULL;
@@ -1320,6 +1315,8 @@ TGround::TGround()
nRootOfType[i] = NULL; // zerowanie tablic wyszukiwania nRootOfType[i] = NULL; // zerowanie tablic wyszukiwania
bDynamicRemove = false; // na razie nic do usunięcia bDynamicRemove = false; // na razie nic do usunięcia
sTracks = new TNames(); // nazwy torów - na razie tak sTracks = new TNames(); // nazwy torów - na razie tak
::SecureZeroMemory( TempVerts, sizeof( TempVerts ) );
::SecureZeroMemory( TempConnectionType, sizeof( TempConnectionType ) );
} }
TGround::~TGround() TGround::~TGround()
@@ -1410,9 +1407,6 @@ int iTrainSetWehicleNumber = 0;
TGroundNode *nTrainSetNode = NULL; // poprzedni pojazd do łączenia TGroundNode *nTrainSetNode = NULL; // poprzedni pojazd do łączenia
TGroundNode *nTrainSetDriver = NULL; // pojazd, któremu zostanie wysłany rozkład TGroundNode *nTrainSetDriver = NULL; // pojazd, któremu zostanie wysłany rozkład
TGroundVertex TempVerts[10000]; // tu wczytywane są trójkąty
BYTE TempConnectionType[200]; // Ra: sprzęgi w składzie; ujemne, gdy odwrotnie
void TGround::RaTriangleDivider(TGroundNode *node) void TGround::RaTriangleDivider(TGroundNode *node)
{ // tworzy dodatkowe trójkąty i zmiejsza podany { // tworzy dodatkowe trójkąty i zmiejsza podany
// to jest wywoływane przy wczytywaniu trójkątów // to jest wywoływane przy wczytywaniu trójkątów
@@ -1767,8 +1761,7 @@ TGroundNode * TGround::AddGroundNode(cParser *parser)
*parser >> token; *parser >> token;
str = token; str = token;
//str = AnsiString(token.c_str()); //str = AnsiString(token.c_str());
tmp->tsStaticSound = new TTextSound(strdup(str.c_str()), sqrt(tmp->fSquareRadius), tmp->pCenter.x, tmp->tsStaticSound = new TTextSound(str, sqrt(tmp->fSquareRadius), tmp->pCenter.x, tmp->pCenter.y, tmp->pCenter.z, false, rmin);
tmp->pCenter.y, tmp->pCenter.z, false, rmin);
if (rmin < 0.0) if (rmin < 0.0)
rmin = rmin =
0.0; // przywrócenie poprawnej wartości, jeśli służyła do wyłączenia efektu Dopplera 0.0; // przywrócenie poprawnej wartości, jeśli służyła do wyłączenia efektu Dopplera
@@ -2273,8 +2266,9 @@ void TGround::FirstInit()
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
std::string xxxzzz = 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(3, 3),0) - 500)); ( std::stoi( xxxzzz.substr( 0, 3 )) - 500 ) * 1000,
( std::stoi( xxxzzz.substr( 3, 3 )) - 500 ) * 1000 );
if (Global::bUseVBO) if (Global::bUseVBO)
gr->nTerrain = Current->nNode + j; // zapamiętanie gr->nTerrain = Current->nNode + j; // zapamiętanie
else else
@@ -2320,9 +2314,7 @@ void TGround::FirstInit()
WriteLog("InitLaunchers OK"); WriteLog("InitLaunchers OK");
WriteLog("InitGlobalTime"); WriteLog("InitGlobalTime");
// ABu 160205: juz nie TODO :) // ABu 160205: juz nie TODO :)
GlobalTime = new TMTableTime( GlobalTime = std::make_shared<TMTableTime>( hh, mm, srh, srm, ssh, ssm ); // McZapkie-300302: inicjacja czasu rozkladowego - TODO: czytac z trasy!
hh, mm, srh, srm, ssh,
ssm); // McZapkie-300302: inicjacja czasu rozkladowego - TODO: czytac z trasy!
WriteLog("InitGlobalTime OK"); WriteLog("InitGlobalTime OK");
// jeszcze ustawienie pogody, gdyby nie było w scenerii wpisów // jeszcze ustawienie pogody, gdyby nie było w scenerii wpisów
glClearColor(Global::AtmoColor[0], Global::AtmoColor[1], Global::AtmoColor[2], glClearColor(Global::AtmoColor[0], Global::AtmoColor[1], Global::AtmoColor[2],
@@ -3134,13 +3126,12 @@ bool TGround::InitEvents()
strcpy(buff, Current->Params[i].asText); strcpy(buff, Current->Params[i].asText);
SafeDeleteArray(Current->Params[i].asText); SafeDeleteArray(Current->Params[i].asText);
Current->Params[i].asEvent = FindEvent(buff); Current->Params[i].asEvent = FindEvent(buff);
if (!Current->Params[i].asEvent) // Ra: tylko w logu informacja o braku if( !Current->Params[ i ].asEvent ) { // Ra: tylko w logu informacja o braku
if (string(Current->Params[i].asText).substr(0, 5) != "none_") if( ( Current->Params[ i ].asText == NULL )
{ || ( std::string( Current->Params[ i ].asText ).substr( 0, 5 ) != "none_" ) ) {
WriteLog("Event \"" + string(buff) + WriteLog( "Event \"" + string( buff ) + "\" does not exist" );
"\" does not exist"); ErrorLog( "Missed event: " + string( buff ) + " in multiple " + Current->asName );
ErrorLog("Missed event: " + string(buff) + " in multiple " + }
Current->asName);
} }
} }
} }

View File

@@ -182,28 +182,28 @@ class TGroundNode : public Resource
class TSubRect : public Resource, public CMesh class TSubRect : public Resource, public CMesh
{ // sektor składowy kwadratu kilometrowego { // sektor składowy kwadratu kilometrowego
public: public:
int iTracks; // ilość torów w (tTracks) int iTracks = 0; // ilość torów w (tTracks)
TTrack **tTracks; // tory do renderowania pojazdów TTrack **tTracks = nullptr; // tory do renderowania pojazdów
protected: protected:
TTrack *tTrackAnim; // obiekty do przeliczenia animacji TTrack *tTrackAnim = nullptr; // obiekty do przeliczenia animacji
TGroundNode *nRootMesh; // obiekty renderujące wg tekstury (wtórne, lista po nNext2) TGroundNode *nRootMesh = nullptr; // obiekty renderujące wg tekstury (wtórne, lista po nNext2)
TGroundNode *nMeshed; // lista obiektów dla których istnieją obiekty renderujące grupowo TGroundNode *nMeshed = nullptr; // lista obiektów dla których istnieją obiekty renderujące grupowo
public: public:
TGroundNode * TGroundNode *
nRootNode; // wszystkie obiekty w sektorze, z wyjątkiem renderujących i pojazdów (nNext2) nRootNode = nullptr; // wszystkie obiekty w sektorze, z wyjątkiem renderujących i pojazdów (nNext2)
TGroundNode * TGroundNode *
nRenderHidden; // lista obiektów niewidocznych, "renderowanych" również z tyłu (nNext3) nRenderHidden = nullptr; // lista obiektów niewidocznych, "renderowanych" również z tyłu (nNext3)
TGroundNode *nRenderRect; // z poziomu sektora - nieprzezroczyste (nNext3) TGroundNode *nRenderRect = nullptr; // z poziomu sektora - nieprzezroczyste (nNext3)
TGroundNode *nRenderRectAlpha; // z poziomu sektora - przezroczyste (nNext3) TGroundNode *nRenderRectAlpha = nullptr; // z poziomu sektora - przezroczyste (nNext3)
TGroundNode *nRenderWires; // z poziomu sektora - druty i inne linie (nNext3) TGroundNode *nRenderWires = nullptr; // z poziomu sektora - druty i inne linie (nNext3)
TGroundNode *nRender; // indywidualnie - nieprzezroczyste (nNext3) TGroundNode *nRender = nullptr; // indywidualnie - nieprzezroczyste (nNext3)
TGroundNode *nRenderMixed; // indywidualnie - nieprzezroczyste i przezroczyste (nNext3) TGroundNode *nRenderMixed = nullptr; // indywidualnie - nieprzezroczyste i przezroczyste (nNext3)
TGroundNode *nRenderAlpha; // indywidualnie - przezroczyste (nNext3) TGroundNode *nRenderAlpha = nullptr; // indywidualnie - przezroczyste (nNext3)
int iNodeCount; // licznik obiektów, do pomijania pustych sektorów int iNodeCount = 0; // licznik obiektów, do pomijania pustych sektorów
public: public:
void LoadNodes(); // utworzenie VBO sektora void LoadNodes(); // utworzenie VBO sektora
public: public:
TSubRect(); // TSubRect() = default;
virtual ~TSubRect(); virtual ~TSubRect();
virtual void Release(); // zwalnianie VBO sektora virtual void Release(); // zwalnianie VBO sektora
void NodeAdd(TGroundNode *Node); // dodanie obiektu do sektora na etapie rozdzielania na sektory void NodeAdd(TGroundNode *Node); // dodanie obiektu do sektora na etapie rozdzielania na sektory

View File

@@ -1,22 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.40629.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "maszyna", "maszyna.vcxproj", "{8E0232E5-1C67-442F-9E04-45ED2DDFC960}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8E0232E5-1C67-442F-9E04-45ED2DDFC960}.Debug|x86.ActiveCfg = Debug|Win32
{8E0232E5-1C67-442F-9E04-45ED2DDFC960}.Debug|x86.Build.0 = Debug|Win32
{8E0232E5-1C67-442F-9E04-45ED2DDFC960}.Release|x86.ActiveCfg = Release|Win32
{8E0232E5-1C67-442F-9E04-45ED2DDFC960}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -1,202 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{8E0232E5-1C67-442F-9E04-45ED2DDFC960}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140_xp</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<TargetName>eu07++</TargetName>
<IntDir>$(SolutionDir)tmp\$(PlatformShortName)-$(Configuration)\$(ProjectName)\</IntDir>
<OutDir>$(SolutionDir)bin\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<TargetName>eu07++</TargetName>
<IntDir>$(SolutionDir)tmp\$(PlatformShortName)-$(Configuration)\$(ProjectName)\</IntDir>
<OutDir>$(SolutionDir)bin\</OutDir>
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(SolutionDir);$(SolutionDir)console;$(SolutionDir)mczapkie;$(SolutionDir)opengl;$(SolutionDir)python/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeader>Use</PrecompiledHeader>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<AdditionalLibraryDirectories>$(DXSKD_DIR)lib/$(PlatformShortName);$(SolutionDir)opengl;$(SolutionDir)python/libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>$(SolutionDir);$(SolutionDir)console;$(SolutionDir)mczapkie;$(SolutionDir)opengl;$(SolutionDir)python/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeader>Use</PrecompiledHeader>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(DXSKD_DIR)lib/$(PlatformShortName);$(SolutionDir)opengl;$(SolutionDir)python/libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="AdvSound.cpp" />
<ClCompile Include="AirCoupler.cpp" />
<ClCompile Include="AnimModel.cpp" />
<ClCompile Include="Button.cpp" />
<ClCompile Include="Camera.cpp" />
<ClCompile Include="Console.cpp" />
<ClCompile Include="console\LPT.cpp" />
<ClCompile Include="Console\MWD.cpp" />
<ClCompile Include="console\PoKeys55.cpp" />
<ClCompile Include="Driver.cpp" />
<ClCompile Include="dumb3d.cpp" />
<ClCompile Include="DynObj.cpp" />
<ClCompile Include="EU07.cpp" />
<ClCompile Include="Event.cpp" />
<ClCompile Include="EvLaunch.cpp" />
<ClCompile Include="FadeSound.cpp" />
<ClCompile Include="Float3d.cpp" />
<ClCompile Include="Gauge.cpp" />
<ClCompile Include="Globals.cpp" />
<ClCompile Include="Ground.cpp" />
<ClCompile Include="Logs.cpp" />
<ClCompile Include="mczapkie\friction.cpp" />
<ClCompile Include="mczapkie\hamulce.cpp" />
<ClCompile Include="mczapkie\mctools.cpp" />
<ClCompile Include="mczapkie\Mover.cpp" />
<ClCompile Include="mczapkie\Oerlikon_ESt.cpp" />
<ClCompile Include="MdlMngr.cpp" />
<ClCompile Include="MemCell.cpp" />
<ClCompile Include="Model3d.cpp" />
<ClCompile Include="mtable.cpp" />
<ClCompile Include="Names.cpp" />
<ClCompile Include="opengl\ARB_Multisample.cpp" />
<ClCompile Include="parser.cpp" />
<ClCompile Include="PyInt.cpp" />
<ClCompile Include="RealSound.cpp" />
<ClCompile Include="ResourceManager.cpp" />
<ClCompile Include="Segment.cpp" />
<ClCompile Include="sky.cpp" />
<ClCompile Include="Sound.cpp" />
<ClCompile Include="Spring.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="Texture.cpp" />
<ClCompile Include="TextureDDS.cpp" />
<ClCompile Include="Timer.cpp" />
<ClCompile Include="Track.cpp" />
<ClCompile Include="Traction.cpp" />
<ClCompile Include="TractionPower.cpp" />
<ClCompile Include="Train.cpp" />
<ClCompile Include="TrkFoll.cpp" />
<ClCompile Include="VBO.cpp" />
<ClCompile Include="wavread.cpp" />
<ClCompile Include="World.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="AdvSound.h" />
<ClInclude Include="AirCoupler.h" />
<ClInclude Include="AnimModel.h" />
<ClInclude Include="Button.h" />
<ClInclude Include="Camera.h" />
<ClInclude Include="Classes.h" />
<ClInclude Include="Console.h" />
<ClInclude Include="Console\LPT.h" />
<ClInclude Include="Console\MWD.h" />
<ClInclude Include="Console\PoKeys55.h" />
<ClInclude Include="dumb3d.h" />
<ClInclude Include="DynObj.h" />
<ClInclude Include="Event.h" />
<ClInclude Include="FadeSound.h" />
<ClInclude Include="Float3d.h" />
<ClInclude Include="Gauge.h" />
<ClInclude Include="Globals.h" />
<ClInclude Include="Ground.h" />
<ClInclude Include="Logs.h" />
<ClInclude Include="McZapkie\friction.h" />
<ClInclude Include="McZapkie\hamulce.h" />
<ClInclude Include="McZapkie\mctools.h" />
<ClInclude Include="McZapkie\mover.h" />
<ClInclude Include="McZapkie\Oerlikon_ESt.h" />
<ClInclude Include="MdlMngr.h" />
<ClInclude Include="Model3d.h" />
<ClInclude Include="Names.h" />
<ClInclude Include="opengl\arb_multisample.h" />
<ClInclude Include="opengl\glew.h" />
<ClInclude Include="opengl\wglew.h" />
<ClInclude Include="parser.h" />
<ClInclude Include="PyInt.h" />
<ClInclude Include="python\include\Python.h" />
<ClInclude Include="RealSound.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="Segment.h" />
<ClInclude Include="sky.h" />
<ClInclude Include="Sound.h" />
<ClInclude Include="Spring.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="Texture.h" />
<ClInclude Include="TractionPower.h" />
<ClInclude Include="Train.h" />
<ClInclude Include="usefull.h" />
<ClInclude Include="VBO.h" />
<ClInclude Include="World.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="maszyna.rc" />
</ItemGroup>
<ItemGroup>
<Image Include="eu07.ico" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -1,346 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
</Filter>
<Filter Include="Source Files\opengl">
<UniqueIdentifier>{d91dfdb6-7d84-4b52-a16a-bad302b45e3c}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\mczapkie">
<UniqueIdentifier>{fafd38ab-4c2a-48c8-8e66-ad0d928573b3}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\console">
<UniqueIdentifier>{2d73d7b2-5252-499c-963a-88fa3cb1af53}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\opengl">
<UniqueIdentifier>{aec51dd3-af67-4f08-9dcb-889f673ad7c9}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\mczapkie">
<UniqueIdentifier>{36684428-8a48-435f-bca4-a24d9bfe2587}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\console">
<UniqueIdentifier>{cdf75bec-91f7-413c-8b57-9e32cba49148}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="AdvSound.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="AirCoupler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="AnimModel.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Button.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Camera.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Console.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Driver.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="dumb3d.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DynObj.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="EU07.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Event.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="EvLaunch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="FadeSound.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Float3d.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Gauge.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Globals.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Ground.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Logs.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MdlMngr.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MemCell.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Model3d.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="mtable.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Names.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="parser.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PyInt.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="RealSound.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ResourceManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Segment.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="sky.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Sound.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Spring.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Texture.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="TextureDDS.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Timer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Track.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Traction.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="TractionPower.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Train.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="TrkFoll.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="VBO.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="wavread.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="World.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="opengl\ARB_Multisample.cpp">
<Filter>Source Files\opengl</Filter>
</ClCompile>
<ClCompile Include="mczapkie\friction.cpp">
<Filter>Source Files\mczapkie</Filter>
</ClCompile>
<ClCompile Include="mczapkie\hamulce.cpp">
<Filter>Source Files\mczapkie</Filter>
</ClCompile>
<ClCompile Include="console\LPT.cpp">
<Filter>Source Files\console</Filter>
</ClCompile>
<ClCompile Include="mczapkie\mctools.cpp">
<Filter>Source Files\mczapkie</Filter>
</ClCompile>
<ClCompile Include="mczapkie\Mover.cpp">
<Filter>Source Files\mczapkie</Filter>
</ClCompile>
<ClCompile Include="mczapkie\Oerlikon_ESt.cpp">
<Filter>Source Files\mczapkie</Filter>
</ClCompile>
<ClCompile Include="console\PoKeys55.cpp">
<Filter>Source Files\console</Filter>
</ClCompile>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Console\MWD.cpp">
<Filter>Source Files\console</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="opengl\glew.h">
<Filter>Header Files\opengl</Filter>
</ClInclude>
<ClInclude Include="opengl\arb_multisample.h">
<Filter>Header Files\opengl</Filter>
</ClInclude>
<ClInclude Include="Globals.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Console.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Logs.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="McZapkie\mover.h">
<Filter>Header Files\mczapkie</Filter>
</ClInclude>
<ClInclude Include="World.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="dumb3d.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="PyInt.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="usefull.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Classes.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Texture.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Camera.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Ground.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MdlMngr.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="sky.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="parser.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="VBO.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Float3d.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="python\include\Python.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="TractionPower.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="McZapkie\Oerlikon_ESt.h">
<Filter>Header Files\mczapkie</Filter>
</ClInclude>
<ClInclude Include="McZapkie\mctools.h">
<Filter>Header Files\mczapkie</Filter>
</ClInclude>
<ClInclude Include="McZapkie\hamulce.h">
<Filter>Header Files\mczapkie</Filter>
</ClInclude>
<ClInclude Include="McZapkie\friction.h">
<Filter>Header Files\mczapkie</Filter>
</ClInclude>
<ClInclude Include="Console\PoKeys55.h">
<Filter>Header Files\console</Filter>
</ClInclude>
<ClInclude Include="Console\LPT.h">
<Filter>Header Files\console</Filter>
</ClInclude>
<ClInclude Include="RealSound.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Segment.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Spring.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Button.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="AirCoupler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Gauge.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="DynObj.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Train.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Names.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="FadeSound.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Sound.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="AdvSound.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Model3d.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Event.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="AnimModel.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="opengl\wglew.h">
<Filter>Header Files\opengl</Filter>
</ClInclude>
<ClInclude Include="Console\MWD.h">
<Filter>Header Files\console</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="maszyna.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<Image Include="eu07.ico">
<Filter>Resource Files</Filter>
</Image>
</ItemGroup>
</Project>

View File

@@ -496,10 +496,10 @@ struct TScheme
typedef TScheme TSchemeTable[ResArraySize + 1]; /*tablica rezystorow rozr.*/ typedef TScheme TSchemeTable[ResArraySize + 1]; /*tablica rezystorow rozr.*/
struct TDEScheme struct TDEScheme
{ {
double RPM; /*obroty diesla*/ double RPM = 0.0; /*obroty diesla*/
double GenPower; /*moc maksymalna*/ double GenPower = 0.0; /*moc maksymalna*/
double Umax; /*napiecie maksymalne*/ double Umax = 0.0; /*napiecie maksymalne*/
double Imax; /*prad maksymalny*/ double Imax = 0.0; /*prad maksymalny*/
}; };
typedef TDEScheme TDESchemeTable[33]; /*tablica rezystorow rozr.*/ typedef TDEScheme TDESchemeTable[33]; /*tablica rezystorow rozr.*/
struct TShuntScheme struct TShuntScheme
@@ -569,23 +569,28 @@ struct TTransmision
enum TCouplerType { NoCoupler, Articulated, Bare, Chain, Screw, Automatic }; enum TCouplerType { NoCoupler, Articulated, Bare, Chain, Screw, Automatic };
//class TMoverParameters; // wyforwardowanie klasy coby typ byl widoczny w ponizszej strukturze
class TMoverParameters; // wyforwardowanie klasy coby typ byl widoczny w ponizszej strukturze
struct TCoupling { struct TCoupling {
/*parametry*/ /*parametry*/
double SpringKB; double SpringKC; double beta; /*stala sprezystosci zderzaka/sprzegu, %tlumiennosci */ double SpringKB = 1.0; /*stala sprezystosci zderzaka/sprzegu, %tlumiennosci */
double DmaxB; double FmaxB; double DmaxC; double FmaxC; /*tolerancja scisku/rozciagania, sila rozerwania*/ double SpringKC = 1.0;
TCouplerType CouplerType; /*typ sprzegu*/ double beta = 0.0;
double DmaxB = 0.1; /*tolerancja scisku/rozciagania, sila rozerwania*/
double FmaxB = 1000.0;
double DmaxC = 0.1;
double FmaxC = 1000.0;
TCouplerType CouplerType = NoCoupler; /*typ sprzegu*/
/*zmienne*/ /*zmienne*/
int CouplingFlag; /*0 - wirtualnie, 1 - sprzegi, 2 - pneumatycznie, 4 - sterowanie, 8 - kabel mocy*/ int CouplingFlag = 0; /*0 - wirtualnie, 1 - sprzegi, 2 - pneumatycznie, 4 - sterowanie, 8 - kabel mocy*/
int AllowedFlag; //Ra: znaczenie jak wyżej, maska dostępnych int AllowedFlag = 3; //Ra: znaczenie jak wyżej, maska dostępnych
bool Render; /*ABu: czy rysowac jak zaczepiony sprzeg*/ bool Render = false; /*ABu: czy rysowac jak zaczepiony sprzeg*/
double CoupleDist; /*ABu: optymalizacja - liczenie odleglosci raz na klatkę, bez iteracji*/ double CoupleDist = 0.0; /*ABu: optymalizacja - liczenie odleglosci raz na klatkę, bez iteracji*/
TMoverParameters* Connected; /*co jest podlaczone*/ class TMoverParameters *Connected = nullptr; /*co jest podlaczone*/
int ConnectedNr; //Ra: od której strony podłączony do (Connected): 0=przód, 1=tył int ConnectedNr = 0; //Ra: od której strony podłączony do (Connected): 0=przód, 1=tył
double CForce; /*sila z jaka dzialal*/ double CForce = 0.0; /*sila z jaka dzialal*/
double Dist; /*strzalka ugiecia zderzaków*/ double Dist = 0.0; /*strzalka ugiecia zderzaków*/
bool CheckCollision; /*czy sprawdzac sile czy pedy*/ bool CheckCollision = false; /*czy sprawdzac sile czy pedy*/
}; };
class TMoverParameters class TMoverParameters
@@ -642,10 +647,11 @@ public:
TBrakeHandle BrakeLocHandle; TBrakeHandle BrakeLocHandle;
double MBPM; /*masa najwiekszego cisnienia*/ double MBPM; /*masa najwiekszego cisnienia*/
TBrake *Hamulec; std::shared_ptr<TBrake> Hamulec;
TDriverHandle *Handle; std::shared_ptr<TDriverHandle> Handle;
TDriverHandle *LocHandle; std::shared_ptr<TDriverHandle> LocHandle;
TReservoir *Pipe; TReservoir *Pipe2; std::shared_ptr<TReservoir> Pipe;
std::shared_ptr<TReservoir> Pipe2;
TLocalBrake LocalBrake; /*rodzaj hamulca indywidualnego*/ TLocalBrake LocalBrake; /*rodzaj hamulca indywidualnego*/
TBrakePressureTable BrakePressureTable; /*wyszczegolnienie cisnien w rurze*/ TBrakePressureTable BrakePressureTable; /*wyszczegolnienie cisnien w rurze*/
@@ -1110,11 +1116,19 @@ public:
/*funkcje ladujace pliki opisujace pojazd*/ /*funkcje ladujace pliki opisujace pojazd*/
bool LoadFIZ(std::string chkpath); //Q 20160717 bool LoadChkFile(std::string chkpath); bool LoadFIZ(std::string chkpath); //Q 20160717 bool LoadChkFile(std::string chkpath);
bool readMPT(int ln, std::string line); //Q 20160717 bool LoadFIZ_Doors( std::string const &line );
bool readRLIST(int ln, std::string line); //Q 20160718 bool readMPT0( std::string const &line );
bool readBPT(int ln, std::string line); //Q 20160721 bool readMPT( std::string const &line ); //Q 20160717
void BrakeValveDecode(std::string s); //Q 20160719 bool readMPTElectricSeries( std::string const &line );
void BrakeSubsystemDecode(); //Q 20160719 bool readMPTDieselElectric( std::string const &line );
bool readMPTDieselEngine( std::string const &line );
bool readRList(int const ln, std::string const &line); //Q 20160718
bool readBPT(/*int const ln,*/ std::string const &line); //Q 20160721
bool readDList( std::string const &line );
bool readFFList( std::string const &line );
bool readWWList( std::string const &line );
void BrakeValveDecode( std::string s ); //Q 20160719
void BrakeSubsystemDecode(); //Q 20160719
void PowerParamDecode(std::string lines, std::string prefix, TPowerParameters &PowerParamDecode); //Q 20160719 void PowerParamDecode(std::string lines, std::string prefix, TPowerParameters &PowerParamDecode); //Q 20160719
TPowerSource PowerSourceDecode(std::string s); //Q 20160719 TPowerSource PowerSourceDecode(std::string s); //Q 20160719
TPowerType PowerDecode(std::string s); //Q 20160719 TPowerType PowerDecode(std::string s); //Q 20160719
@@ -1124,3 +1138,34 @@ public:
}; };
extern double Distance(TLocation Loc1, TLocation Loc2, TDimension Dim1, TDimension Dim2); extern double Distance(TLocation Loc1, TLocation Loc2, TDimension Dim1, TDimension Dim2);
template <typename _Type>
bool getkeyval( _Type &Variable, std::string const &Key, std::string const &Input, std::string const &Default ) {
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 );
}
}
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; // supplied the default
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -327,21 +327,17 @@ void TNESt3::Init(double PP, double HPP, double LPP, double BP, int BDF)
ValveRes->CreatePress(PP); ValveRes->CreatePress(PP);
BrakeCyl->CreatePress(BP); BrakeCyl->CreatePress(BP);
BrakeRes->CreatePress(PP); BrakeRes->CreatePress(PP);
CntrlRes = new TReservoir(); CntrlRes = std::make_shared<TReservoir>();
CntrlRes->CreateCap(15); CntrlRes->CreateCap(15);
CntrlRes->CreatePress(HPP); CntrlRes->CreatePress(HPP);
BrakeStatus = static_cast<int>(BP > 1.0); BrakeStatus = static_cast<int>(BP > 1.0);
Miedzypoj = new TReservoir(); Miedzypoj = std::make_shared<TReservoir>();
Miedzypoj->CreateCap(5); Miedzypoj->CreateCap(5);
Miedzypoj->CreatePress(PP); Miedzypoj->CreatePress(PP);
BVM = 1.0 / (HPP - 0.05 - LPP) * MaxBP; BVM = 1.0 / (HPP - 0.05 - LPP) * MaxBP;
BrakeDelayFlag = BDF; BrakeDelayFlag = BDF;
RapidStatus = false;
LoadC, LoadM, TareBP, TareM, Podskok, LBP = 0.0;
Zamykajacy, Przys_blok = false;
if (!(typeid(*FM) == typeid(TDisk1) || typeid(*FM) == typeid(TDisk2))) // jesli zeliwo to schodz if (!(typeid(*FM) == typeid(TDisk1) || typeid(*FM) == typeid(TDisk2))) // jesli zeliwo to schodz
RapidStaly = false; RapidStaly = false;
@@ -500,35 +496,36 @@ void TNESt3::SetSize(int size, std::string params) // ustawianie dysz (rozmiaru
if (params.find("ESt3") != std::string::npos) if (params.find("ESt3") != std::string::npos)
{ {
Podskok = 0.7; Podskok = 0.7;
Przekladniki[1] = new TRura(); Przekladniki[1] = std::make_shared<TRura>();
Przekladniki[3] = new TRura(); Przekladniki[3] = std::make_shared<TRura>();
} }
else else
{ {
Podskok = -1; Podskok = -1;
Przekladniki[1] = new TRapid(); Przekladniki[1] = std::make_shared<TRapid>();
if (params.find("-s216") != std::string::npos) if (params.find("-s216") != std::string::npos)
Przekladniki[1]->SetRapidParams(2, 16); Przekladniki[1]->SetRapidParams(2, 16);
else else
Przekladniki[1]->SetRapidParams(2, 0); Przekladniki[1]->SetRapidParams(2, 0);
Przekladniki[3] = new TPrzeciwposlizg(); Przekladniki[3] = std::make_shared<TPrzeciwposlizg>();
if (params.find("-ED") != std::string::npos) if (params.find("-ED") != std::string::npos)
{ {
delete Przekladniki[3]; // tutaj ma być destruktor
Przekladniki[1]->SetRapidParams(2, 18); Przekladniki[1]->SetRapidParams(2, 18);
Przekladniki[3] = new TPrzekED(); Przekladniki[3] = std::make_shared<TPrzekED>();
} }
} }
if (params.find("AL2") != std::string::npos) if (params.find("AL2") != std::string::npos)
Przekladniki[2] = new TPrzekCiagly(); Przekladniki[2] = std::make_shared<TPrzekCiagly>();
else if (params.find("PZZ") != std::string::npos) else if (params.find("PZZ") != std::string::npos)
Przekladniki[2] = new TPrzek_PZZ(); Przekladniki[2] = std::make_shared<TPrzek_PZZ>();
else else
Przekladniki[2] = new TRura(); Przekladniki[2] = std::make_shared<TRura>();
if ((params.find("3d") + params.find("4d")) != std::string::npos) if( ( params.find( "3d" ) != std::string::npos )
|| ( params.find( "4d" ) != std::string::npos ) ) {
autom = false; autom = false;
}
else else
autom = true; autom = true;
if ((params.find("HBG300") != std::string::npos)) if ((params.find("HBG300") != std::string::npos))

View File

@@ -17,10 +17,10 @@ http://mozilla.org/MPL/2.0/.
Copyright (C) 2007-2014 Maciej Cierniak Copyright (C) 2007-2014 Maciej Cierniak
*/ */
#include <memory>
#include "hamulce.h" // Pascal unit #include "hamulce.h" // Pascal unit
#include "friction.h" // Pascal unit #include "friction.h" // Pascal unit
#include "mctools.h" // Pascal unit #include "mctools.h" // Pascal unit
#include <string>
/* /*
(C) youBy (C) youBy
@@ -72,8 +72,8 @@ class TPrzekladnik : public TReservoir // przekladnik (powtarzacz)
{ {
private: private:
public: public:
TReservoir *BrakeRes; std::shared_ptr<TReservoir> BrakeRes;
TReservoir *Next; std::shared_ptr<TReservoir> Next;
TPrzekladnik() : TReservoir() {}; TPrzekladnik() : TReservoir() {};
virtual void Update(double dt); virtual void Update(double dt);
@@ -110,55 +110,51 @@ class TPrzeciwposlizg : public TRura // przy napelnianiu - rura, przy poslizgu -
} }
}; };
class TRapid : public TPrzekladnik // przekladnik dwustopniowy // przekladnik dwustopniowy
class TRapid : public TPrzekladnik {
{
private: private:
bool RapidStatus; // status rapidu bool RapidStatus = false; // status rapidu
double RapidMult; // przelozenie (w dol) double RapidMult = 0.0; // przelozenie (w dol)
// Komora2: real; // Komora2: real;
double DN; double DN = 0.0;
double DL; // srednice dysz napelniania i luzowania double DL = 0.0; // srednice dysz napelniania i luzowania
public: public:
void SetRapidParams(double mult, double size); void SetRapidParams(double mult, double size);
void SetRapidStatus(bool rs); void SetRapidStatus(bool rs);
void Update(double dt) /*override*/; void Update(double dt) /*override*/;
inline TRapid() : TPrzekladnik() inline TRapid() :
{ TPrzekladnik()
RapidStatus = false; {}
RapidMult, DN, DL = 0.0;
}
}; };
class TPrzekCiagly : public TPrzekladnik // AL2 // AL2
class TPrzekCiagly : public TPrzekladnik {
{
private: private:
double mult; double mult = 0.0;
public: public:
void SetMult(double m); void SetMult(double m);
void Update(double dt) /*override*/; void Update(double dt) /*override*/;
inline TPrzekCiagly() : TPrzekladnik() inline TPrzekCiagly() :
{ TPrzekladnik()
mult = 0.0; {}
}
}; };
class TPrzek_PZZ : public TPrzekladnik // podwojny zawor zwrotny // podwojny zawor zwrotny
class TPrzek_PZZ : public TPrzekladnik {
{
private: private:
double LBP; double LBP = 0.0;
public: public:
void SetLBP(double P); void SetLBP(double P);
void Update(double dt) /*override*/; void Update(double dt) /*override*/;
inline TPrzek_PZZ() : TPrzekladnik() inline TPrzek_PZZ() :
{ TPrzekladnik()
LBP = 0.0; {}
}
}; };
class TPrzekZalamany : public TPrzekladnik // Knicksventil class TPrzekZalamany : public TPrzekladnik // Knicksventil
@@ -166,59 +162,55 @@ class TPrzekZalamany : public TPrzekladnik // Knicksventil
{ {
private: private:
public: public:
TPrzekZalamany() : TPrzekladnik() {}; TPrzekZalamany() :
TPrzekladnik()
{}
}; };
class TPrzekED : public TRura // przy napelnianiu - rura, przy hamowaniu - upust // przy napelnianiu - rura, przy hamowaniu - upust
class TPrzekED : public TRura {
{
private: private:
double MaxP; double MaxP = 0.0;
public: public:
void SetP(double P); void SetP(double P);
void Update(double dt) /*override*/; void Update(double dt) /*override*/;
inline TPrzekED() : TRura() inline TPrzekED() :
{ TRura()
MaxP = 0.0; {}
}
}; };
class TNESt3 : public TBrake class TNESt3 : public TBrake {
{
private: private:
double Nozzles[dMAX]; // dysze std::shared_ptr<TReservoir> CntrlRes; // zbiornik sterujacy
TReservoir *CntrlRes; // zbiornik sterujący std::shared_ptr<TReservoir> Miedzypoj; // pojemnosc posrednia (urojona) do napelniania ZP i ZS
double BVM; // przelozenie PG-CH std::shared_ptr<TPrzekladnik> Przekladniki[ 4 ];
double Nozzles[ dMAX ]; // dysze
double BVM = 0.0; // przelozenie PG-CH
// ValveFlag: byte; //polozenie roznych zaworkow // ValveFlag: byte; //polozenie roznych zaworkow
bool Zamykajacy; // pamiec zaworka zamykajacego bool Zamykajacy = false; // pamiec zaworka zamykajacego
// Przys_wlot: boolean; //wlot do komory przyspieszacza // Przys_wlot: boolean; //wlot do komory przyspieszacza
bool Przys_blok; // blokada przyspieszacza bool Przys_blok = false; // blokada przyspieszacza
TReservoir *Miedzypoj; // pojemnosc posrednia (urojona) do napelniania ZP i ZS bool RapidStatus = false;
TPrzekladnik *Przekladniki[4]; bool RapidStaly = false;
bool RapidStatus; double LoadC = 0.0;
bool RapidStaly; double TareM = 0.0; // masa proznego
double LoadC; double LoadM = 0.0; // masa pelnego
double TareM; double TareBP = 0.0; // cisnienie dla proznego
double LoadM; // masa proznego i pelnego double HBG300 = 0.0; // zawor ograniczajacy cisnienie
double TareBP; // cisnienie dla proznego double Podskok = 0.0; // podskok preznosci poczatkowej
double HBG300; // zawor ograniczajacy cisnienie
double Podskok; // podskok preznosci poczatkowej
// HPBR: real; //zasilanie ZP z wysokiego cisnienia // HPBR: real; //zasilanie ZP z wysokiego cisnienia
bool autom; // odluzniacz samoczynny bool autom = false; // odluzniacz samoczynny
double LBP; // cisnienie hamulca pomocniczego double LBP = 0.0; // cisnienie hamulca pomocniczego
public: public:
inline TNESt3(double i_mbp, double i_bcr, double i_bcd, double i_brc, inline TNESt3(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) :
int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TBrake(i_mbp, i_bcr, i_bcd, i_brc, i_bcn TBrake( i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa)
, i_BD, i_mat, i_ba, i_nbpa) {}
{
}
void Init(double PP, double HPP, double LPP, double BP, int BDF) /*override*/; void Init(double PP, double HPP, double LPP, double BP, int BDF) /*override*/;
virtual double GetPF(double PP, double dt, virtual double GetPF(double PP, double dt, double Vel) /*override*/; // przeplyw miedzy komora wstepna i PG
double Vel) /*override*/; // przeplyw miedzy komora wstepna i PG
void EStParams(double i_crc); // parametry charakterystyczne dla ESt void EStParams(double i_crc); // parametry charakterystyczne dla ESt
virtual double GetCRP() /*override*/; virtual double GetCRP() /*override*/;
void CheckState(double BCP, double &dV1); // glowny przyrzad rozrzadczy void CheckState(double BCP, double &dV1); // glowny przyrzad rozrzadczy

View File

@@ -20,15 +20,15 @@ Copyright (C) 2007-2014 Maciej Cierniak
//---FUNKCJE OGOLNE--- //---FUNKCJE OGOLNE---
static double const DPL = 0.25; static double const DPL = 0.25;
double TFV4aM::pos_table[11] = {-2, 6, -1, 0, -2, 1, 4, 6, 0, 0, 0}; double const TFV4aM::pos_table[11] = {-2, 6, -1, 0, -2, 1, 4, 6, 0, 0, 0};
double TMHZ_EN57::pos_table[11] = {-2, 10, -1, 0, 0, 2, 9, 10, 0, 0, 0}; double const TMHZ_EN57::pos_table[11] = {-2, 10, -1, 0, 0, 2, 9, 10, 0, 0, 0};
double TM394::pos_table[11] = {-1, 5, -1, 0, 1, 2, 4, 5, 0, 0, 0}; double const TM394::pos_table[11] = {-1, 5, -1, 0, 1, 2, 4, 5, 0, 0, 0};
double TH14K1::BPT_K[6][2] = {{10, 0}, {4, 1}, {0, 1}, {4, 0}, {4, -1}, {15, -1}}; double const TH14K1::BPT_K[6][2] = {{10, 0}, {4, 1}, {0, 1}, {4, 0}, {4, -1}, {15, -1}};
double TH14K1::pos_table[11] = {-1, 4, -1, 0, 1, 2, 3, 4, 0, 0, 0}; double const TH14K1::pos_table[11] = {-1, 4, -1, 0, 1, 2, 3, 4, 0, 0, 0};
double TSt113::BPT_K[6][2] = {{10, 0}, {4, 1}, {0, 1}, {4, 0}, {4, -1}, {15, -1}}; double const TSt113::BPT_K[6][2] = {{10, 0}, {4, 1}, {0, 1}, {4, 0}, {4, -1}, {15, -1}};
double TSt113::BEP_K[7] = {0, -1, 1, 0, 0, 0, 0}; double const TSt113::BEP_K[7] = {0, -1, 1, 0, 0, 0, 0};
double TSt113::pos_table[11] = {-1, 5, -1, 0, 2, 3, 4, 5, 0, 0, 1}; double const TSt113::pos_table[11] = {-1, 5, -1, 0, 2, 3, 4, 5, 0, 0, 1};
double TFVel6::pos_table[11] = {-1, 6, -1, 0, 6, 4, 4.7, 5, -1, 0, 1}; double const TFVel6::pos_table[11] = {-1, 6, -1, 0, 6, 4, 4.7, 5, -1, 0, 1};
double PR(double P1, double P2) double PR(double P1, double P2)
{ {
@@ -96,9 +96,9 @@ double PFVa(double PH, double PL, double S, double LIM,
FM = FM * (LIM - PL) / DP; // jesli jestesmy przy nastawieniu, to zawor sie przymyka FM = FM * (LIM - PL) / DP; // jesli jestesmy przy nastawieniu, to zawor sie przymyka
if ((sg > 0.5)) // jesli ponizej stosunku krytycznego if ((sg > 0.5)) // jesli ponizej stosunku krytycznego
if ((PH - PL) < DPL) // niewielka roznica cisnien if ((PH - PL) < DPL) // niewielka roznica cisnien
return (PH - PL) / DPL * FM * 2 * sqrt((sg) * (1 - sg)); return (PH - PL) / DPL * FM * 2 * sqrt((sg) * (1 - sg)); // BUG: (1-sg) can be < 0, leading to sqrt(-x)
else else
return FM * 2 * sqrt((sg) * (1 - sg)); return FM * 2 * sqrt( (sg) * ( 1 - sg ) ); // BUG: (1-sg) can be < 0, leading to sqrt(-x)
else // powyzej stosunku krytycznego else // powyzej stosunku krytycznego
return FM; return FM;
} }
@@ -147,14 +147,6 @@ void TReservoir::Flow(double dv)
dVol = dVol + dv; dVol = dVol + dv;
} }
TReservoir::TReservoir()
{
// inherited:: Create;
Cap = 1;
Vol = 0;
dVol = 0;
}
void TReservoir::Act() void TReservoir::Act()
{ {
Vol = Vol + dVol; Vol = Vol + dVol;
@@ -201,7 +193,8 @@ double TBrakeCyl::P()
static double const cD = 1; static double const cD = 1;
static double const pD = VD - cD; static double const pD = VD - cD;
double VtoC = Vol / Cap; // stosunek cisnienia do objetosci double VtoC = ( Cap > 0.0 ) ? Vol / Cap : 0.0; // stosunek cisnienia do objetosci.
// Added div/0 trap for vehicles with incomplete definitions (cars etc)
// P:=VtoC; // P:=VtoC;
if (VtoC < VS) if (VtoC < VS)
return VtoC * pS / VS; // objetosc szkodliwa return VtoC * pS / VS; // objetosc szkodliwa
@@ -264,9 +257,9 @@ TBrake::TBrake(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn
4.2; // objetosc CH w stosunku do cylindra 14" i cisnienia 4.2 atm 4.2; // objetosc CH w stosunku do cylindra 14" i cisnienia 4.2 atm
// BrakeCyl:=TReservoir.Create; // BrakeCyl:=TReservoir.Create;
BrakeCyl = new TBrakeCyl(); BrakeCyl = std::make_shared<TBrakeCyl>();
BrakeRes = new TReservoir(); BrakeRes = std::make_shared<TReservoir>();
ValveRes = new TReservoir(); ValveRes = std::make_shared<TReservoir>();
// tworzenie zbiornikow // tworzenie zbiornikow
BrakeCyl->CreateCap(i_bcd * BCA * 1000); BrakeCyl->CreateCap(i_bcd * BCA * 1000);
@@ -279,34 +272,34 @@ TBrake::TBrake(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn
switch (i_mat) switch (i_mat)
{ {
case bp_P10Bg: case bp_P10Bg:
FM = new TP10Bg(); FM = std::make_shared<TP10Bg>();
break; break;
case bp_P10Bgu: case bp_P10Bgu:
FM = new TP10Bgu(); FM = std::make_shared<TP10Bgu>();
break; break;
case bp_FR513: case bp_FR513:
FM = new TFR513(); FM = std::make_shared<TFR513>();
break; break;
case bp_FR510: case bp_FR510:
FM = new TFR510(); FM = std::make_shared<TFR510>();
break; break;
case bp_Cosid: case bp_Cosid:
FM = new TCosid(); FM = std::make_shared<TCosid>();
break; break;
case bp_P10yBg: case bp_P10yBg:
FM = new TP10yBg(); FM = std::make_shared<TP10yBg>();
break; break;
case bp_P10yBgu: case bp_P10yBgu:
FM = new TP10yBgu(); FM = std::make_shared<TP10yBgu>();
break; break;
case bp_D1: case bp_D1:
FM = new TDisk1(); FM = std::make_shared<TDisk1>();
break; break;
case bp_D2: case bp_D2:
FM = new TDisk2(); FM = std::make_shared<TDisk2>();
break; break;
default: // domyslnie default: // domyslnie
FM = new TP10(); FM = std::make_shared<TP10>();
} }
} }
@@ -1842,7 +1835,7 @@ void TKE::CheckReleaser(double dt)
CVP = CntrlRes->P(); CVP = CntrlRes->P();
// odluzniacz // odluzniacz
if ((BrakeStatus && b_rls) == b_rls) if ( true == ((BrakeStatus & b_rls) == b_rls))
if ((CVP - VVP < 0)) if ((CVP - VVP < 0))
BrakeStatus &= 247; BrakeStatus &= 247;
else else
@@ -2203,10 +2196,7 @@ double TFV4a::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
void TFV4a::Init(double Press) void TFV4a::Init(double Press)
{ {
CP = Press; CP = Press;
TP = 0;
RP = Press; RP = Press;
Time = false;
TimeEP = false;
} }
//---FV4a/M--- nowonapisany kran bez poprawki IC //---FV4a/M--- nowonapisany kran bez poprawki IC
@@ -2342,13 +2332,7 @@ double TFV4aM::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
void TFV4aM::Init(double Press) void TFV4aM::Init(double Press)
{ {
CP = Press; CP = Press;
TP = 0.0;
RP = Press; RP = Press;
XP = 0.0;
Time = false;
TimeEP = false;
RedAdj = 0.0;
Fala = false;
} }
void TFV4aM::SetReductor(double nAdj) void TFV4aM::SetReductor(double nAdj)
@@ -2483,12 +2467,6 @@ double TMHZ_EN57::GetPF(double i_bcp, double PP, double HP, double dt, double ep
void TMHZ_EN57::Init(double Press) void TMHZ_EN57::Init(double Press)
{ {
CP = Press; CP = Press;
TP = 0.0;
RP = 0.0;
Time = false;
TimeEP = false;
RedAdj = 0.0;
Fala = false;
} }
void TMHZ_EN57::SetReductor(double nAdj) void TMHZ_EN57::SetReductor(double nAdj)
@@ -2591,9 +2569,7 @@ double TM394::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
void TM394::Init(double Press) void TM394::Init(double Press)
{ {
CP = Press; CP = Press;
RedAdj = 0;
Time = true; Time = true;
TimeEP = false;
} }
void TM394::SetReductor(double nAdj) void TM394::SetReductor(double nAdj)
@@ -2615,32 +2591,23 @@ double TM394::GetPos(int i)
double TH14K1::GetPF(double i_bcp, double PP, double HP, double dt, double ep) double TH14K1::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
{ {
static int const LBDelay = 100; // szybkosc + zasilanie sterujacego int const LBDelay = 100; // szybkosc + zasilanie sterujacego
// static double const BPT_K[/*?*/ /*-1..4*/ (4) - (-1) + 1][2] = // static double const BPT_K[/*?*/ /*-1..4*/ (4) - (-1) + 1][2] =
//{ (10, 0), (4, 1), (0, 1), (4, 0), (4, -1), (15, -1) }; //{ (10, 0), (4, 1), (0, 1), (4, 0), (4, -1), (15, -1) };
static double const NomPress = 5.0; double const NomPress = 5.0;
double LimPP; int BCP = std::lround(i_bcp);
double dpPipe; if( i_bcp < -1 ) { BCP = 1; }
double dpMainValve;
double ActFlowSpeed;
int BCP;
BCP = lround(i_bcp); double LimPP = BPT_K[BCP + 1][1];
if (i_bcp < -1) if( LimPP < 0.0 ) { LimPP = 0.5 * PP; }
BCP = 1; else if( LimPP > 0.0 ) { LimPP = PP; }
LimPP = BPT_K[BCP + 1][1]; else { LimPP = CP; }
if (LimPP < 0) double ActFlowSpeed = BPT_K[BCP + 1][0];
LimPP = 0.5 * PP;
else if (LimPP > 0)
LimPP = PP;
else
LimPP = CP;
ActFlowSpeed = BPT_K[BCP + 1][0];
CP = CP + 6 * Min0R(abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy CP = CP + 6 * std::min( std::abs(LimPP - CP), 0.05 ) * PR(CP, LimPP) * dt; // zbiornik sterujacy
dpMainValve = 0; double dpMainValve = 0.0;
if (BCP == -1) if (BCP == -1)
dpMainValve = PF(HP, PP, ActFlowSpeed / LBDelay) * dt; dpMainValve = PF(HP, PP, ActFlowSpeed / LBDelay) * dt;
@@ -2657,7 +2624,6 @@ double TH14K1::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
void TH14K1::Init(double Press) void TH14K1::Init(double Press)
{ {
CP = Press; CP = Press;
RedAdj = 0;
Time = true; Time = true;
TimeEP = true; TimeEP = true;
} }
@@ -2738,7 +2704,6 @@ void TSt113::Init(double Press)
{ {
Time = true; Time = true;
TimeEP = true; TimeEP = true;
EPS = 0.0;
} }
//--- test --- //--- test ---
@@ -2799,11 +2764,8 @@ double TFD1::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
void TFD1::Init(double Press) void TFD1::Init(double Press)
{ {
BP = 0;
MaxBP = Press; MaxBP = Press;
Time = false; Speed = 1.0;
TimeEP = false;
Speed = 1;
} }
double TFD1::GetCP() double TFD1::GetCP()
@@ -2844,10 +2806,8 @@ double TH1405::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
void TH1405::Init(double Press) void TH1405::Init(double Press)
{ {
BP = 0;
MaxBP = Press; MaxBP = Press;
Time = true; Time = true;
TimeEP = false;
} }
double TH1405::GetCP() double TH1405::GetCP()
@@ -2919,7 +2879,6 @@ void TFVel6::Init(double Press)
{ {
Time = true; Time = true;
TimeEP = true; TimeEP = true;
EPS = 0.0;
} }
// END // END

File diff suppressed because it is too large Load Diff

View File

@@ -279,7 +279,7 @@ std::string Tab2Sp(std::string const &s) /*Tab to Space sign*/
{ {
std::string s2 = ""; std::string s2 = "";
char tmp = (char)9; char tmp = (char)9;
for (int b = 0; b < s.length(); ++b) for (std::size_t b = 0; b < s.length(); ++b)
//{ //{
// if (s[b] == tmp[0]) // if (s[b] == tmp[0])
// s[b] = tmp[1]; // s[b] = tmp[1];
@@ -294,20 +294,32 @@ std::string Tab2Sp(std::string const &s) /*Tab to Space sign*/
return s2; return s2;
} }
std::string ExchangeCharInString(std::string s, const char &aim, const char &target) std::string ExchangeCharInString( std::string const &Source, char const &From, char const &To )
{ {
char *tmp = new char[s.length()]; std::string replacement; replacement.reserve( Source.size() );
for (int b = 0; b < s.length(); ++b) std::for_each(Source.cbegin(), Source.cend(), [&](char const idx) {
{ if( idx != From ) { replacement += idx; }
if (s[b] == aim) else {
if (target == (char)"") if( To != NULL ) { replacement += To; } }
b++; } );
else
tmp[b] = target; return replacement;
else /*
tmp[b] = s[b]; int const length = Source.size();
std::string replacement; replacement.reserve( length );
for( int idx = 0; idx < length; ++idx ) {
if( Source[ idx ] != From ) {
replacement += Source[ idx ];
}
else {
if( To != NULL ) {
replacement += To;
}
}
} }
return std::string(tmp);
return replacement;
*/
} }
std::vector<std::string> &Split(const std::string &s, char delim, std::vector<std::string> &elems) std::vector<std::string> &Split(const std::string &s, char delim, std::vector<std::string> &elems)
@@ -387,29 +399,25 @@ std::string to_string(int _Val, int precision, int width)
return o.str(); return o.str();
}; };
std::string to_string(double _Val, int precision, int width) std::string to_string(double const Value, int const Precision, int const Width)
{ {
std::ostringstream o; std::ostringstream converter;
o.width(width); converter << std::setw( Width ) << std::fixed << std::setprecision(Precision) << Value;
o << std::fixed << std::setprecision(precision); return converter.str();
o << _Val;
return o.str();
}; };
std::string to_hex_str(double _Val, int precision, int width) std::string to_hex_str( int const Value, int const Width )
{ {
std::ostringstream o; std::ostringstream converter;
if (width) converter << "0x" << std::uppercase << std::setfill( '0' ) << std::setw( Width ) << std::hex << Value;
o.width(width); return converter.str();
o << std::fixed << std::hex;
if (precision)
o << std::setprecision(precision);
o << _Val;
return o.str();
}; };
int stol_def(const std::string &str, const int &DefaultValue) int stol_def(const std::string &str, const int &DefaultValue)
{ {
// NOTE: there's good chance this function is bugged, it produced wrong result on at least one occasion
// TODO: rewrite into something more reliable
// this function was developed iteratively on Codereview.stackexchange // this function was developed iteratively on Codereview.stackexchange
// with the assistance of @Corbin // with the assistance of @Corbin
std::size_t len = str.size(); std::size_t len = str.size();

View File

@@ -122,7 +122,7 @@ std::string DUE(std::string s); /*Delete Until Equal sign*/
std::string DWE(std::string s); /*Delete While Equal sign*/ std::string DWE(std::string s); /*Delete While Equal sign*/
std::string Ld2Sp(std::string const &s); /*Low dash to Space sign*/ std::string Ld2Sp(std::string const &s); /*Low dash to Space sign*/
std::string Tab2Sp(std::string const &s); /*Tab to Space sign*/ std::string Tab2Sp(std::string const &s); /*Tab to Space sign*/
std::string ExchangeCharInString(std::string s, const char &aim, const char &target); // zamienia jeden znak na drugi std::string ExchangeCharInString(std::string const &s, const char &aim, const char &target); // zamienia jeden znak na drugi
std::vector<std::string> &Split(const std::string &s, char delim, std::vector<std::string> &elems); std::vector<std::string> &Split(const std::string &s, char delim, std::vector<std::string> &elems);
std::vector<std::string> Split(const std::string &s, char delim); std::vector<std::string> Split(const std::string &s, char delim);
std::vector<std::string> Split(const std::string &s); std::vector<std::string> Split(const std::string &s);
@@ -134,7 +134,7 @@ std::string to_string(int _Val, int precision, int width);
std::string to_string(double _Val); std::string to_string(double _Val);
std::string to_string(double _Val, int precision); std::string to_string(double _Val, int precision);
std::string to_string(double _Val, int precision, int width); std::string to_string(double _Val, int precision, int width);
std::string to_hex_str(double _Val, int precision = 0, int width = 0); std::string to_hex_str( int const _Val, int const width = 4 );
inline std::string to_string(bool _Val) inline std::string to_string(bool _Val)
{ {
return _Val == true ? "true" : "false"; return _Val == true ? "true" : "false";

View File

@@ -1844,7 +1844,11 @@ bool TModel3d::LoadFromFile(std::string const &FileName, bool dynamic) {
Init(); // generowanie siatek i zapis E3D Init(); // generowanie siatek i zapis E3D
} }
} }
return Root ? (iSubModelsCount > 0) : false; // brak pliku albo problem z wczytaniem bool const result = Root ? (iSubModelsCount > 0) : false; // brak pliku albo problem z wczytaniem
if( false == result ) {
ErrorLog( "Failed to load 3d model \"" + FileName + "\"" );
}
return result;
}; };
void TModel3d::LoadFromBinFile(std::string const &FileName, bool dynamic) void TModel3d::LoadFromBinFile(std::string const &FileName, bool dynamic)

View File

@@ -108,6 +108,11 @@ TNames::TNames()
ZeroMemory(rTypes, 20 * sizeof(ItemRecord *)); ZeroMemory(rTypes, 20 * sizeof(ItemRecord *));
}; };
TNames::~TNames() {
delete[] cBuffer;
}
int TNames::Add(int t, const char *n) int TNames::Add(int t, const char *n)
{ // dodanie obiektu typu (t) o nazwie (n) { // dodanie obiektu typu (t) o nazwie (n)
int len = strlen(n) + 1; // ze znacznikiem końca int len = strlen(n) + 1; // ze znacznikiem końca

View File

@@ -49,6 +49,7 @@ class TNames
int iLast; // ostatnio użyty rekord int iLast; // ostatnio użyty rekord
public: public:
TNames(); TNames();
~TNames();
int Add(int t, const char *n); // dodanie obiektu typu (t) int Add(int t, const char *n); // dodanie obiektu typu (t)
int Add(int t, const char *n, void *d); // dodanie obiektu z wskaźnikiem int Add(int t, const char *n, void *d); // dodanie obiektu z wskaźnikiem
int Add(int t, const char *n, int d); // dodanie obiektu z numerem int Add(int t, const char *n, int d); // dodanie obiektu z numerem

View File

@@ -45,13 +45,19 @@ TPythonInterpreter *TPythonInterpreter::getInstance()
return _instance; return _instance;
} }
bool TPythonInterpreter::loadClassFile(const char *lookupPath, const char *className) void
TPythonInterpreter::killInstance() {
delete _instance;
}
bool TPythonInterpreter::loadClassFile( std::string const &lookupPath, std::string const &className )
{ {
std::set<const char *, ltstr>::const_iterator it = _classes.find(className); std::set<std::string const>::const_iterator it = _classes.find(className);
if (it == _classes.end()) if (it == _classes.end())
{ {
FILE *sourceFile = _getFile(lookupPath, className); FILE *sourceFile = _getFile(lookupPath, className);
if (sourceFile != NULL) if (sourceFile != nullptr)
{ {
fseek(sourceFile, 0, SEEK_END); fseek(sourceFile, 0, SEEK_END);
long fsize = ftell(sourceFile); long fsize = ftell(sourceFile);
@@ -72,10 +78,13 @@ bool TPythonInterpreter::loadClassFile(const char *lookupPath, const char *class
handleError(); handleError();
return false; return false;
} }
_classes.insert( className );
/*
char *classNameToRemember = (char *)calloc(strlen(className) + 1, sizeof(char)); char *classNameToRemember = (char *)calloc(strlen(className) + 1, sizeof(char));
strcpy(classNameToRemember, className); strcpy(classNameToRemember, className);
_classes.insert(classNameToRemember); _classes.insert(classNameToRemember);
free(buffer); */
free(buffer);
return true; return true;
} }
return false; return false;
@@ -83,13 +92,28 @@ bool TPythonInterpreter::loadClassFile(const char *lookupPath, const char *class
return true; return true;
} }
PyObject *TPythonInterpreter::newClass(const char *className) PyObject *TPythonInterpreter::newClass( std::string const &className )
{ {
return newClass(className, NULL); return newClass(className, NULL);
} }
FILE *TPythonInterpreter::_getFile(const char *lookupPath, const char *className) FILE *TPythonInterpreter::_getFile( std::string const &lookupPath, std::string const &className )
{ {
if( false == lookupPath.empty() ) {
std::string const sourcefilepath = lookupPath + className + ".py";
FILE *file = fopen( sourcefilepath.c_str(), "r" );
#ifdef _PY_INT_MORE_LOG
WriteLog( sourceFilePath );
#endif // _PY_INT_MORE_LOG
if( nullptr != file ) { return file; }
}
std::string sourcefilepath = "python\\local\\" + className + ".py";
FILE *file = fopen( sourcefilepath.c_str(), "r" );
#ifdef _PY_INT_MORE_LOG
WriteLog( sourceFilePath );
#endif // _PY_INT_MORE_LOG
return file; // either the file, or a nullptr on fail
/*
char *sourceFilePath; char *sourceFilePath;
if (lookupPath != NULL) if (lookupPath != NULL)
{ {
@@ -124,6 +148,7 @@ FILE *TPythonInterpreter::_getFile(const char *lookupPath, const char *className
return file; return file;
} }
return NULL; return NULL;
*/
} }
void TPythonInterpreter::handleError() void TPythonInterpreter::handleError()
@@ -177,14 +202,14 @@ void TPythonInterpreter::handleError()
} }
} }
} }
PyObject *TPythonInterpreter::newClass(const char *className, PyObject *argsTuple) PyObject *TPythonInterpreter::newClass(std::string const &className, PyObject *argsTuple)
{ {
if (_main == NULL) if (_main == NULL)
{ {
WriteLog("main turned into null"); WriteLog("main turned into null");
return NULL; return NULL;
} }
PyObject *classNameObj = PyObject_GetAttrString(_main, className); PyObject *classNameObj = PyObject_GetAttrString(_main, className.c_str());
if (classNameObj == NULL) if (classNameObj == NULL)
{ {
#ifdef _PY_INT_MORE_LOG #ifdef _PY_INT_MORE_LOG
@@ -477,18 +502,12 @@ void TPythonScreens::update()
void TPythonScreens::setLookupPath(std::string const &path) void TPythonScreens::setLookupPath(std::string const &path)
{ {
if (_lookupPath != NULL) _lookupPath = path;
{
free(_lookupPath);
}
_lookupPath = (char *)calloc(path.length() + 1, sizeof(char));
strcpy(_lookupPath, path.c_str());
} }
TPythonScreens::TPythonScreens() TPythonScreens::TPythonScreens()
{ {
_lookupPath = NULL; TPythonInterpreter::getInstance()->loadClassFile("", "abstractscreenrenderer");
TPythonInterpreter::getInstance()->loadClassFile(NULL, "abstractscreenrenderer");
_terminationFlag = false; _terminationFlag = false;
_renderReadyFlag = false; _renderReadyFlag = false;
_cleanupReadyFlag = false; _cleanupReadyFlag = false;
@@ -501,6 +520,7 @@ TPythonScreens::~TPythonScreens()
WriteLog("Called python sceeens destructor"); WriteLog("Called python sceeens destructor");
#endif // _PY_INT_MORE_LOG #endif // _PY_INT_MORE_LOG
reset(NULL); reset(NULL);
/*
if (_lookupPath != NULL) if (_lookupPath != NULL)
{ {
#ifdef _PY_INT_MORE_LOG #ifdef _PY_INT_MORE_LOG
@@ -508,6 +528,7 @@ TPythonScreens::~TPythonScreens()
#endif // _PY_INT_MORE_LOG #endif // _PY_INT_MORE_LOG
free(_lookupPath); free(_lookupPath);
} }
*/
} }
void TPythonScreens::run() void TPythonScreens::run()
@@ -551,7 +572,7 @@ void TPythonScreens::run()
void TPythonScreens::finish() void TPythonScreens::finish()
{ {
_thread == NULL; _thread = NULL;
} }
DWORD WINAPI ScreenRendererThread(LPVOID lpParam) DWORD WINAPI ScreenRendererThread(LPVOID lpParam)

22
PyInt.h
View File

@@ -30,22 +30,26 @@ class TPythonInterpreter
{ {
protected: protected:
TPythonInterpreter(); TPythonInterpreter();
~TPythonInterpreter() ~TPythonInterpreter() {}
{
}
static TPythonInterpreter *_instance; static TPythonInterpreter *_instance;
int _screenRendererPriority; int _screenRendererPriority;
std::set<const char *, ltstr> _classes; // std::set<const char *, ltstr> _classes;
PyObject *_main; std::set<std::string const> _classes;
PyObject *_main;
PyObject *_stdErr; PyObject *_stdErr;
FILE *_getFile(const char *lookupPath, const char *className); // FILE *_getFile(const char *lookupPath, const char *className);
FILE *_getFile( std::string const &lookupPath, std::string const &className );
public: public:
static TPythonInterpreter *getInstance(); static TPythonInterpreter *getInstance();
bool loadClassFile(const char *lookupPath, const char *className); static void killInstance();
/* bool loadClassFile(const char *lookupPath, const char *className);
PyObject *newClass(const char *className); PyObject *newClass(const char *className);
PyObject *newClass(const char *className, PyObject *argsTuple); PyObject *newClass(const char *className, PyObject *argsTuple);
int getScreenRendererPriotity() */ bool loadClassFile( std::string const &lookupPath, std::string const &className );
PyObject *newClass( std::string const &className );
PyObject *newClass( std::string const &className, PyObject *argsTuple );
int getScreenRendererPriotity()
{ {
return _screenRendererPriority; return _screenRendererPriority;
}; };
@@ -79,7 +83,7 @@ class TPythonScreens
void *_thread; void *_thread;
unsigned int _threadId; unsigned int _threadId;
std::vector<TPythonScreenRenderer *> _screens; std::vector<TPythonScreenRenderer *> _screens;
char *_lookupPath; std::string _lookupPath;
void *_train; void *_train;
void _cleanup(); void _cleanup();
void _freeTrainState(); void _freeTrainState();

View File

@@ -37,7 +37,7 @@ TRealSound::TRealSound()
bLoopPlay = false; // dźwięk wyłączony bLoopPlay = false; // dźwięk wyłączony
} }
TRealSound::TRealSound(const char *SoundName, double SoundAttenuation, double X, double Y, double Z, bool Dynamic, TRealSound::TRealSound(std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z, bool Dynamic,
bool freqmod, double rmin) bool freqmod, double rmin)
{ {
Init(SoundName, SoundAttenuation, X, Y, Z, Dynamic, freqmod, rmin); Init(SoundName, SoundAttenuation, X, Y, Z, Dynamic, freqmod, rmin);
@@ -250,7 +250,7 @@ void TRealSound::ResetPosition()
pSound->SetCurrentPosition(0); pSound->SetCurrentPosition(0);
} }
TTextSound::TTextSound(const char *SoundName, double SoundAttenuation, double X, double Y, double Z, TTextSound::TTextSound(std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z,
bool Dynamic, bool freqmod, double rmin) bool Dynamic, bool freqmod, double rmin)
: TRealSound(SoundName, SoundAttenuation, X, Y, Z, Dynamic, freqmod, rmin) : TRealSound(SoundName, SoundAttenuation, X, Y, Z, Dynamic, freqmod, rmin)
{ {

View File

@@ -18,7 +18,7 @@ class TRealSound
{ {
protected: protected:
PSound pSound; PSound pSound;
char *Nazwa; // dla celow odwszawiania // char *Nazwa; // dla celow odwszawiania NOTE: currently not used anywhere
double fDistance, fPreviousDistance; // dla liczenia Dopplera double fDistance, fPreviousDistance; // dla liczenia Dopplera
float fFrequency; // częstotliwość samplowania pliku float fFrequency; // częstotliwość samplowania pliku
int iDoppler; // Ra 2014-07: możliwość wyłączenia efektu Dopplera np. dla śpiewu ptaków int iDoppler; // Ra 2014-07: możliwość wyłączenia efektu Dopplera np. dla śpiewu ptaków
@@ -31,7 +31,7 @@ class TRealSound
double FA; // offset czestotliwosci double FA; // offset czestotliwosci
bool bLoopPlay; // czy zapętlony dźwięk jest odtwarzany bool bLoopPlay; // czy zapętlony dźwięk jest odtwarzany
TRealSound(); TRealSound();
TRealSound(const char *SoundName, double SoundAttenuation, double X, double Y, double Z, bool Dynamic, TRealSound( std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z, bool Dynamic,
bool freqmod = false, double rmin = 0.0); bool freqmod = false, double rmin = 0.0);
~TRealSound(); ~TRealSound();
void Free(); void Free();
@@ -54,7 +54,7 @@ class TTextSound : public TRealSound
std::string asText; std::string asText;
float fTime; // czas trwania float fTime; // czas trwania
public: public:
TTextSound(const char *SoundName, double SoundAttenuation, double X, double Y, double Z, TTextSound(std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z,
bool Dynamic, bool freqmod = false, double rmin = 0.0); bool Dynamic, bool freqmod = false, double rmin = 0.0);
void Init(std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z, void Init(std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z,
bool Dynamic, bool freqmod = false, double rmin = 0.0); bool Dynamic, bool freqmod = false, double rmin = 0.0);

View File

@@ -14,6 +14,7 @@ http://mozilla.org/MPL/2.0/.
#include "Logs.h" #include "Logs.h"
#include "Usefull.h" #include "Usefull.h"
#include "mczapkie/mctools.h" #include "mczapkie/mctools.h"
#include "WavRead.h"
//#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } } //#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
#define SAFE_RELEASE(p) \ #define SAFE_RELEASE(p) \
{ \ { \

View File

@@ -11,14 +11,7 @@ http://mozilla.org/MPL/2.0/.
#define SoundH #define SoundH
#include <stack> #include <stack>
#undef EOF
#include <objbase.h>
//#include <initguid.h>
//#include <commdlg.h>
#include <mmreg.h>
#include <dsound.h> #include <dsound.h>
//#include "resource.h"
#include "WavRead.h"
typedef LPDIRECTSOUNDBUFFER PSound; typedef LPDIRECTSOUNDBUFFER PSound;

View File

@@ -59,30 +59,26 @@ TSwitchExtension::TSwitchExtension(TTrack *owner, int what)
pOwner = NULL; pOwner = NULL;
pNextAnim = NULL; pNextAnim = NULL;
bMovement = false; // nie potrzeba przeliczać fOffset1 bMovement = false; // nie potrzeba przeliczać fOffset1
Segments[0] = new TSegment(owner); // z punktu 1 do 2 Segments[0] = std::make_shared<TSegment>(owner); // z punktu 1 do 2
Segments[1] = new TSegment( Segments[1] = std::make_shared<TSegment>(owner); // z punktu 3 do 4 (1=3 dla zwrotnic; odwrócony dla skrzyżowań, ewentualnie 1=4)
owner); // z punktu 3 do 4 (1=3 dla zwrotnic; odwrócony dla skrzyżowań, ewentualnie 1=4)
Segments[2] = (what >= 3) ? Segments[2] = (what >= 3) ?
new TSegment(owner) : std::make_shared<TSegment>(owner) :
NULL; // z punktu 2 do 4 skrzyżowanie od góry: wersja "-1": nullptr; // z punktu 2 do 4 skrzyżowanie od góry: wersja "-1":
Segments[3] = Segments[3] = (what >= 4) ?
(what >= 4) ? new TSegment(owner) : NULL; // z punktu 4 do 1 1 1=4 0 0=3 std::make_shared<TSegment>(owner) :
Segments[4] = nullptr; // z punktu 4 do 1 1 1=4 0 0=3
(what >= 5) ? new TSegment(owner) : NULL; // z punktu 1 do 3 4 x 3 3 3 x 2 2 Segments[4] = (what >= 5) ?
Segments[5] = (what >= 6) ? new TSegment(owner) : std::make_shared<TSegment>(owner) :
NULL; // z punktu 3 do 2 2 2 1 1 nullptr; // z punktu 1 do 3 4 x 3 3 3 x 2 2
Segments[5] = (what >= 6) ?
std::make_shared<TSegment>(owner) :
nullptr; // z punktu 3 do 2 2 2 1 1
evPlus = evMinus = NULL; evPlus = evMinus = NULL;
fVelocity = -1.0; // maksymalne ograniczenie prędkości (ustawianej eventem) fVelocity = -1.0; // maksymalne ograniczenie prędkości (ustawianej eventem)
vTrans = vector3(0, 0, 0); // docelowa translacja przesuwnicy vTrans = vector3(0, 0, 0); // docelowa translacja przesuwnicy
} }
TSwitchExtension::~TSwitchExtension() TSwitchExtension::~TSwitchExtension()
{ // nie ma nic do usuwania { // nie ma nic do usuwania
// delete Segments[0];
// delete Segments[1];
delete Segments[2];
delete Segments[3];
delete Segments[4];
delete Segments[5];
} }
TIsolated::TIsolated() TIsolated::TIsolated()
@@ -121,7 +117,7 @@ TIsolated * TIsolated::Find(const string &n)
return p; return p;
p = p->pNext; p = p->pNext;
} }
pRoot = new TIsolated(n, pRoot); pRoot = new TIsolated(n, pRoot); // BUG: source of a memory leak
return pRoot; return pRoot;
}; };
@@ -211,7 +207,11 @@ TTrack::TTrack(TGroundNode *g)
TTrack::~TTrack() TTrack::~TTrack()
{ // likwidacja odcinka { // likwidacja odcinka
if (eType == tt_Normal) if( eType == tt_Cross ) {
delete SwitchExtension->vPoints; // skrzyżowanie może mieć punkty
}
/* if (eType == tt_Normal)
delete Segment; // dla zwrotnic nie usuwać tego (kopiowany) delete Segment; // dla zwrotnic nie usuwać tego (kopiowany)
else else
{ // usuwanie dodatkowych danych dla niezwykłych odcinków { // usuwanie dodatkowych danych dla niezwykłych odcinków
@@ -219,6 +219,7 @@ TTrack::~TTrack()
delete SwitchExtension->vPoints; // skrzyżowanie może mieć punkty delete SwitchExtension->vPoints; // skrzyżowanie może mieć punkty
SafeDelete(SwitchExtension); SafeDelete(SwitchExtension);
} }
*/
} }
void TTrack::Init() void TTrack::Init()
@@ -226,21 +227,21 @@ void TTrack::Init()
switch (eType) switch (eType)
{ {
case tt_Switch: case tt_Switch:
SwitchExtension = new TSwitchExtension(this, 2); // na wprost i na bok SwitchExtension = std::make_shared<TSwitchExtension>( this, 2 ); // na wprost i na bok
break; break;
case tt_Cross: // tylko dla skrzyżowania dróg case tt_Cross: // tylko dla skrzyżowania dróg
SwitchExtension = new TSwitchExtension(this, 6); // 6 połączeń SwitchExtension = std::make_shared<TSwitchExtension>( this, 6 ); // 6 po³¹czeñ
SwitchExtension->vPoints = NULL; // brak tablicy punktów SwitchExtension->vPoints = NULL; // brak tablicy punktów
SwitchExtension->iPoints = 0; SwitchExtension->iPoints = 0;
SwitchExtension->bPoints = false; // tablica punktów nie wypełniona SwitchExtension->bPoints = false; // tablica punktów nie wypełniona
SwitchExtension->iRoads = 4; // domyślnie 4 SwitchExtension->iRoads = 4; // domyślnie 4
break; break;
case tt_Normal: case tt_Normal:
Segment = new TSegment(this); Segment = std::make_shared<TSegment>( this );
break; break;
case tt_Table: // oba potrzebne case tt_Table: // oba potrzebne
SwitchExtension = new TSwitchExtension(this, 1); // kopia oryginalnego toru SwitchExtension = std::make_shared<TSwitchExtension>( this, 1 ); // kopia oryginalnego toru
Segment = new TSegment(this); Segment = make_shared<TSegment>(this);
break; break;
} }
} }

20
Track.h
View File

@@ -48,13 +48,13 @@ class TSwitchExtension
public: public:
TSwitchExtension(TTrack *owner, int what); TSwitchExtension(TTrack *owner, int what);
~TSwitchExtension(); ~TSwitchExtension();
TSegment *Segments[6]; // dwa tory od punktu 1, pozostałe dwa od 2? Ra 140101: 6 połączeń dla std::shared_ptr<TSegment> Segments[6]; // dwa tory od punktu 1, pozosta³e dwa od 2? Ra 140101: 6 po³¹czeñ dla
// skrzyżowań // skrzy¿owañ
// TTrack *trNear[4]; //tory dołączone do punktów 1, 2, 3 i 4 // TTrack *trNear[4]; //tory do³¹czone do punktów 1, 2, 3 i 4
// dotychczasowe [2]+[2] wskaźniki zamienić na nowe [4] // dotychczasowe [2]+[2] wskaŸniki zamieniæ na nowe [4]
TTrack *pNexts[2]; // tory dołączone do punktów 2 i 4 TTrack *pNexts[2]; // tory do³¹czone do punktów 2 i 4
TTrack *pPrevs[2]; // tory dołączone do punktów 1 i 3 TTrack *pPrevs[2]; // tory do³¹czone do punktów 1 i 3
int iNextDirection[2]; // to też z [2]+[2] przerobić na [4] int iNextDirection[2]; // to te¿ z [2]+[2] przerobiæ na [4]
int iPrevDirection[2]; int iPrevDirection[2];
int CurrentIndex; // dla zwrotnicy int CurrentIndex; // dla zwrotnicy
double fOffset, fDesiredOffset; // aktualne i docelowe położenie napędu iglic double fOffset, fDesiredOffset; // aktualne i docelowe położenie napędu iglic
@@ -126,8 +126,8 @@ class TIsolated
class TTrack : public Resource class TTrack : public Resource
{ // trajektoria ruchu - opakowanie { // trajektoria ruchu - opakowanie
private: private:
TSwitchExtension *SwitchExtension; // dodatkowe dane do toru, który jest zwrotnicą std::shared_ptr<TSwitchExtension> SwitchExtension; // dodatkowe dane do toru, który jest zwrotnicą
TSegment *Segment; std::shared_ptr<TSegment> Segment;
TTrack *trNext; // odcinek od strony punktu 2 - to powinno być w segmencie TTrack *trNext; // odcinek od strony punktu 2 - to powinno być w segmencie
TTrack *trPrev; // odcinek od strony punktu 1 TTrack *trPrev; // odcinek od strony punktu 1
// McZapkie-070402: dodalem zmienne opisujace rozmiary tekstur // McZapkie-070402: dodalem zmienne opisujace rozmiary tekstur
@@ -204,7 +204,7 @@ class TTrack : public Resource
{ {
return Segment->GetLength(); return Segment->GetLength();
}; };
inline TSegment * CurrentSegment() inline std::shared_ptr<TSegment> CurrentSegment()
{ {
return Segment; return Segment;
}; };

View File

@@ -11,18 +11,19 @@ http://mozilla.org/MPL/2.0/.
Copyright (C) 2001-2004 Marcin Wozniak, Maciej Czapkiewicz and others Copyright (C) 2001-2004 Marcin Wozniak, Maciej Czapkiewicz and others
*/ */
#include "stdafx.h" #include "stdafx.h"
#include "Train.h" #include "Train.h"
#include "Console.h"
#include "Driver.h"
#include "Globals.h" #include "Globals.h"
#include "Logs.h" #include "Logs.h"
#include "McZapkie\MOVER.h"
#include "McZapkie\hamulce.h"
#include "MdlMngr.h" #include "MdlMngr.h"
#include "Timer.h" #include "Timer.h"
#include "Driver.h"
#include "Console.h"
#include "McZapkie\hamulce.h"
#include "McZapkie\MOVER.h"
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
using namespace Timer; using namespace Timer;
@@ -68,15 +69,27 @@ void TCab::Load(cParser &Parser)
Parser >> token; Parser >> token;
if (token == "cablight") if (token == "cablight")
{ {
Parser.getTokens(9, false); Parser.getTokens( 9, false );
Parser >> dimm_r >> dimm_g >> dimm_b >> intlit_r >> intlit_g >> intlit_b >> intlitlow_r >> Parser
intlitlow_g >> intlitlow_b; >> dimm_r
Parser.getTokens(); >> dimm_g
Parser >> token; >> dimm_b
>> intlit_r
>> intlit_g
>> intlit_b
>> intlitlow_r
>> intlitlow_g
>> intlitlow_b;
Parser.getTokens(); Parser >> token;
} }
CabPos1.x = std::stod(token); CabPos1.x = std::stod( token );
Parser.getTokens(5, false); Parser.getTokens( 5, false );
Parser >> CabPos1.y >> CabPos1.z >> CabPos2.x >> CabPos2.y >> CabPos2.z; Parser
>> CabPos1.y
>> CabPos1.z
>> CabPos2.x
>> CabPos2.y
>> CabPos2.z;
bEnabled = true; bEnabled = true;
bOccupied = true; bOccupied = true;
@@ -216,9 +229,9 @@ bool TTrain::Init(TDynamicObject *NewDynamicObject, bool e3d)
fMechPitch = 0.1; fMechPitch = 0.1;
fMainRelayTimer = 0; // Hunter, do k...y nędzy, ustawiaj wartości początkowe zmiennych! fMainRelayTimer = 0; // Hunter, do k...y nędzy, ustawiaj wartości początkowe zmiennych!
if (!LoadMMediaFile(DynamicObject->asBaseDir + DynamicObject->MoverParameters->TypeName + if( false == LoadMMediaFile( DynamicObject->asBaseDir + DynamicObject->MoverParameters->TypeName + ".mmd" ) ) {
".mmd"))
return false; return false;
}
// McZapkie: w razie wykolejenia // McZapkie: w razie wykolejenia
// dsbDerailment=TSoundsManager::GetFromName("derail.wav"); // dsbDerailment=TSoundsManager::GetFromName("derail.wav");
@@ -339,14 +352,13 @@ PyObject *TTrain::GetTrainState()
PyGetFloatS(fPress[i][j])); PyGetFloatS(fPress[i][j]));
} }
bool bEP, bPN; bool bEP, bPN;
bEP = (mvControlled->LocHandle->GetCP() > 0.2) || (fEIMParams[0][2] > 0.01); bEP = ( mvControlled->LocHandle->GetCP() > 0.2 ) || ( fEIMParams[0][2] > 0.01 );
PyDict_SetItemString(dict, "dir_brake", PyGetBool(bEP)); PyDict_SetItemString(dict, "dir_brake", PyGetBool(bEP));
if (typeid(mvControlled->Hamulec) == typeid(TLSt) || if (typeid(mvControlled->Hamulec) == typeid(TLSt) ||
typeid(mvControlled->Hamulec) == typeid(TEStED)) typeid(mvControlled->Hamulec) == typeid(TEStED))
{ {
TBrake *temp_ham = mvControlled->Hamulec;
// TLSt* temp_ham2 = temp_ham; // TLSt* temp_ham2 = temp_ham;
bPN = (static_cast<TLSt *>(temp_ham)->GetEDBCP() > 0.2); bPN = ( static_cast<TLSt *>( mvControlled->Hamulec.get() )->GetEDBCP() > 0.2 );
} }
else else
bPN = false; bPN = false;
@@ -736,8 +748,7 @@ if ((mvControlled->PantFrontVolt) || (mvControlled->PantRearVolt) ||
else if (cKey == Global::Keys[k_OpenLeft]) // NBMX 17-09-2003: otwieranie drzwi else if (cKey == Global::Keys[k_OpenLeft]) // NBMX 17-09-2003: otwieranie drzwi
{ {
if (mvOccupied->DoorOpenCtrl == 1) if (mvOccupied->DoorOpenCtrl == 1)
if (mvOccupied->CabNo < 0 ? mvOccupied->DoorRight(true) : if (mvOccupied->CabNo < 0 ? mvOccupied->DoorRight(true) : mvOccupied->DoorLeft(true))
mvOccupied->DoorLeft(true))
{ {
dsbSwitch->SetVolume(DSBVOLUME_MAX); dsbSwitch->SetVolume(DSBVOLUME_MAX);
dsbSwitch->Play(0, 0, 0); dsbSwitch->Play(0, 0, 0);
@@ -750,9 +761,8 @@ if ((mvControlled->PantFrontVolt) || (mvControlled->PantRearVolt) ||
} }
else if (cKey == Global::Keys[k_OpenRight]) // NBMX 17-09-2003: otwieranie drzwi else if (cKey == Global::Keys[k_OpenRight]) // NBMX 17-09-2003: otwieranie drzwi
{ {
if (mvOccupied->DoorCloseCtrl == 1) if (mvOccupied->DoorOpenCtrl == 1)
if (mvOccupied->CabNo < 0 ? mvOccupied->DoorLeft(true) : if (mvOccupied->CabNo < 0 ? mvOccupied->DoorLeft(true) : mvOccupied->DoorRight(true))
mvOccupied->DoorRight(true))
{ {
dsbSwitch->SetVolume(DSBVOLUME_MAX); dsbSwitch->SetVolume(DSBVOLUME_MAX);
dsbSwitch->Play(0, 0, 0); dsbSwitch->Play(0, 0, 0);
@@ -898,7 +908,7 @@ if ((mvControlled->PantFrontVolt) || (mvControlled->PantRearVolt) ||
else if (cKey == Global::Keys[k_LeftSign]) // lewe swiatlo - włączenie else if (cKey == Global::Keys[k_LeftSign]) // lewe swiatlo - włączenie
// ABu 060205: dzielo Wingera po malutkim liftingu: // ABu 060205: dzielo Wingera po malutkim liftingu:
{ {
if (!mvOccupied->LightsPosNo > 0) if (false == (mvOccupied->LightsPosNo > 0))
{ {
if ((GetAsyncKeyState(VK_CONTROL) < 0) && if ((GetAsyncKeyState(VK_CONTROL) < 0) &&
(ggRearLeftLightButton.SubModel)) // hunter-230112 - z controlem zapala z tylu (ggRearLeftLightButton.SubModel)) // hunter-230112 - z controlem zapala z tylu
@@ -1073,7 +1083,7 @@ if ((mvControlled->PantFrontVolt) || (mvControlled->PantRearVolt) ||
// tylne (koncowki) - // tylne (koncowki) -
// wlaczenie // wlaczenie
{ {
if (!mvOccupied->LightsPosNo > 0) if (false == (mvOccupied->LightsPosNo > 0))
{ {
if ((GetAsyncKeyState(VK_CONTROL) < 0) && if ((GetAsyncKeyState(VK_CONTROL) < 0) &&
(ggRearRightLightButton.SubModel)) // hunter-230112 - z controlem zapala z tylu (ggRearRightLightButton.SubModel)) // hunter-230112 - z controlem zapala z tylu
@@ -1968,27 +1978,27 @@ if
} }
else if (cKey == Global::Keys[k_CloseLeft]) // NBMX 17-09-2003: zamykanie drzwi else if (cKey == Global::Keys[k_CloseLeft]) // NBMX 17-09-2003: zamykanie drzwi
{ {
if (mvOccupied->CabNo < 0 ? mvOccupied->DoorRight(false) : mvOccupied->DoorLeft(false)) if( mvOccupied->DoorCloseCtrl == 1 ) {
{ if( mvOccupied->CabNo < 0 ? mvOccupied->DoorRight( false ) : mvOccupied->DoorLeft( false ) ) {
dsbSwitch->SetVolume(DSBVOLUME_MAX); dsbSwitch->SetVolume( DSBVOLUME_MAX );
dsbSwitch->Play(0, 0, 0); dsbSwitch->Play( 0, 0, 0 );
if (dsbDoorClose) if( dsbDoorClose ) {
{ dsbDoorClose->SetCurrentPosition( 0 );
dsbDoorClose->SetCurrentPosition(0); dsbDoorClose->Play( 0, 0, 0 );
dsbDoorClose->Play(0, 0, 0); }
} }
} }
} }
else if (cKey == Global::Keys[k_CloseRight]) // NBMX 17-09-2003: zamykanie drzwi else if (cKey == Global::Keys[k_CloseRight]) // NBMX 17-09-2003: zamykanie drzwi
{ {
if (mvOccupied->CabNo < 0 ? mvOccupied->DoorLeft(false) : mvOccupied->DoorRight(false)) if( mvOccupied->DoorCloseCtrl == 1 ) {
{ if( mvOccupied->CabNo < 0 ? mvOccupied->DoorLeft( false ) : mvOccupied->DoorRight( false ) ) {
dsbSwitch->SetVolume(DSBVOLUME_MAX); dsbSwitch->SetVolume( DSBVOLUME_MAX );
dsbSwitch->Play(0, 0, 0); dsbSwitch->Play( 0, 0, 0 );
if (dsbDoorClose) if( dsbDoorClose ) {
{ dsbDoorClose->SetCurrentPosition( 0 );
dsbDoorClose->SetCurrentPosition(0); dsbDoorClose->Play( 0, 0, 0 );
dsbDoorClose->Play(0, 0, 0); }
} }
} }
} }
@@ -2105,7 +2115,7 @@ if
else if (cKey == Global::Keys[k_LeftSign]) // ABu 060205: lewe swiatlo - else if (cKey == Global::Keys[k_LeftSign]) // ABu 060205: lewe swiatlo -
// wylaczenie // wylaczenie
{ {
if (!mvOccupied->LightsPosNo > 0) if (false == (mvOccupied->LightsPosNo > 0))
{ {
if ((GetAsyncKeyState(VK_CONTROL) < 0) && if ((GetAsyncKeyState(VK_CONTROL) < 0) &&
(ggRearLeftLightButton.SubModel)) // hunter-230112 - z controlem gasi z tylu (ggRearLeftLightButton.SubModel)) // hunter-230112 - z controlem gasi z tylu
@@ -2278,7 +2288,7 @@ if
if (cKey == Global::Keys[k_RightSign]) // Winger 070304: swiatla tylne if (cKey == Global::Keys[k_RightSign]) // Winger 070304: swiatla tylne
// (koncowki) - wlaczenie // (koncowki) - wlaczenie
{ {
if (!mvOccupied->LightsPosNo > 0) if (false == (mvOccupied->LightsPosNo > 0))
{ {
if ((GetAsyncKeyState(VK_CONTROL) < 0) && if ((GetAsyncKeyState(VK_CONTROL) < 0) &&
(ggRearRightLightButton.SubModel)) // hunter-230112 - z controlem gasi z tylu (ggRearRightLightButton.SubModel)) // hunter-230112 - z controlem gasi z tylu
@@ -3220,7 +3230,7 @@ bool TTrain::Update()
rsRunningNoise.AM = am; rsRunningNoise.AM = am;
rsRunningNoise.AA = 0.7; rsRunningNoise.AA = 0.7;
rsRunningNoise.FA = fa; rsRunningNoise.FA = fa;
rsRunningNoise.FM - fm; rsRunningNoise.FM = fm;
} }
mvOccupied->EventFlag = false; mvOccupied->EventFlag = false;
} }
@@ -5063,6 +5073,7 @@ bool TTrain::LoadMMediaFile(std::string const &asFileName)
dsbCouplerDetach = TSoundsManager::GetFromName("couplerdetach.wav", true); dsbCouplerDetach = TSoundsManager::GetFromName("couplerdetach.wav", true);
dsbCouplerStretch = TSoundsManager::GetFromName("en57_couplerstretch.wav", true); dsbCouplerStretch = TSoundsManager::GetFromName("en57_couplerstretch.wav", true);
dsbCouplerAttach = TSoundsManager::GetFromName("couplerattach.wav", true); dsbCouplerAttach = TSoundsManager::GetFromName("couplerattach.wav", true);
std::string token; std::string token;
do do
{ {

View File

@@ -102,7 +102,7 @@ TTrack * TTrackFollower::SetCurrentTrack(TTrack *pTrack, int end)
pCurrentTrack->AxleCounter(-1, Owner); // opuszczenie tamtego toru pCurrentTrack->AxleCounter(-1, Owner); // opuszczenie tamtego toru
} }
pCurrentTrack = pTrack; pCurrentTrack = pTrack;
pCurrentSegment = (pCurrentTrack ? pCurrentTrack->CurrentSegment() : NULL); pCurrentSegment = ( pCurrentTrack != nullptr ? pCurrentTrack->CurrentSegment() : nullptr );
if (!pCurrentTrack) if (!pCurrentTrack)
Error(Owner->MoverParameters->Name + " at NULL track"); Error(Owner->MoverParameters->Name + " at NULL track");
return pCurrentTrack; return pCurrentTrack;
@@ -330,5 +330,3 @@ void TTrackFollower::Render(float fNr)
} }
#endif #endif
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
#pragma package(smart_init)

View File

@@ -16,10 +16,10 @@ http://mozilla.org/MPL/2.0/.
class TTrackFollower class TTrackFollower
{ // oś poruszająca się po torze { // oś poruszająca się po torze
private: private:
TTrack *pCurrentTrack; // na którym torze się znajduje TTrack *pCurrentTrack; // na którym torze siê znajduje
TSegment *pCurrentSegment; // zwrotnice mogą mieć dwa segmenty std::shared_ptr<TSegment> pCurrentSegment; // zwrotnice mog¹ mieæ dwa segmenty
double fCurrentDistance; // przesunięcie względem Point1 w stronę Point2 double fCurrentDistance; // przesuniêcie wzglêdem Point1 w stronê Point2
double fDirection; // ustawienie względem toru: -1.0 albo 1.0, mnożone przez dystans double fDirection; // ustawienie wzglêdem toru: -1.0 albo 1.0, mno¿one przez dystans
bool ComputatePosition(); // przeliczenie pozycji na torze bool ComputatePosition(); // przeliczenie pozycji na torze
TDynamicObject *Owner; // pojazd posiadający TDynamicObject *Owner; // pojazd posiadający
int iEventFlag; // McZapkie-020602: informacja o tym czy wyzwalac zdarzenie: 0,1,2,3 int iEventFlag; // McZapkie-020602: informacja o tym czy wyzwalac zdarzenie: 0,1,2,3

View File

@@ -35,7 +35,6 @@ http://mozilla.org/MPL/2.0/.
#define TEXTURE_FILTER_CONTROL_EXT 0x8500 #define TEXTURE_FILTER_CONTROL_EXT 0x8500
#define TEXTURE_LOD_BIAS_EXT 0x8501 #define TEXTURE_LOD_BIAS_EXT 0x8501
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
#pragma package(smart_init)
typedef void(APIENTRY *FglutBitmapCharacter)(void *font, int character); // typ funkcji typedef void(APIENTRY *FglutBitmapCharacter)(void *font, int character); // typ funkcji
FglutBitmapCharacter glutBitmapCharacterDLL = NULL; // deklaracja zmiennej FglutBitmapCharacter glutBitmapCharacterDLL = NULL; // deklaracja zmiennej

View File

@@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerCommand>T:\sources\Projects\maszyna\eu07++.exe</LocalDebuggerCommand>
<LocalDebuggerWorkingDirectory>..\..\Projects\maszyna</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LocalDebuggerCommand>T:\sources\Projects\maszyna\eu07++.exe</LocalDebuggerCommand>
<LocalDebuggerWorkingDirectory>..\..\Projects\maszyna</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>

View File

@@ -15,7 +15,7 @@ http://mozilla.org/MPL/2.0/.
#include "mtable.h" #include "mtable.h"
// using namespace Mtable; // using namespace Mtable;
TMTableTime *Mtable::GlobalTime; std::shared_ptr<TMTableTime> Mtable::GlobalTime;
double CompareTime(double t1h, double t1m, double t2h, double t2m) /*roznica czasu w minutach*/ double CompareTime(double t1h, double t1m, double t2h, double t2m) /*roznica czasu w minutach*/
// zwraca różnicę czasu // zwraca różnicę czasu
@@ -529,19 +529,6 @@ void TMTableTime::UpdateMTableTime(double deltaT)
GameTime = GameTime + deltaT; GameTime = GameTime + deltaT;
} }
TMTableTime::TMTableTime(int InitH, int InitM, int InitSRH, int InitSRM, int InitSSH, int InitSSM)
{
GameTime = 0.0;
dd = 0;
hh = InitH;
mm = InitM;
srh = InitSRH;
srm = InitSRM;
ssh = InitSSH;
ssm = InitSSM;
mr = 0.0;
}
bool TTrainParameters::DirectionChange() bool TTrainParameters::DirectionChange()
// sprawdzenie, czy po zatrzymaniu wykonać kolejne komendy // sprawdzenie, czy po zatrzymaniu wykonać kolejne komendy
{ {

View File

@@ -86,20 +86,29 @@ class TMTableTime
{ {
public: public:
double GameTime; double GameTime = 0.0;
int dd; int dd = 0;
int hh; int hh = 0;
int mm; int mm = 0;
int srh; int srh = 0;
int srm; /*wschod slonca*/ int srm = 0; /*wschod slonca*/
int ssh; int ssh = 0;
int ssm; /*zachod slonca*/ int ssm = 0; /*zachod slonca*/
double mr; double mr = 0.0;
void UpdateMTableTime(double deltaT); void UpdateMTableTime(double deltaT);
TMTableTime(int InitH, int InitM, int InitSRH, int InitSRM, int InitSSH, int InitSSM); TMTableTime(int InitH, int InitM, int InitSRH, int InitSRM, int InitSSH, int InitSSM) :
hh( InitH ),
mm( InitM ),
srh( InitSRH ),
srm( InitSRM ),
ssh( InitSSH ),
ssm( InitSSM )
{}
TMTableTime() = default;
}; };
extern TMTableTime *GlobalTime; extern std::shared_ptr<TMTableTime> GlobalTime;
} }
#if !defined(NO_IMPLICIT_NAMESPACE_USE) #if !defined(NO_IMPLICIT_NAMESPACE_USE)

Binary file not shown.

Binary file not shown.

View File

@@ -79,6 +79,10 @@ bool cParser::getTokens(int Count, bool ToLower, const char *Break)
for (i = 0; i < Count; ++i) for (i = 0; i < Count; ++i)
{ {
std::string string = readToken(ToLower, Break); std::string string = readToken(ToLower, Break);
if( true == string.empty() ) {
// no more tokens
break;
}
// collect parameters // collect parameters
if (i == 0) if (i == 0)
this->str(string); this->str(string);
@@ -191,7 +195,7 @@ bool cParser::trimComments(std::string &String)
return false; return false;
} }
std::string cParser::readComment(const std::string Break) std::string cParser::readComment(std::string const &Break)
{ // pobieranie znaków aż do znalezienia znacznika końca { // pobieranie znaków aż do znalezienia znacznika końca
std::string token = ""; std::string token = "";
while (mStream->peek() != EOF) while (mStream->peek() != EOF)

View File

@@ -57,7 +57,7 @@ class cParser : public std::stringstream
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
readToken(); readToken();
}; };
inline bool expectToken(std::string value) inline bool expectToken(std::string const &value)
{ {
return readToken() == value; return readToken() == value;
}; };
@@ -77,7 +77,7 @@ class cParser : public std::stringstream
protected: protected:
// methods: // methods:
std::string readToken(bool ToLower = true, const char *Break = "\n\t ;"); std::string readToken(bool ToLower = true, const char *Break = "\n\t ;");
std::string readComment(const std::string Break = "\n\t ;"); std::string readComment(std::string const &Break = "\n\t ;");
std::string trtest; std::string trtest;
bool trimComments(std::string &String); bool trimComments(std::string &String);
// members: // members:

View File

@@ -10,6 +10,12 @@
#define _CRTDBG_MAP_ALLOC #define _CRTDBG_MAP_ALLOC
#include <stdlib.h> #include <stdlib.h>
#include <crtdbg.h> #include <crtdbg.h>
#ifdef _DEBUG
#ifndef DBG_NEW
#define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
#define new DBG_NEW
#endif
#endif // _DEBUG
#endif #endif
// operating system // operating system
#include "targetver.h" #include "targetver.h"
@@ -19,6 +25,7 @@
#undef NOMINMAX #undef NOMINMAX
// stl // stl
#include <cstdlib> #include <cstdlib>
#include <cassert>
#define _USE_MATH_DEFINES #define _USE_MATH_DEFINES
#include <cmath> #include <cmath>
#include <cstdint> #include <cstdint>

View File

@@ -18,7 +18,6 @@ http://mozilla.org/MPL/2.0/.
#ifndef WAVE_READ_H #ifndef WAVE_READ_H
#define WAVE_READ_H #define WAVE_READ_H
#include <mmreg.h>
#include <mmsystem.h> #include <mmsystem.h>
HRESULT WaveOpenFile(CHAR *strFileName, HMMIO *phmmioIn, WAVEFORMATEX **ppwfxInfo, HRESULT WaveOpenFile(CHAR *strFileName, HMMIO *phmmioIn, WAVEFORMATEX **ppwfxInfo,