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

LCD Screens in python

Merge with python branch
This commit is contained in:
Firleju
2015-04-29 13:17:44 +02:00
parent ef4e168c68
commit 06652e579c
167 changed files with 15534 additions and 1120 deletions

View File

@@ -4,9 +4,11 @@ IndentWidth: 4
---
Language: Cpp
AlignEscapedNewlinesLeft: true
AlignTrailingComments: false
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: false
AllowShortBlocksOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
ColumnLimit: 100
---

View File

@@ -32,10 +32,12 @@ TAdvancedSound::~TAdvancedSound()
// SoundShut.Stop();
}
void TAdvancedSound::Free() {}
void TAdvancedSound::Free()
{
}
void TAdvancedSound::Init(char *NameOn, char *Name, char *NameOff,
double DistanceAttenuation, vector3 pPosition)
void TAdvancedSound::Init(char *NameOn, char *Name, char *NameOff, double DistanceAttenuation,
vector3 pPosition)
{
SoundStart.Init(NameOn, DistanceAttenuation, pPosition.x, pPosition.y, pPosition.z, true);
SoundCommencing.Init(Name, DistanceAttenuation, pPosition.x, pPosition.y, pPosition.z, true);
@@ -131,8 +133,7 @@ void TAdvancedSound::Update(bool ListenerInside, vector3 NewPosition)
}
}
void TAdvancedSound::UpdateAF(double A, double F, bool ListenerInside,
vector3 NewPosition)
void TAdvancedSound::UpdateAF(double A, double F, bool ListenerInside, vector3 NewPosition)
{ // update, ale z amplituda i czestotliwoscia
if ((State == ss_Commencing) && (SoundCommencing.AM > 0))
{

View File

@@ -38,7 +38,7 @@ class TAdvancedSound
TAdvancedSound();
~TAdvancedSound();
void Init(char *NameOn, char *Name, char *NameOff, double DistanceAttenuation,
vector3 pPosition);
vector3 pPosition);
void Load(TQueryParserComp *Parser, vector3 pPosition);
void TurnOn(bool ListenerInside, vector3 NewPosition);
void TurnOff(bool ListenerInside, vector3 NewPosition);

View File

@@ -14,9 +14,14 @@ http://mozilla.org/MPL/2.0/.
#include "AirCoupler.h"
#include "Timer.h"
TAirCoupler::TAirCoupler() { Clear(); }
TAirCoupler::TAirCoupler()
{
Clear();
}
TAirCoupler::~TAirCoupler() {}
TAirCoupler::~TAirCoupler()
{
}
int TAirCoupler::GetStatus()
{ // zwraca 1, jeœli istnieje model prosty, 2 gdy skoœny

View File

@@ -28,6 +28,7 @@ http://mozilla.org/MPL/2.0/.
//---------------------------------------------------------------------------
TAnimAdvanced::TAnimAdvanced(){};
TAnimAdvanced::~TAnimAdvanced(){
// delete[] pVocaloidMotionData; //plik został zmodyfikowany
};
@@ -115,7 +116,7 @@ void TAnimContainer::SetRotateAnim(vector3 vNewRotateAngles, double fNewRotateSp
*/
if (evDone)
{ // dołączyć model do listy aniomowania, żeby animacje były przeliczane również bez
// wyświetlania
// wyświetlania
if (iAnim >= 0)
{ // jeśli nie jest jeszcze na liście animacyjnej
acAnimNext = TAnimModel::acAnimList; // pozostałe doklić sobie jako ogon
@@ -138,7 +139,7 @@ void TAnimContainer::SetTranslateAnim(vector3 vNewTranslate, double fNewSpeed)
*/
if (evDone)
{ // dołączyć model do listy aniomowania, żeby animacje były przeliczane również bez
// wyświetlania
// wyświetlania
if (iAnim >= 0)
{ // jeśli nie jest jeszcze na liście animacyjnej
acAnimNext = TAnimModel::acAnimList; // pozostałe doklić sobie jako ogon
@@ -179,7 +180,7 @@ void TAnimContainer::AnimSetVMD(double fNewSpeed)
//-+-+ - dłoń ma w górze zamiast na pasie w pozycji początkowej
//+--+ - głowa do tyłu (broda w górę) w pozycji początkowej
//--++ - pozycja początkowa dobra, trąca u góry, ale z rękami jakoś nie tak, kółko w
//przeciwną stronę
// przeciwną stronę
//++++ - kładzie się brzuchem do góry
//-+++ - ręce w górze na początku, zamiast w dół, łokieć jakby w przeciwną stronę
//+-++ - nie podnosi ręki do głowy
@@ -223,7 +224,7 @@ void TAnimContainer::UpdateModel()
vTranslation += s;
else
vTranslation = vTranslateTo; // koniec animacji, "koniec animowania" uruchomi
// się w następnej klatce
// się w następnej klatce
}
else
{ // koniec animowania
@@ -233,7 +234,7 @@ void TAnimContainer::UpdateModel()
iAnim &= ~2; // wyłączyć zmianę pozycji submodelu
if (evDone)
Global::AddToQuery(evDone, NULL); // wykonanie eventu informującego o
// zakończeniu
// zakończeniu
}
}
if (fRotateSpeed != 0)
@@ -300,7 +301,7 @@ void TAnimContainer::UpdateModel()
fRotateSpeed = 0.0;
if (evDone)
Global::AddToQuery(evDone, NULL); // wykonanie eventu informującego o
// zakończeniu
// zakończeniu
}
}
if (fAngleSpeed != 0.0)
@@ -364,7 +365,7 @@ void TAnimContainer::UpdateModelIK()
{
case at_IK11: // stopa: ustawić w kierunku czubka (pierwszy potomny)
d = ch->Translation1Get(); // wektor względem aktualnego układu (nie uwzględnia
// obrotu)
// obrotu)
k = float3(RadToDeg(atan2(d.z, hypot(d.x, d.y))), 0.0,
-RadToDeg(atan2(d.y, d.x))); // proste skierowanie na punkt
pSubModel->SetRotateIK1(k);
@@ -378,7 +379,7 @@ void TAnimContainer::UpdateModelIK()
// potem wyliczyć ewentualne odchylenie w tej i następnej
// w sumie to proste, jak wyznaczenie kątów w trójkącie o znanej długości boków...
d = ch->Translation2Get(); // wektor względem aktualnego układu (nie uwzględnia
// obrotu)
// obrotu)
// if ()
{ // kość IK jest dalej niż pozycja spoczynkowa
k = float3(RadToDeg(atan2(d.z, hypot(d.x, d.y))), 0.0,
@@ -456,7 +457,7 @@ bool TAnimModel::Init(AnsiString asName, AnsiString asReplacableTexture)
0x31310031; // tekstura z kanałem alfa - nie renderować w cyklu nieprzezroczystych
else
iTexAlpha = 0x30300030; // tekstura nieprzezroczysta - nie renderować w cyklu
// przezroczystych
// przezroczystych
return (Init(TModelsManager::GetModel(asName.c_str())));
}
@@ -684,10 +685,12 @@ void TAnimModel::RenderAlphaVBO(vector3 *vPosition)
//---------------------------------------------------------------------------
bool TAnimModel::TerrainLoaded()
{ // zliczanie kwadratów kilometrowych (główna linia po Next) do tworznia tablicy
return (this ? pModel != NULL : false); };
return (this ? pModel != NULL : false);
};
int TAnimModel::TerrainCount()
{ // zliczanie kwadratów kilometrowych (główna linia po Next) do tworznia tablicy
return pModel ? pModel->TerrainCount() : 0; };
return pModel ? pModel->TerrainCount() : 0;
};
TSubModel *__fastcall TAnimModel::TerrainSquare(int n)
{ // pobieranie wskaźników do pierwszego submodelu
return pModel ? pModel->TerrainSquare(n) : 0;
@@ -721,7 +724,7 @@ void TAnimModel::Advanced()
if (!strcmp(pCurrent->pMovementData->cBone,
(pCurrent->pMovementData + 1)->cBone))
{ // jak kolejna ramka dotyczy tego samego submodelu, ustawić animację do
// kolejnej ramki
// kolejnej ramki
++pCurrent->pMovementData; // kolejna klatka
pCurrent->AnimSetVMD(
pAdvanced->fFrequency /
@@ -773,7 +776,7 @@ void TAnimModel::AnimationVND(void *pData, double a, double b, double c, double
{
pSub->pMovementData = pAdvanced->pMovementData + i; // gotów do animowania
pSub->AnimSetVMD(0.0); // usuawienie pozycji początkowej (powinna być zerowa,
// inaczej będzie skok)
// inaczej będzie skok)
}
name = AnsiString(pAdvanced->pMovementData[i].cBone); // nowa nazwa do pomijania
}

View File

@@ -72,7 +72,7 @@ class TAnimContainer
public:
TAnimContainer *pNext;
TAnimContainer *acAnimNext; // lista animacji z eventem, które musz¹ byæ przeliczane równie¿ bez
// wyœwietlania
// wyœwietlania
TAnimContainer();
~TAnimContainer();
bool Init(TSubModel *pNewSubModel);
@@ -80,7 +80,10 @@ class TAnimContainer
// std::string(pSubModel?pSubModel->asName.c_str():""); };
// std::string inline GetName() { return std::string(pSubModel?pSubModel->pName:"");
// };
char *__fastcall NameGet() { return (pSubModel ? pSubModel->pName : NULL); };
char *__fastcall NameGet()
{
return (pSubModel ? pSubModel->pName : NULL);
};
// void SetRotateAnim(vector3 vNewRotateAxis, double fNewDesiredAngle, double
// fNewRotateSpeed, bool bResetAngle=false);
void SetRotateAnim(vector3 vNewRotateAngles, double fNewRotateSpeed);
@@ -90,7 +93,10 @@ class TAnimContainer
void UpdateModel();
void UpdateModelIK();
bool InMovement(); // czy w trakcie animacji?
double _fastcall AngleGet() { return vRotateAngles.z; }; // jednak ostatnia, T3D ma inny uk³ad
double _fastcall AngleGet()
{
return vRotateAngles.z;
}; // jednak ostatnia, T3D ma inny uk³ad
vector3 _fastcall TransGet()
{
return vector3(-vTranslation.x, vTranslation.z, vTranslation.y);
@@ -101,7 +107,10 @@ class TAnimContainer
pSubModel->WillBeAnimated();
};
void EventAssign(TEvent *ev);
TEvent *__fastcall Event() { return evDone; };
TEvent *__fastcall Event()
{
return evDone;
};
};
class TAnimAdvanced
@@ -141,7 +150,7 @@ class TAnimModel
public:
GLuint ReplacableSkinId[5]; // McZapkie-020802: zmienialne skory
static TAnimContainer *acAnimList; // lista animacji z eventem, które musz¹ byæ przeliczane
// równie¿ bez wyœwietlania
// równie¿ bez wyœwietlania
TAnimModel();
~TAnimModel();
bool Init(TModel3d *pNewModel);

View File

@@ -25,7 +25,10 @@ class TButton
TButton();
~TButton();
void Clear(int i = -1);
inline void FeedbackBitSet(int i) { iFeedbackBit = 1 << i; };
inline void FeedbackBitSet(int i)
{
iFeedbackBit = 1 << i;
};
inline void Turn(bool to)
{
bOn = to;
@@ -46,7 +49,10 @@ class TButton
bOn = !bOn;
Update();
};
inline bool Active() { return (pModelOn) || (pModelOff); };
inline bool Active()
{
return (pModelOn) || (pModelOff);
};
void Init(AnsiString asName, TModel3d *pModel, bool bNewOn = false);
void Load(TQueryParserComp *Parser, TModel3d *pModel1, TModel3d *pModel2 = NULL);
};

View File

@@ -157,7 +157,7 @@ vector3 TCamera::GetDirection()
bool TCamera::SetMatrix()
{
glRotated(-Roll * 180.0f / M_PI, 0, 0, 1); // po wy³¹czeniu tego krêci siê pojazd, a sceneria
// nie
// nie
glRotated(-Pitch * 180.0f / M_PI, 1, 0, 0);
glRotated(-Yaw * 180.0f / M_PI, 0, 1, 0); // w zewnêtrznym widoku: kierunek patrzenia

View File

@@ -38,7 +38,10 @@ class TCamera
vector3 CrossPos;
double CrossDist;
void Init(vector3 NPos, vector3 NAngle);
void Reset() { Pitch = Yaw = Roll = 0; };
void Reset()
{
Pitch = Yaw = Roll = 0;
};
void OnCursorMove(double x, double y);
void Update();
vector3 GetDirection();

View File

@@ -274,7 +274,10 @@ void Console::BitsUpdate(int mask)
}
};
bool Console::Pressed(int x) { return Global::bActive && (GetKeyState(x) < 0); }; // na razie tak - czyta się tylko klawiatura
bool Console::Pressed(int x)
{ // na razie tak - czyta się tylko klawiatura
return Global::bActive && (GetKeyState(x) < 0);
};
void Console::ValueSet(int x, double y)
{ // ustawienie wartości (y) na kanale analogowym (x)
@@ -353,5 +356,11 @@ void Console::OnKeyUp(int k)
else
iButton[char(k) >> 5] &= ~(1 << (k & 31)); // wyłącz monostabilny podstawowy
};
int Console::KeyDownConvert(int k) { return int(ktTable[k & 0x3FF].iDown); };
int Console::KeyUpConvert(int k) { return int(ktTable[k & 0x3FF].iUp); };
int Console::KeyDownConvert(int k)
{
return int(ktTable[k & 0x3FF].iDown);
};
int Console::KeyUpConvert(int k)
{
return int(ktTable[k & 0x3FF].iUp);
};

View File

@@ -48,4 +48,7 @@ bool TLPT::Connect(int port)
return bool(OutPort);
};
void TLPT::Out(int x) { OutPort(address, x); }; // wys³anie bajtu do portu
void TLPT::Out(int x)
{ // wys³anie bajtu do portu
OutPort(address, x);
};

View File

@@ -39,7 +39,10 @@ TPoKeys55::TPoKeys55()
bNoError = true;
};
//---------------------------------------------------------------------------
TPoKeys55::~TPoKeys55() { Close(); };
TPoKeys55::~TPoKeys55()
{
Close();
};
//---------------------------------------------------------------------------
bool TPoKeys55::Close()
{ // roz³¹czenie komunikacji
@@ -86,7 +89,7 @@ bool TPoKeys55::Connect()
{
ErrorStatus = GetLastError();
if (ERROR_NO_MORE_ITEMS == ErrorStatus) // Did we reach the end of the list of matching
// devices in the DeviceInfoTable?
// devices in the DeviceInfoTable?
{ // Cound not find the device. Must not have been attached.
SetupDiDestroyDeviceInfoList(
DeviceInfoTable); // Clean up the old structure we no longer need.
@@ -138,7 +141,7 @@ bool TPoKeys55::Connect()
// free(PropertyValueBuffer); //No longer need the PropertyValueBuffer,free the memory to
// prevent potential memory leaks
delete PropertyValueBuffer; // No longer need the PropertyValueBuffer,free the memory to
// prevent potential memory leaks
// prevent potential memory leaks
// Convert both strings to lower case. This makes the code more robust/portable accross OS
// Versions
DeviceIDFromRegistry = DeviceIDFromRegistry.LowerCase();
@@ -202,12 +205,11 @@ bool TPoKeys55::Connect()
return false;
}
//---------------------------------------------------------------------------
bool TPoKeys55::Write(unsigned char c, unsigned char b3, unsigned char b4,
unsigned char b5)
bool TPoKeys55::Write(unsigned char c, unsigned char b3, unsigned char b4, unsigned char b5)
{
DWORD BytesWritten = 0;
OutputBuffer[0] = 0; // The first byte is the "Report ID" and does not get transmitted over the
// USB bus. Always set=0.
// USB bus. Always set=0.
OutputBuffer[1] = 0xBB; // 0xBB - bajt rozpoznawczy dla PoKeys55
OutputBuffer[2] = iLastCommand = c; // operacja: 0x31: blokowy odczyt wejϾ
OutputBuffer[3] = b3; // np. numer pinu (o 1 mniej ni¿ numer na p³ytce)
@@ -233,7 +235,7 @@ bool TPoKeys55::Read()
{
DWORD BytesRead = 0;
InputBuffer[0] = 0; // The first byte is the "Report ID" and does not get transmitted over the
// USB bus. Always set=0.
// USB bus. Always set=0.
// Now get the response packet from the firmware.
// The following call to ReadFIle() retrieves 64 bytes of data from the USB device.
ReadFile(ReadHandle, &InputBuffer, 65, &BytesRead,
@@ -361,7 +363,7 @@ bool TPoKeys55::Update(bool pause)
if (!iRepeats)
bNoError = true; // jest OK
else if (iRepeats >= 10) // youBy 2014-07: przy 5 powtórzeniach sieje mi pauz¹ po 2 razy na
// sekundê, a przy 10 jest ok
// sekundê, a przy 10 jest ok
{ // przekroczenie liczby prób wymusza kolejn¹ fazê
++iFaza;
iRepeats = 1; // w nowej fazie nowe szanse, ale nie od 0!

View File

@@ -28,8 +28,7 @@ class TPoKeys55
~TPoKeys55();
bool Connect();
bool Close();
bool Write(unsigned char c, unsigned char b3, unsigned char b4 = 0,
unsigned char b5 = 0);
bool Write(unsigned char c, unsigned char b3, unsigned char b4 = 0, unsigned char b5 = 0);
bool Read();
bool ReadLoop(int i);
AnsiString Version();

3
Data.h
View File

@@ -17,7 +17,8 @@ struct TDist
{
int x, y;
};
const TDist SectorOrder[] = { // tabela wspó³rzêdnych sektorów, posortowana wg odleg³oœci
const TDist SectorOrder[] = {
// tabela wspó³rzêdnych sektorów, posortowana wg odleg³oœci
{0, 0}, // 0.00
{1, 0}, // 1.00
{0, 1}, // 1.00

File diff suppressed because it is too large Load Diff

View File

@@ -164,7 +164,7 @@ class TController
double fLastStopExpDist; // odległość wygasania ostateniego przystanku
double ReactionTime; // czas reakcji Ra: czego i na co? świadomości AI
double fBrakeTime; // wpisana wartość jest zmniejszana do 0, gdy ujemna należy zmienić nastawę
// hamulca
// hamulca
private:
double fReady; // poziom odhamowania wagonów
bool Ready; // ABu: stan gotowosci do odjazdu - sprawdzenie odhamowania wagonow
@@ -178,7 +178,7 @@ class TController
public:
bool AIControllFlag; // rzeczywisty/wirtualny maszynista
int iRouteWanted; // oczekiwany kierunek jazdy (0-stop,1-lewo,2-prawo,3-prosto) np. odpala
// migacz lub czeka na stan zwrotnicy
// migacz lub czeka na stan zwrotnicy
private:
TDynamicObject *pVehicle; // pojazd w którym siedzi sterujący
TDynamicObject *
@@ -194,17 +194,17 @@ class TController
int iGuardRadio; // numer kanału radiowego kierownika (0, gdy nie używa radia)
public:
double AccPreferred; // preferowane przyspieszenie (wg psychiki kierującego, zmniejszana przy
// wykryciu kolizji)
// wykryciu kolizji)
double AccDesired; // przyspieszenie, jakie ma utrzymywać (<0:nie przyspieszaj,<-0.1:hamuj)
double VelDesired; // predkość, z jaką ma jechać, wynikająca z analizy tableki; <=VelSignal
double fAccDesiredAv; // uśrednione przyspieszenie z kolejnych przebłysków świadomości, żeby
// ograniczyć migotanie
// ograniczyć migotanie
private:
double VelforDriver; // prędkość, używana przy zmianie kierunku (ograniczenie przy nieznajmości
// szlaku?)
// szlaku?)
double VelSignal; // predkość zadawana przez semafor (funkcją SetVelocity())
double VelLimit; // predkość zadawana przez event jednokierunkowego ograniczenia prędkości
// (PutValues albo komendą)
// (PutValues albo komendą)
public:
double VelNext; // prędkość, jaka ma być po przejechaniu długości ProximityDist
private:
@@ -215,7 +215,7 @@ class TController
ActualProximityDist; // odległość brana pod uwagę przy wyliczaniu prędkości i przyspieszenia
private:
vector3 vCommandLocation; // polozenie wskaznika, sygnalizatora lub innego obiektu do ktorego
// odnosi sie komenda
// odnosi sie komenda
TOrders OrderList[maxorders]; // lista rozkazów
int OrderPos, OrderTop; // rozkaz aktualny oraz wolne miejsce do wstawiania nowych
std::ofstream LogFile; // zapis parametrow fizycznych
@@ -226,7 +226,7 @@ class TController
int iDirectionOrder; //żadany kierunek jazdy (służy do zmiany kierunku)
int iVehicleCount; // ilość pojazdów do odłączenia albo zabrania ze składu (-1=wszystkie)
int iCoupler; // maska sprzęgu, jaką należy użyć przy łączeniu (po osiągnięciu trybu Connect), 0
// gdy jazda bez łączenia
// gdy jazda bez łączenia
int iDriverFailCount; // licznik błędów AI
bool Need_TryAgain; // true, jeśli druga pozycja w elektryku nie załapała
bool Need_BrakeRelease;
@@ -235,13 +235,13 @@ class TController
double fMinProximityDist; // minimalna oległość do przeszkody, jaką należy zachować
double fOverhead1; // informacja o napięciu w sieci trakcyjnej (0=brak drutu, zatrzymaj!)
double fOverhead2; // informacja o sposobie jazdy (-1=normalnie, 0=bez prądu, >0=z opuszczonym i
// ograniczeniem prędkości)
// ograniczeniem prędkości)
int iOverheadZero; // suma bitowa jezdy bezprądowej, bity ustawiane przez pojazdy z
// podniesionymi pantografami
// podniesionymi pantografami
int iOverheadDown; // suma bitowa opuszczenia pantografów, bity ustawiane przez pojazdy z
// podniesionymi pantografami
// podniesionymi pantografami
double fVoltage; // uśrednione napięcie sieci: przy spadku poniżej wartości minimalnej opóźnić
// rozruch o losowy czas
// rozruch o losowy czas
private:
double fMaxProximityDist; // akceptowalna odległość stanięcia przed przeszkodą
TStopReason eStopReason; // powód zatrzymania przy ustawieniu zerowej prędkości
@@ -268,15 +268,18 @@ class TController
void ControllingSet(); // znajduje człon do sterowania
void AutoRewident(); // ustawia hamulce w składzie
public:
Mtable::TTrainParameters *__fastcall Timetable() { return TrainParams; };
Mtable::TTrainParameters *__fastcall Timetable()
{
return TrainParams;
};
void PutCommand(AnsiString NewCommand, double NewValue1, double NewValue2,
const _mover::TLocation &NewLocation, TStopReason reason = stopComm);
const _mover::TLocation &NewLocation, TStopReason reason = stopComm);
bool PutCommand(AnsiString NewCommand, double NewValue1, double NewValue2,
const vector3 *NewLocation, TStopReason reason = stopComm);
const vector3 *NewLocation, TStopReason reason = stopComm);
bool UpdateSituation(double dt); // uruchamiac przynajmniej raz na sekundę
// procedury dotyczace rozkazow dla maszynisty
void SetVelocity(double NewVel, double NewVelNext,
TStopReason r = stopNone); // uaktualnia informacje o prędkości
TStopReason r = stopNone); // uaktualnia informacje o prędkości
bool SetProximityVelocity(
double NewDist,
double NewVelNext); // uaktualnia informacje o prędkości przy nastepnym semaforze
@@ -298,8 +301,8 @@ class TController
void OrdersClear();
void OrdersDump();
TController(bool AI, TDynamicObject *NewControll, bool InitPsyche,
bool primary = true // czy ma aktywnie prowadzić?
);
bool primary = true // czy ma aktywnie prowadzić?
);
AnsiString OrderCurrent();
void WaitingSet(double Seconds);
@@ -319,8 +322,7 @@ class TController
TEvent *__fastcall TableCheckTrackEvent(double fDirection, TTrack *Track);
void TableTraceRoute(double fDistance, TDynamicObject *pVehicle = NULL);
void TableCheck(double fDistance);
TCommandType TableUpdate(double &fVelDes, double &fDist, double &fNext,
double &fAcc);
TCommandType TableUpdate(double &fVelDes, double &fDist, double &fNext, double &fAcc);
void TablePurger();
private: // Ra: stare funkcje skanujące, używane do szukania sygnalizatora z tyłu
@@ -342,8 +344,14 @@ class TController
int StationCount();
int StationIndex();
bool IsStop();
bool Primary() { return this ? bool(iDrivigFlags & movePrimary) : false; };
int inline DrivigFlags() { return iDrivigFlags; };
bool Primary()
{
return this ? bool(iDrivigFlags & movePrimary) : false;
};
int inline DrivigFlags()
{
return iDrivigFlags;
};
void MoveTo(TDynamicObject *to);
void DirectionInitial();
AnsiString TableText(int i);

View File

@@ -54,7 +54,7 @@ void TAnimPant::AKP_4E()
fLenL1 = 1.22; // 1.176289 w modelach
fLenU1 = 1.755; // 1.724482197 w modelach
fHoriz = 0.535; // 0.54555075 przesunięcie ślizgu w długości pojazdu względem osi obrotu dolnego
// ramienia
// ramienia
fHeight = 0.07; // wysokość ślizgu ponad oś obrotu
fWidth = 0.635; // połowa szerokości ślizgu, 0.635 dla AKP-1 i AKP-4E
fAngleL0 = DegToRad(2.8547285515689267247882521833308);
@@ -68,7 +68,7 @@ void TAnimPant::AKP_4E()
hvPowerWire = NULL;
fWidthExtra = 0.381; //(2.032m-1.027)/2
// poza obszarem roboczym jest aproksymacja łamaną o 5 odcinkach
fHeightExtra[0] = 0.0; //+0.0762
fHeightExtra[0] = 0.0; //+0.0762
fHeightExtra[1] = -0.01; //+0.1524
fHeightExtra[2] = -0.03; //+0.2286
fHeightExtra[3] = -0.07; //+0.3048
@@ -131,7 +131,8 @@ TAnim::~TAnim()
break;
}
};
void TAnim::Parovoz(){// animowanie tłoka i rozrządu parowozu
void TAnim::Parovoz(){
// animowanie tłoka i rozrządu parowozu
};
//---------------------------------------------------------------------------
TDynamicObject *__fastcall TDynamicObject::FirstFind(int &coupler_nr)
@@ -288,7 +289,10 @@ TDynamicObject* TDynamicObject::GetFirstCabDynamic(int cpl_type)
};
*/
void TDynamicObject::ABuSetModelShake(vector3 mShake) { modelShake = mShake; };
void TDynamicObject::ABuSetModelShake(vector3 mShake)
{
modelShake = mShake;
};
int TDynamicObject::GetPneumatic(bool front, bool red)
{
@@ -413,7 +417,7 @@ void TDynamicObject::UpdateDoorRotate(TAnim *pAnim)
{ // animacja drzwi - obrót
if (pAnim->smAnimated)
{ // if (MoverParameters->DoorOpenMethod==2) //obrotowe albo dwójłomne (trzeba kombinowac
// submodelami i ShiftL=90,R=180)
// submodelami i ShiftL=90,R=180)
if (pAnim->iNumber & 1)
pAnim->smAnimated->SetRotate(float3(1, 0, 0), dDoorMoveR);
else
@@ -425,7 +429,7 @@ void TDynamicObject::UpdateDoorFold(TAnim *pAnim)
{ // animacja drzwi - obrót
if (pAnim->smAnimated)
{ // if (MoverParameters->DoorOpenMethod==2) //obrotowe albo dwójłomne (trzeba kombinowac
// submodelami i ShiftL=90,R=180)
// submodelami i ShiftL=90,R=180)
if (pAnim->iNumber & 1)
{
pAnim->smAnimated->SetRotate(float3(0, 0, 1), dDoorMoveR);
@@ -849,7 +853,7 @@ void __inline TDynamicObject::ABuLittleUpdate(double ObjSqrDist)
}
if (MoverParameters->Battery)
{ // sygnały czoła pociagu //Ra: wyświetlamy bez ograniczeń odległości, by były widoczne z
// daleka
// daleka
if (TestFlag(iLights[0], 1))
{
btHeadSignals11.TurnOn();
@@ -899,7 +903,7 @@ TDynamicObject *__fastcall TDynamicObject::ABuFindNearestObject(TTrack *Track,
TDynamicObject *MyPointer,
int &CouplNr)
{ // zwraca wskaznik do obiektu znajdujacego sie na torze (Track), którego sprzęg jest najblizszy
// kamerze
// kamerze
// służy np. do łączenia i rozpinania sprzęgów
// WE: Track - tor, na ktorym odbywa sie poszukiwanie
// MyPointer - wskaznik do obiektu szukajacego
@@ -926,7 +930,7 @@ TDynamicObject *__fastcall TDynamicObject::ABuFindNearestObject(TTrack *Track,
{ // wektor [kamera-sprzeg0], potem [kamera-sprzeg1]
// Powinno byc wyliczone, ale nie zaszkodzi drugi raz:
//(bo co, jesli nie wykonuje sie obrotow wozkow?) - Ra: ale zawsze są liczone
//współrzędne sprzęgów
// współrzędne sprzęgów
// Track->Dynamics[i]->modelRot.z=ABuAcos(Track->Dynamics[i]->Axle0.pPosition-Track->Dynamics[i]->Axle1.pPosition);
// poz=Track->Dynamics[i]->vPosition; //pozycja środka pojazdu
// kon=vector3( //położenie przodu względem środka
@@ -1101,7 +1105,7 @@ TDynamicObject *__fastcall TDynamicObject::ABuFindObject(TTrack *Track, int Scan
0; // to, bo (ScanDir>=0)
if (Track->iCategoryFlag & 254) // trajektoria innego typu niż tor kolejowy
{ // dla torów nie ma sensu tego sprawdzać, rzadko co jedzie po jednej
// szynie i się mija
// szynie i się mija
// Ra: mijanie samochodów wcale nie jest proste
// Przesuniecie wzgledne pojazdow. Wyznaczane, zeby sprawdzic,
// czy pojazdy faktycznie sie zderzaja (moga byc przesuniete
@@ -1120,7 +1124,7 @@ TDynamicObject *__fastcall TDynamicObject::ABuFindObject(TTrack *Track, int Scan
if (RelOffsetH + RelOffsetH >
MoverParameters->Dim.W + Track->Dynamics[i]->MoverParameters->Dim.W)
continue; // odległość większa od połowy sumy szerokości - kolizji
// nie będzie
// nie będzie
// jeśli zahaczenie jest niewielkie, a jest miejsce na poboczu, to
// zjechać na pobocze
}
@@ -1147,7 +1151,7 @@ TDynamicObject *__fastcall TDynamicObject::ABuFindObject(TTrack *Track, int Scan
1; // odwrotnie, bo (ScanDir<0)
if (Track->iCategoryFlag & 254) // trajektoria innego typu niż tor kolejowy
{ // dla torów nie ma sensu tego sprawdzać, rzadko co jedzie po jednej
// szynie i się mija
// szynie i się mija
// Ra: mijanie samochodów wcale nie jest proste
// Przesunięcie względne pojazdów. Wyznaczane, żeby sprawdzić,
// czy pojazdy faktycznie się zderzają (mogą być przesunięte
@@ -1166,7 +1170,7 @@ TDynamicObject *__fastcall TDynamicObject::ABuFindObject(TTrack *Track, int Scan
if (RelOffsetH + RelOffsetH >
MoverParameters->Dim.W + Track->Dynamics[i]->MoverParameters->Dim.W)
continue; // odległość większa od połowy sumy szerokości - kolizji
// nie będzie
// nie będzie
}
iMinDist = i; // potencjalna kolizja
MinDist = TestDist; // odleglość pomiędzy aktywnymi osiami pojazdów
@@ -1175,7 +1179,7 @@ TDynamicObject *__fastcall TDynamicObject::ABuFindObject(TTrack *Track, int Scan
}
}
dist += MinDist; // doliczenie odległości przeszkody albo długości odcinka do przeskanowanej
// odległości
// odległości
return (iMinDist >= 0) ? Track->Dynamics[iMinDist] : NULL;
}
dist += Track->Length(); // doliczenie długości odcinka do przeskanowanej odległości
@@ -1227,7 +1231,7 @@ void TDynamicObject::CouplersDettach(double MinDist, int MyScanDir)
if ((PrevConnectedNo ? PrevConnected->NextConnected :
PrevConnected->PrevConnected) == this)
{ // Ra: nie rozłączamy znalezionego, jeżeli nie do nas podłączony (może jechać w
// innym kierunku)
// innym kierunku)
PrevConnected->MoverParameters->Couplers[PrevConnectedNo].Connected = NULL;
if (PrevConnectedNo == 0)
{
@@ -1257,7 +1261,7 @@ void TDynamicObject::CouplersDettach(double MinDist, int MyScanDir)
if ((NextConnectedNo ? NextConnected->NextConnected :
NextConnected->PrevConnected) == this)
{ // Ra: nie rozłączamy znalezionego, jeżeli nie do nas podłączony (może jechać w
// innym kierunku)
// innym kierunku)
NextConnected->MoverParameters->Couplers[NextConnectedNo].Connected = NULL;
if (NextConnectedNo == 0)
{
@@ -1289,7 +1293,7 @@ void TDynamicObject::ABuScanObjects(int ScanDir, double ScanDist)
FirstAxle->GetTrack(); // tor na którym "stoi" skrajny wózek (może być inny niż tor pojazdu)
if (FirstAxle->GetDirection() < 0) // czy oś jest ustawiona w stronę Point1?
ScanDir = -ScanDir; // jeśli tak, to kierunek szukania będzie przeciwny (teraz względem
// toru)
// toru)
Byte MyCouplFound; // numer sprzęgu do podłączenia w obiekcie szukajacym
MyCouplFound = (MyScanDir < 0) ? 1 : 0;
Byte CouplFound; // numer sprzęgu w znalezionym obiekcie (znaleziony wypełni)
@@ -1511,7 +1515,7 @@ TDynamicObject::TDynamicObject()
cp1 = cp2 = sp1 = sp2 = 0;
iDirection = 1; // stoi w kierunku tradycyjnym (0, gdy jest odwrócony)
iAxleFirst = 0; // numer pierwszej osi w kierunku ruchu (przełączenie następuje, gdy osie sa na
// tym samym torze)
// tym samym torze)
iInventory = 0; // flagi bitowe posiadanych submodeli (zaktualizuje się po wczytaniu MMD)
RaLightsSet(0, 0); // początkowe zerowanie stanu świateł
// Ra: domyślne ilości animacji dla zgodności wstecz (gdy brak ilości podanych w MMD)
@@ -1536,7 +1540,7 @@ TDynamicObject::TDynamicObject()
fScanDist = 300.0; // odległość skanowania, zwiększana w trybie łączenia
ctOwner = NULL; // na początek niczyj
iOverheadMask = 0; // maska przydzielana przez AI pojazdom posiadającym pantograf, aby wymuszały
// jazdę bezprądową
// jazdę bezprądową
tmpTraction.TractionVoltage =
0; // Ra 2F1H: prowizorka, trzeba przechować napięcie, żeby nie wywalało WS pod izolatorem
fAdjustment = 0.0; // korekcja odległości pomiędzy wózkami (np. na łukach)
@@ -1651,7 +1655,7 @@ double TDynamicObject::Init(
int dlugosc = MoreParams.Length();
ActPar = MoreParams.SubString(1, kropka - 1).UpperCase(); // pierwszy parametr;
MoreParams = MoreParams.SubString(kropka + 1, dlugosc - kropka); // reszta do dalszej
// obrobki
// obrobki
kropka = MoreParams.Pos(".");
if (ActPar.SubString(1, 1) == "B") // jesli hamulce
@@ -1780,13 +1784,13 @@ double TDynamicObject::Init(
{ // ustawianie samochodow na poboczu albo na środku drogi
if (Track->fTrackWidth < 3.5) // jeśli droga wąska
MoverParameters->OffsetTrackH = 0.0; // to stawiamy na środku, niezależnie od stanu
// ruchu
// ruchu
else if (driveractive) // od 3.5m do 8.0m jedzie po środku pasa, dla szerszych w odległości
// 1.5m
// 1.5m
MoverParameters->OffsetTrackH =
Track->fTrackWidth <= 8.0 ? -Track->fTrackWidth * 0.25 : -1.5;
else // jak stoi, to kołem na poboczu i pobieramy szerokość razem z poboczem, ale nie z
// chodnikiem
// chodnikiem
MoverParameters->OffsetTrackH =
-0.5 * (Track->WidthTotal() - MoverParameters->Dim.W) + 0.05;
iHornWarning = 0; // nie będzie trąbienia po podaniu zezwolenia na jazdę
@@ -1889,7 +1893,7 @@ double TDynamicObject::Init(
smBuforPrawy[i]->WillBeAnimated();
}
for (int i = 0; i < iAxles; i++) // wyszukiwanie osi (0 jest na końcu, dlatego dodajemy
// długość?)
// długość?)
dRailPosition[i] =
(Reversed ? -dWheelsPosition[i] : (dWheelsPosition[i] + MoverParameters->Dim.L)) +
fDist;
@@ -1943,7 +1947,7 @@ double TDynamicObject::Init(
break;
}
Move(0.0001); // potrzebne do wyliczenia aktualnej pozycji; nie może być zero, bo nie przeliczy
// pozycji
// pozycji
// teraz jeszcze trzeba przypisać pojazdy do nowego toru, bo przesuwanie początkowe osi nie
// zrobiło tego
ABuCheckMyTrack(); // zmiana toru na ten, co oś Axle0 (oś z przodu)
@@ -2009,11 +2013,11 @@ void TDynamicObject::Move(double fDistance)
bEnabled &= Axle1.Move(fDistance, iAxleFirst); // oś z tyłu pojazdu prusza się pierwsza
bEnabled &= Axle0.Move(fDistance /*-fAdjustment*/, !iAxleFirst); // oś z przodu pojazdu
}
else //gf: bez wywolania Move na postoju nie ma event0
{
bEnabled&=Axle1.Move(fDistance,iAxleFirst); //oś z tyłu pojazdu prusza się pierwsza
bEnabled&=Axle0.Move(fDistance,!iAxleFirst); //oś z przodu pojazdu
}
else // gf: bez wywolania Move na postoju nie ma event0
{
bEnabled &= Axle1.Move(fDistance, iAxleFirst); // oś z tyłu pojazdu prusza się pierwsza
bEnabled &= Axle0.Move(fDistance, !iAxleFirst); // oś z przodu pojazdu
}
if (fDistance != 0.0) // nie liczyć ponownie, jeśli stoi
{ // liczenie pozycji pojazdu tutaj, bo jest używane w wielu miejscach
vPosition = 0.5 * (Axle1.pPosition + Axle0.pPosition); //środek między skrajnymi osiami
@@ -2049,7 +2053,7 @@ void TDynamicObject::Move(double fDistance)
}
mMatrix.Identity(); // to też można by od razu policzyć, ale potrzebne jest do wyświetlania
mMatrix.BasisChange(vLeft, vUp, vFront); // przesuwanie jest jednak rzadziej niż
// renderowanie
// renderowanie
mMatrix =
Inverse(mMatrix); // wyliczenie macierzy dla pojazdu (potrzebna tylko do wyświetlania?)
// if (MoverParameters->CategoryFlag&2)
@@ -2076,7 +2080,7 @@ void TDynamicObject::Move(double fDistance)
TTrack *t0 = Axle0.GetTrack(); // już po przesunięciu
TTrack *t1 = Axle1.GetTrack();
if ((t0->eEnvironment == e_flat) && (t1->eEnvironment == e_flat)) // może być
// e_bridge...
// e_bridge...
fShade = 0.0; // standardowe oświetlenie
else
{ // jeżeli te tory mają niestandardowy stopień zacienienia (e_canyon, e_tunnel)
@@ -2171,11 +2175,11 @@ void TDynamicObject::AttachPrev(TDynamicObject *Object, int iType)
if ((MoverParameters->Power < 1.0) &&
(Object->MoverParameters->Power > 1.0)) // my nie mamy mocy, ale ten drugi ma
iLights = Object->MoverParameters->iLights; // to w tym z mocą będą światła
// załączane, a w tym bez tylko widoczne
// załączane, a w tym bez tylko widoczne
else if ((MoverParameters->Power > 1.0) &&
(Object->MoverParameters->Power < 1.0)) // my mamy moc, ale ten drugi nie ma
Object->iLights = MoverParameters->iLights; // to w tym z mocą będą światła
// załączane, a w tym bez tylko widoczne
// załączane, a w tym bez tylko widoczne
return;
// SetPneumatic(1,1); //Ra: to i tak się nie wykonywało po return
// SetPneumatic(1,0);
@@ -2337,10 +2341,10 @@ bool TDynamicObject::Update(double dt, double dt1)
// if ((!MoverParameters->PantCompFlag)&&(MoverParameters->CompressedVolume>=2.8))
// MoverParameters->PantVolume=MoverParameters->CompressedVolume;
if (MoverParameters->PantPress < (MoverParameters->TrainType == dt_EZT ? 2.4 : 3.5))
{ // 3.5 wg http://www.transportszynowy.pl/eu06-07pneumat.php
{ // 3.5 wg http://www.transportszynowy.pl/eu06-07pneumat.php
//"Wyłączniki ciśnieniowe odbieraków prądu wyłączają sterowanie wyłącznika szybkiego
//oraz uniemożliwiają podniesienie odbieraków prądu, gdy w instalacji rozrządu
//ciśnienie spadnie poniżej wartości 3,5 bara."
// oraz uniemożliwiają podniesienie odbieraków prądu, gdy w instalacji rozrządu
// ciśnienie spadnie poniżej wartości 3,5 bara."
// Ra 2013-12: Niebugocław mówi, że w EZT podnoszą się przy 2.5
// if (!MoverParameters->PantCompFlag)
// MoverParameters->PantVolume=MoverParameters->CompressedVolume;
@@ -2375,7 +2379,7 @@ bool TDynamicObject::Update(double dt, double dt1)
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
// przechyłki
}
else
ts.R = 0.0;
@@ -2383,7 +2387,7 @@ bool TDynamicObject::Update(double dt, double dt1)
// Ra: składową pochylenia wzdłużnego mamy policzoną w jednostkowym wektorze vFront
ts.Len = 1.0; // Max0R(MoverParameters->BDist,MoverParameters->ADist);
ts.dHtrack = -vFront.y; // Axle1.pPosition.y-Axle0.pPosition.y; //wektor między skrajnymi osiami
// (!!!odwrotny)
// (!!!odwrotny)
ts.dHrail = (Axle1.GetRoll() + Axle0.GetRoll()) * 0.5; //średnia przechyłka pudła
// TTrackParam tp;
tp.Width = MyTrack->fTrackWidth;
@@ -2447,14 +2451,14 @@ bool TDynamicObject::Update(double dt, double dt1)
*/
NoVoltTime = NoVoltTime + dt;
if (NoVoltTime > 0.2) // jeśli brak zasilania dłużej niż 0.2 sekundy (25km/h pod
// izolatorem daje 0.15s)
// izolatorem daje 0.15s)
{ // Ra 2F1H: prowizorka, trzeba przechować napięcie, żeby nie wywalało WS pod
// izolatorem
// izolatorem
if (MoverParameters->Vel > 0.5) // jeśli jedzie
if (MoverParameters->PantFrontUp ||
MoverParameters->PantRearUp) // Ra 2014-07: doraźna blokada logowania
// zimnych lokomotyw - zrobić to trzeba
// inaczej
// zimnych lokomotyw - zrobić to trzeba
// inaczej
// if (NoVoltTime>0.02) //tu można ograniczyć czas rozłączenia
// if (DebugModeFlag) //logowanie nie zawsze
if (MoverParameters->Mains)
@@ -2744,7 +2748,7 @@ bool TDynamicObject::Update(double dt, double dt1)
if (pants[0].fParamPants->hvPowerWire &&
pants[1].fParamPants->hvPowerWire) // i oba podłączone do drutów
fPantCurrent = fCurrent * 0.5; // to dzielimy prąd równo na oba (trochę bez
// sensu, ale lepiej tak niż podwoić prąd)
// sensu, ale lepiej tak niż podwoić prąd)
for (int i = 0; i < iAnimType[ANIM_PANTS]; ++i)
{ // pętla po wszystkich pantografach
p = pants[i].fParamPants;
@@ -2780,7 +2784,7 @@ bool TDynamicObject::Update(double dt, double dt1)
(MoverParameters->PantRearVolt == 0.0))
sPantUp.Play(vol, 0, MechInside, vPosition);
if (p->hvPowerWire) // TODO: wyliczyć trzeba prąd przypadający na pantograf i
// wstawić do GetVoltage()
// wstawić do GetVoltage()
{
MoverParameters->PantFrontVolt =
p->hvPowerWire->VoltageGet(MoverParameters->Voltage, fPantCurrent);
@@ -2804,7 +2808,7 @@ bool TDynamicObject::Update(double dt, double dt1)
(MoverParameters->PantFrontVolt == 0.0))
sPantUp.Play(vol, 0, MechInside, vPosition);
if (p->hvPowerWire) // TODO: wyliczyć trzeba prąd przypadający na pantograf i
// wstawić do GetVoltage()
// wstawić do GetVoltage()
{
MoverParameters->PantRearVolt =
p->hvPowerWire->VoltageGet(MoverParameters->Voltage, fPantCurrent);
@@ -2833,7 +2837,7 @@ bool TDynamicObject::Update(double dt, double dt1)
{
if (PantDiff > 0.001) // jeśli nie dolega do drutu
{ // jeśli poprzednia wysokość jest mniejsza niż pożądana, zwiększyć kąt dolnego
// ramienia zgodnie z ciśnieniem
// ramienia zgodnie z ciśnieniem
if (pantspeedfactor >
0.55 * PantDiff) // 0.55 to około pochodna kąta po wysokości
k += 0.55 * PantDiff; // ograniczenie "skoku" w danej klatce
@@ -2889,7 +2893,7 @@ bool TDynamicObject::Update(double dt, double dt1)
{ // to coś wyłączało dźwięk silnika w ST43!
MoverParameters->ConverterFlag = false;
MoverParameters->CompressorFlag = false; // Ra: to jest wątpliwe - wyłączenie
// sprężarki powinno być w jednym miejscu!
// sprężarki powinno być w jednym miejscu!
}
}
}
@@ -3013,7 +3017,7 @@ bool TDynamicObject::Update(double dt, double dt1)
else
{
CouplCounter = 25; // a bezruch nie, ale trzeba zaktualizować odległość, bo zawalidroga może
// sobie pojechać
// sobie pojechać
}
if (MoverParameters->DerailReason > 0)
{
@@ -3366,7 +3370,7 @@ void TDynamicObject::RenderSounds()
if ((MoverParameters->DynamicBrakeFlag) && (MoverParameters->EnginePower > 0.1) &&
(MoverParameters->EngineType ==
ElectricSeriesMotor)) // Szociu - 29012012 - jeżeli uruchomiony jest hamulec
// elektrodynamiczny, odtwarzany jest dźwięk silnika
// elektrodynamiczny, odtwarzany jest dźwięk silnika
vol += 0.8;
if (enginevolume > 0.0001)
@@ -3601,7 +3605,7 @@ void TDynamicObject::RenderSounds()
if (MoverParameters->DoorClosureWarning)
{
if (MoverParameters->DepartureSignal) // NBMX sygnal odjazdu, MC: pod warunkiem ze jest
// zdefiniowane w chk
// zdefiniowane w chk
sDepartureSignal.TurnOn(MechInside, GetPosition());
else
sDepartureSignal.TurnOff(MechInside, GetPosition());
@@ -3755,7 +3759,7 @@ void TDynamicObject::RenderAlpha()
// McZapkie-250202
// wczytywanie pliku z danymi multimedialnymi (dzwieki)
void TDynamicObject::LoadMMediaFile(AnsiString BaseDir, AnsiString TypeName,
AnsiString ReplacableSkin)
AnsiString ReplacableSkin)
{
double dSDist;
TFileStream *fs;
@@ -3806,7 +3810,7 @@ void TDynamicObject::LoadMMediaFile(AnsiString BaseDir, AnsiString TypeName,
}
if ((i = asModel.Pos(",")) > 0)
{ // Ra 2015-01: może szukać przecinka w nazwie modelu, a po przecinku była by liczba
// tekstur?
// tekstur?
if (i < asModel.Length())
iMultiTex = asModel[i + 1] - '0';
if (iMultiTex < 0)
@@ -3866,7 +3870,7 @@ void TDynamicObject::LoadMMediaFile(AnsiString BaseDir, AnsiString TypeName,
if (!ReplacableSkin.IsEmpty())
{ // próba wycięcia trzeciej nazwy
iMultiTex = -4; // skoro zostało coś po kresce, to są co
// najmniej cztery
// najmniej cztery
ReplacableSkinID[-iMultiTex] =
TTexturesManager::GetTextureID(
NULL, NULL,
@@ -3902,7 +3906,7 @@ void TDynamicObject::LoadMMediaFile(AnsiString BaseDir, AnsiString TypeName,
Global::iDynamicFiltering);
if (ReplacableSkinID[4])
iMultiTex = 4; // jak są cztery, to blokujemy podmianę tekstury
// rozkładem
// rozkładem
}
}
}
@@ -3918,22 +3922,22 @@ void TDynamicObject::LoadMMediaFile(AnsiString BaseDir, AnsiString TypeName,
NULL, NULL, ReplacableSkin.c_str(), Global::iDynamicFiltering);
if (TTexturesManager::GetAlpha(ReplacableSkinID[1]))
iAlpha = 0x31310031; // tekstura -1 z kanałem alfa - nie renderować w cyklu
// nieprzezroczystych
// nieprzezroczystych
else
iAlpha = 0x30300030; // wszystkie tekstury nieprzezroczyste - nie renderować w
// cyklu przezroczystych
// cyklu przezroczystych
if (ReplacableSkinID[2])
if (TTexturesManager::GetAlpha(ReplacableSkinID[2]))
iAlpha |= 0x02020002; // tekstura -2 z kanałem alfa - nie renderować w cyklu
// nieprzezroczystych
// nieprzezroczystych
if (ReplacableSkinID[3])
if (TTexturesManager::GetAlpha(ReplacableSkinID[3]))
iAlpha |= 0x04040004; // tekstura -3 z kanałem alfa - nie renderować w cyklu
// nieprzezroczystych
// nieprzezroczystych
if (ReplacableSkinID[4])
if (TTexturesManager::GetAlpha(ReplacableSkinID[4]))
iAlpha |= 0x08080008; // tekstura -4 z kanałem alfa - nie renderować w cyklu
// nieprzezroczystych
// nieprzezroczystych
}
// Winger 040304 - ladowanie przedsionkow dla EZT
if (MoverParameters->TrainType == dt_EZT)
@@ -3984,7 +3988,7 @@ void TDynamicObject::LoadMMediaFile(AnsiString BaseDir, AnsiString TypeName,
str = Parser->GetNextSymbol().LowerCase();
if (str == AnsiString("animations:"))
{ // Ra: ustawienie ilości poszczególnych animacji - musi być jako pierwsze, inaczej
// ilości będą domyślne
// ilości będą domyślne
if (!pAnimations)
{ // jeśli nie ma jeszcze tabeli animacji, można odczytać nowe ilości
int co = 0, ile;
@@ -3992,7 +3996,7 @@ void TDynamicObject::LoadMMediaFile(AnsiString BaseDir, AnsiString TypeName,
do
{ // kolejne liczby to ilość animacj, -1 to znacznik końca
ile = Parser->GetNextSymbol().ToIntDef(-1); // ilość danego typu
// animacji
// animacji
// if (co==ANIM_PANTS)
// if (!Global::bLoadTraction)
// if (!DebugModeFlag) //w debugmode pantografy mają "niby działać"
@@ -4030,7 +4034,7 @@ void TDynamicObject::LoadMMediaFile(AnsiString BaseDir, AnsiString TypeName,
if (j == ANIM_PANTS) // zliczamy poprzednie animacje
if (!pants)
if (iAnimType[ANIM_PANTS]) // o ile jakieś pantografy są (a
// domyślnie są)
// domyślnie są)
pants = pAnimations +
k; // zapamiętanie na potrzeby wyszukania submodeli
pAnimations[k].iShift = sm; // przesunięcie do przydzielenia wskaźnika
@@ -4082,7 +4086,7 @@ void TDynamicObject::LoadMMediaFile(AnsiString BaseDir, AnsiString TypeName,
if (pAnimations[i].smAnimated)
{ //++iAnimatedAxles;
pAnimations[i].smAnimated->WillBeAnimated(); // wyłączenie optymalizacji
// transformu
// transformu
pAnimations[i].yUpdate = UpdateAxle; // animacja osi
pAnimations[i].fMaxDist =
50 *
@@ -4092,8 +4096,8 @@ void TDynamicObject::LoadMMediaFile(AnsiString BaseDir, AnsiString TypeName,
MoverParameters
->WheelDiameter; // 50m do kwadratu, a średnica do trzeciej
pAnimations[i].fMaxDist *= Global::fDistanceFactor; // współczynnik
// przeliczeniowy
// jakości ekranu
// przeliczeniowy
// jakości ekranu
}
}
// Ra: ustawianie indeksów osi
@@ -4121,12 +4125,12 @@ void TDynamicObject::LoadMMediaFile(AnsiString BaseDir, AnsiString TypeName,
else if ((k >= '1') && (k <= '9'))
{
pAnimations[i++].dWheelAngle = dWheelAngle + m; // obrót osi
// tocznych
// tocznych
--k; // następna będzie albo taka sama, albo bierzemy kolejny znak
}
else
k = MoverParameters->AxleArangement[j++]; // pobranie kolejnego
// znaku
// znaku
}
}
}
@@ -4162,17 +4166,17 @@ void TDynamicObject::LoadMMediaFile(AnsiString BaseDir, AnsiString TypeName,
// m(3)[1]=m[3][1]+0.054; //w górę o wysokość ślizgu (na razie tak)
if ((mdModel->Flags() & 0x8000) == 0) // jeśli wczytano z T3D
m.InitialRotate(); // może być potrzebny dodatkowy obrót, jeśli
// wczytano z T3D, tzn. przed wykonaniem
// Init()
// wczytano z T3D, tzn. przed wykonaniem
// Init()
pants[i].fParamPants->vPos.z =
m[3][0]; // przesunięcie w bok (asymetria)
pants[i].fParamPants->vPos.y =
m[3][1]; // przesunięcie w górę odczytane z modelu
if ((sm = pants[i].smElement[0]->ChildGet()) != NULL)
{ // jeśli ma potomny, można policzyć długość (odległość potomnego
// od osi obrotu)
// od osi obrotu)
m = float4x4(*sm->GetMatrix()); // wystarczyłby wskaźnik, nie
// trzeba kopiować
// trzeba kopiować
// może trzeba: pobrać macierz dolnego ramienia, wyzerować
// przesunięcie, przemnożyć przez macierz górnego
pants[i].fParamPants->fHoriz = -fabs(m[3][1]);
@@ -4189,18 +4193,18 @@ void TDynamicObject::LoadMMediaFile(AnsiString BaseDir, AnsiString TypeName,
// pants[i].fParamPants->fAngleL0=pants[i].fParamPants->fAngleL;
pants[i].fParamPants->fAngleL =
pants[i].fParamPants->fAngleL0; // początkowy kąt dolnego
// ramienia
// ramienia
if ((sm = sm->ChildGet()) != NULL)
{ // jeśli dalej jest ślizg, można policzyć długość górnego
// ramienia
// ramienia
m = float4x4(*sm->GetMatrix()); // wystarczyłby wskaźnik,
// nie trzeba kopiować
// nie trzeba kopiować
// trzeba by uwzględnić macierz dolnego ramienia, żeby
// uzyskać kąt do poziomu...
pants[i].fParamPants->fHoriz +=
fabs(m(3)[1]); // różnica długości rzutów ramion na
// płaszczyznę podstawy (jedna dodatnia,
// druga ujemna)
// płaszczyznę podstawy (jedna dodatnia,
// druga ujemna)
pants[i].fParamPants->fLenU1 =
hypot(m[3][1], m[3][2]); // po osi OX nie potrzeba
// pants[i].fParamPants->pantu=acos((1.22*cos(pants[i].fParamPants->fAngleL)+0.535)/1.755);
@@ -4210,7 +4214,7 @@ void TDynamicObject::LoadMMediaFile(AnsiString BaseDir, AnsiString TypeName,
pants[i].fParamPants->fAngleU0 =
atan2(fabs(m[3][2]),
fabs(m[3][1])); // początkowy kąt górnego
// ramienia, odczytany z modelu
// ramienia, odczytany z modelu
// if (pants[i].fParamPants->fAngleU0<M_PI_2)
// pants[i].fParamPants->fAngleU0+=M_PI; //gdyby w odwrotną
// stronę wyszło
@@ -4225,25 +4229,25 @@ void TDynamicObject::LoadMMediaFile(AnsiString BaseDir, AnsiString TypeName,
// Ra: ze względu na to, że niektóre modele pantografów są
// zrąbane, ich mierzenie ma obecnie ograniczony sens
sm->ParentMatrix(&m); // pobranie macierzy transformacji
// pivota ślizgu względem wstawienia
// pojazdu
// pivota ślizgu względem wstawienia
// pojazdu
if ((mdModel->Flags() & 0x8000) == 0) // jeśli wczytano z
// T3D
// T3D
m.InitialRotate(); // może być potrzebny dodatkowy
// obrót, jeśli wczytano z T3D, tzn.
// przed wykonaniem Init()
// obrót, jeśli wczytano z T3D, tzn.
// przed wykonaniem Init()
float det = Det(m);
if (fabs(det - 1.0) < 0.001) // dopuszczamy 1 promil błędu
// na skalowaniu ślizgu
// na skalowaniu ślizgu
{ // skalowanie jest w normie, można pobrać wymiary z modelu
pants[i].fParamPants->fHeight =
sm->MaxY(m); // przeliczenie maksimum wysokości
// wierzchołków względem macierzy
// wierzchołków względem macierzy
pants[i].fParamPants->fHeight -=
m[3][1]; // odjęcie wysokości pivota ślizgu
pants[i].fParamPants->vPos.x =
m[3][2]; // przy okazji odczytać z modelu pozycję w
// długości
// długości
// ErrorLog("Model OK: "+asModel+",
// height="+pants[i].fParamPants->fHeight);
// ErrorLog("Model OK: "+asModel+",
@@ -4282,7 +4286,7 @@ void TDynamicObject::LoadMMediaFile(AnsiString BaseDir, AnsiString TypeName,
if (pants[i].fParamPants->vPos.y == 0.0)
{ // jeśli pierwsze ramię nie ustawiło tej wartości, próbować drugim
//!!!! docelowo zrobić niezależną animację ramion z każdej
//strony
// strony
m = float4x4(
*sm->GetMatrix()); // skopiowanie, bo będziemy mnożyć
m(3)[1] =
@@ -4345,7 +4349,7 @@ void TDynamicObject::LoadMMediaFile(AnsiString BaseDir, AnsiString TypeName,
double pant1x = Parser->GetNextSymbol().ToDouble();
double pant2x = Parser->GetNextSymbol().ToDouble();
double pant1h = Parser->GetNextSymbol().ToDouble(); // wysokość pierwszego
// ślizgu
// ślizgu
double pant2h = Parser->GetNextSymbol().ToDouble(); // wysokość drugiego ślizgu
if (pant1h > 0.5)
pant1h = pant2h; // tu może być zbyt duża wartość
@@ -4484,8 +4488,8 @@ void TDynamicObject::LoadMMediaFile(AnsiString BaseDir, AnsiString TypeName,
if (pAnimations[i + j].smAnimated)
{ //++iAnimatedDoors;
pAnimations[i + j].smAnimated->WillBeAnimated(); // wyłączenie
// optymalizacji
// transformu
// optymalizacji
// transformu
switch (MoverParameters->DoorOpenMethod)
{ // od razu zapinamy potrzebny typ animacji
case 1:
@@ -4557,7 +4561,7 @@ void TDynamicObject::LoadMMediaFile(AnsiString BaseDir, AnsiString TypeName,
((MoverParameters->EngineType == ElectricSeriesMotor) ||
(MoverParameters->EngineType ==
ElectricInductionMotor)))) // plik z dzwiekiem wentylatora, mnozniki i
// ofsety amp. i czest.
// ofsety amp. i czest.
{
str = Parser->GetNextSymbol();
rsWentylator.Init(str.c_str(), Parser->GetNextSymbol().ToDouble(),
@@ -4630,7 +4634,7 @@ void TDynamicObject::LoadMMediaFile(AnsiString BaseDir, AnsiString TypeName,
rsDerailment.FA = 0.0;
}
else if (str == AnsiString("dieselinc:")) // dzwiek przy wlazeniu na obroty
// woodwarda
// woodwarda
{
str = Parser->GetNextSymbol();
rsDiesielInc.Init(str.c_str(), Parser->GetNextSymbol().ToDouble(),
@@ -4769,7 +4773,7 @@ void TDynamicObject::RadioStop()
{ // zatrzymanie pojazdu
if (Mechanik) // o ile ktoś go prowadzi
if (MoverParameters->SecuritySystem.RadioStop) // jeśli pojazd ma RadioStop i jest on
// aktywny
// aktywny
Mechanik->PutCommand("Emergency_brake", 1.0, 1.0, &vPosition, stopRadio);
};
@@ -4828,7 +4832,7 @@ int TDynamicObject::DirectionSet(int d)
ABuScanObjects(-1, 300);
}
return 1 - (iDirection ? NextConnectedNo : PrevConnectedNo); // informacja o położeniu
// następnego
// następnego
};
TDynamicObject *__fastcall TDynamicObject::PrevAny()
@@ -4865,7 +4869,7 @@ double TDynamicObject::NextDistance(double d)
TDynamicObject *__fastcall TDynamicObject::Neightbour(int &dir)
{ // ustalenie następnego (1) albo poprzedniego (0) w składzie bez względu na prawidłowość
// iDirection
// iDirection
int d = dir; // zapamiętanie kierunku
dir = 1 - (dir ? NextConnectedNo : PrevConnectedNo); // nowa wartość
return (d ? (MoverParameters->Couplers[1].CouplingFlag ? NextConnected : NULL) :
@@ -4891,14 +4895,14 @@ void TDynamicObject::CoupleDist()
if (MoverParameters->Couplers[0].CouplingFlag == 0) // jeśli wirtualny
if (MoverParameters->Couplers[0].CoupleDist < 300.0) // i mniej niż 300m
{ // przez MoverParameters->Couplers[0].Connected nie da się dostać do DynObj, stąd
// prowizorka
// prowizorka
// WriteLog("Collision of
// "+AnsiString(MoverParameters->Couplers[0].CoupleDist)+"m detected by
// "+asName+":0.");
w = 0.5 * (MoverParameters->Couplers[0].Connected->Dim.W +
MoverParameters->Dim.W); // minimalna odległość minięcia
d = -DotProduct(vLeft, vCoulpler[0]); // odległość prostej ruchu od początku
// układu współrzędnych
// układu współrzędnych
d = fabs(
DotProduct(vLeft,
((TMoverParameters *)(MoverParameters->Couplers[0].Connected))
@@ -4919,7 +4923,7 @@ void TDynamicObject::CoupleDist()
w = 0.5 * (MoverParameters->Couplers[1].Connected->Dim.W +
MoverParameters->Dim.W); // minimalna odległość minięcia
d = -DotProduct(vLeft, vCoulpler[1]); // odległość prostej ruchu od początku
// układu współrzędnych
// układu współrzędnych
d = fabs(
DotProduct(vLeft,
((TMoverParameters *)(MoverParameters->Couplers[1].Connected))
@@ -4935,7 +4939,7 @@ void TDynamicObject::CoupleDist()
TDynamicObject *__fastcall TDynamicObject::ControlledFind()
{ // taka proteza: chcę podłączyć kabinę EN57 bezpośrednio z silnikowym, aby nie robić tego przez
// ukrotnienie
// ukrotnienie
// drugi silnikowy i tak musi być ukrotniony, podobnie jak kolejna jednostka
// lepiej by było przesyłać komendy sterowania, co jednak wymaga przebudowy transmisji komend
// (LD)

View File

@@ -102,13 +102,13 @@ class TAnimPant
class TAnim
{ // klasa animowanej części pojazdu (koła, drzwi, pantografy, burty, napęd parowozu, siłowniki
// itd.)
// itd.)
public:
union
{
TSubModel *smAnimated; // animowany submodel (jeśli tylko jeden, np. oś)
TSubModel **smElement; // jeśli animowanych elementów jest więcej (pantograf, napęd
// parowozu)
// parowozu)
int iShift; // przesunięcie przed przydzieleniem wskaźnika
};
union
@@ -153,7 +153,7 @@ class TDynamicObject
TTrackFollower Axle0; // oś z przodu (od sprzęgu 0)
TTrackFollower Axle1; // oś z tyłu (od sprzęgu 1)
int iAxleFirst; // numer pierwszej osi w kierunku ruchu (oś wiążąca pojazd z torem i wyzwalająca
// eventy)
// eventy)
float fAxleDist; // rozstaw wózków albo osi do liczenia proporcji zacienienia
vector3 modelRot; // obrot pudła względem świata - do przeanalizowania, czy potrzebne!!!
// bool bCameraNear; //blisko kamer są potrzebne dodatkowe obliczenia szczegółów
@@ -189,7 +189,7 @@ class TDynamicObject
TSubModel **
pAnimated; // lista animowanych submodeli (może być ich więcej niż obiektów animujących)
double dWheelAngle[3]; // kąty obrotu kół: 0=przednie toczne, 1=napędzające i wiązary, 2=tylne
// toczne
// toczne
void
UpdateNone(TAnim *pAnim){}; // animacja pusta (funkcje ustawiania submodeli, gdy blisko kamery)
void UpdateAxle(TAnim *pAnim); // animacja osi
@@ -332,20 +332,32 @@ class TDynamicObject
public:
int *iLights; // wskaźnik na bity zapalonych świateł (własne albo innego członu)
double fTrackBlock; // odległość do przeszkody do dalszego ruchu (wykrywanie kolizji z innym
// pojazdem)
// pojazdem)
TDynamicObject *__fastcall PrevAny();
TDynamicObject *__fastcall Prev();
TDynamicObject *__fastcall Next();
TDynamicObject *__fastcall NextC(int C);
double NextDistance(double d = -1.0);
void SetdMoveLen(double dMoveLen) { MoverParameters->dMoveLen = dMoveLen; }
void ResetdMoveLen() { MoverParameters->dMoveLen = 0; }
double GetdMoveLen() { return MoverParameters->dMoveLen; }
void SetdMoveLen(double dMoveLen)
{
MoverParameters->dMoveLen = dMoveLen;
}
void ResetdMoveLen()
{
MoverParameters->dMoveLen = 0;
}
double GetdMoveLen()
{
return MoverParameters->dMoveLen;
}
int GetPneumatic(bool front, bool red);
void SetPneumatic(bool front, bool red);
AnsiString asName;
AnsiString GetName() { return this ? asName : AnsiString(""); };
AnsiString GetName()
{
return this ? asName : AnsiString("");
};
TRealSound rsDiesielInc; // youBy
TRealSound rscurve; // youBy
@@ -375,10 +387,10 @@ class TDynamicObject
int iAlpha; // maska przezroczystości tekstur
int iMultiTex; //<0 tekstury wskazane wpisem, >0 tekstury z przecinkami, =0 jedna
int iOverheadMask; // maska przydzielana przez AI pojazdom posiadającym pantograf, aby wymuszały
// jazdę bezprądową
// jazdę bezprądową
TTractionParam tmpTraction;
double fAdjustment; // korekcja - docelowo przenieść do TrkFoll.cpp wraz z odległością od
// poprzedniego
// poprzedniego
TDynamicObject();
~TDynamicObject();
double TDynamicObject::Init( // zwraca długość pojazdu albo 0, jeśli błąd
@@ -395,7 +407,10 @@ class TDynamicObject
void Render();
void RenderAlpha();
void RenderSounds();
inline vector3 GetPosition() { return vPosition; };
inline vector3 GetPosition()
{
return vPosition;
};
inline vector3 HeadPosition()
{
return vCoulpler[iDirection ^ 1];
@@ -408,13 +423,34 @@ class TDynamicObject
{
return iAxleFirst ? Axle1.pPosition : Axle0.pPosition;
};
inline vector3 VectorFront() { return vFront; };
inline vector3 VectorUp() { return vUp; };
inline vector3 VectorLeft() { return vLeft; };
inline double *__fastcall Matrix() { return mMatrix.getArray(); };
inline double GetVelocity() { return MoverParameters->Vel; };
inline double GetLength() { return MoverParameters->Dim.L; };
inline double GetWidth() { return MoverParameters->Dim.W; };
inline vector3 VectorFront()
{
return vFront;
};
inline vector3 VectorUp()
{
return vUp;
};
inline vector3 VectorLeft()
{
return vLeft;
};
inline double *__fastcall Matrix()
{
return mMatrix.getArray();
};
inline double GetVelocity()
{
return MoverParameters->Vel;
};
inline double GetLength()
{
return MoverParameters->Dim.L;
};
inline double GetWidth()
{
return MoverParameters->Dim.W;
};
inline TTrack *__fastcall GetTrack()
{
return (iAxleFirst ? Axle1.GetTrack() : Axle0.GetTrack());
@@ -422,8 +458,7 @@ class TDynamicObject
// void UpdatePos();
// McZapkie-260202
void LoadMMediaFile(AnsiString BaseDir, AnsiString TypeName,
AnsiString ReplacableSkin);
void LoadMMediaFile(AnsiString BaseDir, AnsiString TypeName, AnsiString ReplacableSkin);
inline double ABuGetDirection() // ABu.
{
@@ -463,7 +498,7 @@ class TDynamicObject
TDynamicObject *__fastcall ControlledFind();
void ParamSet(int what, int into);
int RouteWish(TTrack *tr); // zapytanie do AI, po którym segmencie skrzyżowania
// jechać
// jechać
void DestinationSet(AnsiString to);
AnsiString TextureTest(AnsiString &name);
void OverheadTrack(float o);

View File

@@ -13,13 +13,13 @@
TractionPower.obj parser.obj sky.obj AirCoupler.obj opengl\glew.obj
ResourceManager.obj VBO.obj TextureDDS.obj opengl\ARB_Multisample.obj
Float3d.obj Classes.obj Driver.obj Names.obj Console.obj Mover.obj
Console\PoKeys55.obj Forth.obj Console\LPT.obj"/>
Console\PoKeys55.obj Forth.obj Console\LPT.obj PyInt.obj"/>
<RESFILES value="EU07.res"/>
<IDLFILES value=""/>
<IDLGENFILES value=""/>
<DEFFILE value=""/>
<RESDEPEN value="$(RESFILES)"/>
<LIBFILES value="opengl\glut32.lib DirectX\Dsound.lib"/>
<LIBFILES value="opengl\glut32.lib omf_python27.lib DirectX\Dsound.lib"/>
<LIBRARIES value="dclocx50.bpi bcbsmp50.bpi VCLX50.lib bcbsmp50.lib Vcl50.lib"/>
<SPARELIBS value="Vcl50.lib bcbsmp50.lib VCLX50.lib bcbsmp50.bpi dclocx50.bpi"/>
<PACKAGES value="Vcl50.bpi Vclx50.bpi"/>
@@ -33,8 +33,8 @@
<USERDEFINES value="GLEW_STATIC;_DEBUG"/>
<SYSDEFINES value="NO_STRICT;_RTLDLL"/>
<MAINSOURCE value="EU07.cpp"/>
<INCLUDEPATH value="Console;opengl;McZapkie;$(BCB)\include;$(BCB)\include\vcl"/>
<LIBPATH value="Console;opengl;McZapkie;$(BCB)\lib\obj;$(BCB)\lib"/>
<INCLUDEPATH value="Console;opengl;McZapkie;$(BCB)\include;$(BCB)\include\vcl;python\include"/>
<LIBPATH value="Console;opengl;McZapkie;$(BCB)\lib\obj;$(BCB)\lib;python\libs"/>
<WARNINGS value="-w-par"/>
</MACROS>
<OPTIONS>
@@ -58,8 +58,8 @@ IncludeVerInfo=1
AutoIncBuild=0
MajorVer=15
MinorVer=3
Release=1167
Build=470
Release=1168
Build=471
Debug=1
PreRelease=0
Special=0
@@ -71,8 +71,8 @@ CodePage=1250
[Version Info Keys]
CompanyName=EU07 Team
FileDescription=MaSzyna EU07-424
FileVersion=15.3.1167.470
InternalName=9th by firleju + SPKS + MP
FileVersion=15.3.1168.471
InternalName=9th by firleju + SPKS + MP + python
LegalCopyright=
LegalTrademarks=
OriginalFilename=eu07.exe
@@ -81,12 +81,14 @@ ProductVersion=15.3
Comments=
[HistoryLists\hlIncludePath]
Count=1
Item0=Console;opengl;McZapkie;$(BCB)\include;$(BCB)\include\vcl
Count=2
Item0=Console;opengl;McZapkie;$(BCB)\include;$(BCB)\include\vcl;python\include
Item1=Console;opengl;McZapkie;$(BCB)\include;$(BCB)\include\vcl
[HistoryLists\hlLibraryPath]
Count=1
Item0=Console;opengl;McZapkie;$(BCB)\lib\obj;$(BCB)\lib
Count=2
Item0=Console;opengl;McZapkie;$(BCB)\lib\obj;$(BCB)\lib;python\libs
Item1=Console;opengl;McZapkie;$(BCB)\lib\obj;$(BCB)\lib
[HistoryLists\hlDebugSourcePath]
Count=2

131
EU07.cpp
View File

@@ -33,6 +33,7 @@ USEUNIT("Camera.cpp");
USEUNIT("Texture.cpp");
USEUNIT("World.cpp");
USELIB("opengl\glut32.lib");
USELIB("omf_python27.lib");
USEUNIT("Model3d.cpp");
USEUNIT("MdlMngr.cpp");
USEUNIT("Train.cpp");
@@ -80,10 +81,11 @@ USEUNIT("McZapkie\hamulce.pas");
USEUNIT("Console\PoKeys55.cpp");
USEUNIT("Forth.cpp");
USEUNIT("Console\LPT.cpp");
USEUNIT("PyInt.cpp");
//---------------------------------------------------------------------------
#include "World.h"
HDC hDC = NULL; // Private GDI Device Context
HDC hDC = NULL; // Private GDI Device Context
HGLRC hRC = NULL; // Permanent Rendering Context
HWND hWnd = NULL; // Holds Our Window Handle
@@ -122,15 +124,15 @@ GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // resize and initialize the
{
WindowWidth = width;
WindowHeight = height;
if (height == 0) // prevent a divide by zero by
height = 1; // making height equal one
if (height == 0) // prevent a divide by zero by
height = 1; // making height equal one
glViewport(0, 0, width, height); // Reset The Current Viewport
glMatrixMode(GL_PROJECTION); // select the Projection Matrix
glLoadIdentity(); // reset the Projection Matrix
glMatrixMode(GL_PROJECTION); // select the Projection Matrix
glLoadIdentity(); // reset the Projection Matrix
// calculate the aspect ratio of the window
gluPerspective(45.0f, (GLdouble)width / (GLdouble)height, 0.2f, 2500.0f);
glMatrixMode(GL_MODELVIEW); // select the Modelview Matrix
glLoadIdentity(); // reset the Modelview Matrix
glLoadIdentity(); // reset the Modelview Matrix
}
//---------------------------------------------------------------------------
@@ -172,7 +174,7 @@ GLvoid KillGLWindow(GLvoid) // properly kill the window
if (fullscreen) // Are We In Fullscreen Mode?
{
ChangeDisplaySettings(NULL, 0); // if so switch back to the desktop
ShowCursor(TRUE); // show mouse pointer
ShowCursor(TRUE); // show mouse pointer
}
// KillFont();
}
@@ -186,31 +188,31 @@ GLvoid KillGLWindow(GLvoid) // properly kill the window
BOOL CreateGLWindow(char *title, int width, int height, int bits, bool fullscreenflag)
{
GLuint PixelFormat; // holds the results after searching for a match
HINSTANCE hInstance; // holds the instance of the application
WNDCLASS wc; // windows class structure
DWORD dwExStyle; // window extended style
DWORD dwStyle; // window style
RECT WindowRect; // grabs rectangle upper left / lower right values
WindowRect.left = (long)0; // set left value to 0
WindowRect.right = (long)width; // set right value to requested width
WindowRect.top = (long)0; // set top value to 0
GLuint PixelFormat; // holds the results after searching for a match
HINSTANCE hInstance; // holds the instance of the application
WNDCLASS wc; // windows class structure
DWORD dwExStyle; // window extended style
DWORD dwStyle; // window style
RECT WindowRect; // grabs rectangle upper left / lower right values
WindowRect.left = (long)0; // set left value to 0
WindowRect.right = (long)width; // set right value to requested width
WindowRect.top = (long)0; // set top value to 0
WindowRect.bottom = (long)height; // set bottom value to requested height
fullscreen = fullscreenflag; // set the global fullscreen flag
hInstance = GetModuleHandle(NULL); // grab an instance for our window
hInstance = GetModuleHandle(NULL); // grab an instance for our window
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // redraw on size, and own DC for window.
wc.lpfnWndProc = (WNDPROC)WndProc; // wndproc handles messages
wc.cbClsExtra = 0; // no extra window data
wc.cbWndExtra = 0; // no extra window data
wc.hInstance = hInstance; // set the instance
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); // load the default icon
wc.hCursor = LoadCursor(NULL, IDC_ARROW); // load the arrow pointer
wc.hbrBackground = NULL; // no background required for GL
wc.lpszMenuName = NULL; // we don't want a menu
wc.lpfnWndProc = (WNDPROC)WndProc; // wndproc handles messages
wc.cbClsExtra = 0; // no extra window data
wc.cbWndExtra = 0; // no extra window data
wc.hInstance = hInstance; // set the instance
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); // load the default icon
wc.hCursor = LoadCursor(NULL, IDC_ARROW); // load the arrow pointer
wc.hbrBackground = NULL; // no background required for GL
wc.lpszMenuName = NULL; // we don't want a menu
wc.lpszClassName = "EU07"; // nazwa okna do komunikacji zdalnej
// // Set The Class Name
// // Set The Class Name
if (!arbMultisampleSupported) // tylko dla pierwszego okna
if (!RegisterClass(&wc)) // Attempt To Register The Window Class
@@ -223,9 +225,9 @@ BOOL CreateGLWindow(char *title, int width, int height, int bits, bool fullscree
if (fullscreen) // Attempt Fullscreen Mode?
{
DEVMODE dmScreenSettings; // device mode
DEVMODE dmScreenSettings; // device mode
memset(&dmScreenSettings, 0, sizeof(dmScreenSettings)); // makes sure memory's cleared
dmScreenSettings.dmSize = sizeof(dmScreenSettings); // size of the devmode structure
dmScreenSettings.dmSize = sizeof(dmScreenSettings); // size of the devmode structure
// tolaris-240403: poprawka na odswiezanie monitora
// locate primary monitor...
@@ -254,9 +256,9 @@ BOOL CreateGLWindow(char *title, int width, int height, int bits, bool fullscree
dmScreenSettings.dmDisplayFrequency = refreshrate;
dmScreenSettings.dmFields = DM_DISPLAYFREQUENCY;
}
dmScreenSettings.dmPelsWidth = width; // selected screen width
dmScreenSettings.dmPelsWidth = width; // selected screen width
dmScreenSettings.dmPelsHeight = height; // selected screen height
dmScreenSettings.dmBitsPerPel = bits; // selected bits per pixel
dmScreenSettings.dmBitsPerPel = bits; // selected bits per pixel
dmScreenSettings.dmFields =
dmScreenSettings.dmFields | DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
@@ -282,13 +284,13 @@ BOOL CreateGLWindow(char *title, int width, int height, int bits, bool fullscree
if (fullscreen) // Are We Still In Fullscreen Mode?
{
dwExStyle = WS_EX_APPWINDOW; // Window Extended Style
dwExStyle = WS_EX_APPWINDOW; // Window Extended Style
dwStyle = WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; // Windows Style
ShowCursor(FALSE); // Hide Mouse Pointer
ShowCursor(FALSE); // Hide Mouse Pointer
}
else
{
dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; // Window Extended Style
dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; // Window Extended Style
dwStyle = WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; // Windows Style
}
@@ -297,19 +299,19 @@ BOOL CreateGLWindow(char *title, int width, int height, int bits, bool fullscree
// Create The Window
if (NULL ==
(hWnd = CreateWindowEx(dwExStyle, // Extended Style For The Window
"EU07", // Class Name
title, // Window Title
dwStyle | // Defined Window Style
(hWnd = CreateWindowEx(dwExStyle, // Extended Style For The Window
"EU07", // Class Name
title, // Window Title
dwStyle | // Defined Window Style
WS_CLIPSIBLINGS | // Required Window Style
WS_CLIPCHILDREN, // Required Window Style
WS_CLIPCHILDREN, // Required Window Style
0,
0, // Window Position
0, // Window Position
WindowRect.right - WindowRect.left, // Calculate Window Width
WindowRect.bottom - WindowRect.top, // Calculate Window Height
NULL, // No Parent Window
NULL, // No Menu
hInstance, // Instance
NULL, // No Parent Window
NULL, // No Menu
hInstance, // Instance
NULL))) // Dont Pass Anything To WM_CREATE
{
KillGLWindow(); // Reset The Display
@@ -321,24 +323,24 @@ BOOL CreateGLWindow(char *title, int width, int height, int bits, bool fullscree
static PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be
{
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number
PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
PFD_DOUBLEBUFFER, // Must Support Double Buffering
PFD_TYPE_RGBA, // Request An RGBA Format
bits, // Select Our Color Depth
1, // Version Number
PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
PFD_DOUBLEBUFFER, // Must Support Double Buffering
PFD_TYPE_RGBA, // Request An RGBA Format
bits, // Select Our Color Depth
0,
0, 0, 0, 0, 0, // Color Bits Ignored
0, // No Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
24, // 32Bit Z-Buffer (Depth Buffer)
0, // No Stencil Buffer
0, // No Auxiliary Buffer
0, 0, 0, 0, 0, // Color Bits Ignored
0, // No Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
24, // 32Bit Z-Buffer (Depth Buffer)
0, // No Stencil Buffer
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
0, // Reserved
0, 0, 0 // Layer Masks Ignored
};
if (NULL == (hDC = GetDC(hWnd))) // Did We Get A Device Context?
@@ -413,9 +415,9 @@ BOOL CreateGLWindow(char *title, int width, int height, int bits, bool fullscree
return CreateGLWindow(title, width, height, bits, fullscreenflag); // rekurencja
}
ShowWindow(hWnd, SW_SHOW); // show the window
SetForegroundWindow(hWnd); // slightly higher priority
SetFocus(hWnd); // sets keyboard focus to the window
ShowWindow(hWnd, SW_SHOW); // show the window
SetForegroundWindow(hWnd); // slightly higher priority
SetFocus(hWnd); // sets keyboard focus to the window
ReSizeGLScene(width, height); // set up our perspective GL screen
if (!InitGL()) // initialize our newly created GL Window
@@ -579,7 +581,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, // handle for this window
}
case WM_MOVE: // przesuwanie okna?
{
mx = WindowWidth / 2 + LOWORD(lParam); // horizontal position
mx = WindowWidth / 2 + LOWORD(lParam); // horizontal position
my = WindowHeight / 2 + HIWORD(lParam); // vertical position
// SetCursorPos(mx,my);
break;
@@ -739,7 +741,7 @@ int WINAPI WinMain(HINSTANCE hInstance, // instance
// DrawGLScene()
// if (!pause)
// if (Global::bInactivePause?Global::bActive:true) //tak nie, bo spada z góry
if (World.Update()) // Was There A Quit Received?
if (World.Update()) // Was There A Quit Received?
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
else
done = true; //[F10] or DrawGLScene signalled a quit
@@ -754,6 +756,3 @@ int WINAPI WinMain(HINSTANCE hInstance, // instance
KillGLWindow(); // kill the window
return (msg.wParam); // exit the program
}

BIN
EU07.res

Binary file not shown.

View File

@@ -43,9 +43,14 @@ TEventLauncher::TEventLauncher()
iCheckMask = 0;
}
TEventLauncher::~TEventLauncher() { SafeDeleteArray(szText); }
TEventLauncher::~TEventLauncher()
{
SafeDeleteArray(szText);
}
void TEventLauncher::Init() {}
void TEventLauncher::Init()
{
}
bool TEventLauncher::Load(cParser *parser)
{ // wczytanie wyzwalacza zdarzeñ

View File

@@ -31,7 +31,7 @@ TEvent::TEvent(AnsiString m)
// asName=""; //czy nazwa eventu jest niezbêdna w tym przypadku? chyba nie
evNext = evNext2 = NULL;
bEnabled = false; // false dla eventów u¿ywanych do skanowania sygna³ów (nie dodawane do
// kolejki)
// kolejki)
asNodeName = m; // nazwa obiektu powi¹zanego
iQueued = 0; // nie zosta³ dodany do kolejki
// bIsHistory=false;
@@ -91,7 +91,7 @@ void TEvent::Conditions(cParser *parser, AnsiString s)
if (!asNodeName.IsEmpty())
{ // podczepienie ³añcucha, jeœli nie jest pusty
Params[9].asText = new char[asNodeName.Length() + 1]; // usuwane i zamieniane na
// wskaŸnik
// wskaŸnik
strcpy(Params[9].asText, asNodeName.c_str());
}
parser->getTokens();
@@ -313,7 +313,7 @@ void TEvent::Load(cParser *parser, vector3 *org)
case tp_PutValues:
parser->getTokens(3);
*parser >> Params[3].asdouble >> Params[4].asdouble >> Params[5].asdouble; // po³o¿enie
// X,Y,Z
// X,Y,Z
if (org)
{ // przesuniêcie
// tmp->pCenter.RotateY(aRotate.y/180.0*M_PI); //Ra 2014-11: uwzglêdnienie rotacji
@@ -330,7 +330,7 @@ void TEvent::Load(cParser *parser, vector3 *org)
if (str.Pos("#"))
str = str.SubString(1, str.Pos("#") - 1); // obciêcie unikatowoœci
bEnabled = false; // nie do kolejki (dla SetVelocity te¿, ale jak jest do toru
// dowi¹zany)
// dowi¹zany)
Params[6].asCommand = cm_PassengerStopPoint;
}
else if (str == "SetVelocity")

View File

@@ -27,9 +27,14 @@ TFadeSound::TFadeSound()
fTime = 0;
}
TFadeSound::~TFadeSound() { Free(); }
TFadeSound::~TFadeSound()
{
Free();
}
void TFadeSound::Free() {}
void TFadeSound::Free()
{
}
void TFadeSound::Init(char *Name, float fNewFade)
{
@@ -47,7 +52,10 @@ void TFadeSound::TurnOn()
fTime = fFade;
}
void TFadeSound::TurnOff() { State = ss_ShuttingDown; }
void TFadeSound::TurnOff()
{
State = ss_ShuttingDown;
}
void TFadeSound::Update()
{

View File

@@ -26,7 +26,10 @@ class TFadeSound
void Init(char *Name, float fNewFade);
void TurnOn();
void TurnOff();
bool Playing() { return (State == ss_Commencing || State == ss_Starting); };
bool Playing()
{
return (State == ss_Commencing || State == ss_Starting);
};
void Free();
void Update();
void Volume(long vol);

View File

@@ -37,7 +37,10 @@ inline float3 &operator+=(float3 &v1, const float3 &v2)
v1.z += v2.z;
return v1;
};
inline float3 operator-(const float3 &v) { return float3(-v.x, -v.y, -v.z); };
inline float3 operator-(const float3 &v)
{
return float3(-v.x, -v.y, -v.z);
};
inline float3 operator-(const float3 &v1, const float3 &v2)
{
return float3(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
@@ -46,8 +49,14 @@ inline float3 operator+(const float3 &v1, const float3 &v2)
{
return float3(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z);
};
double inline float3::Length() const { return sqrt(x * x + y * y + z * z); };
inline float3 operator/(const float3 &v, double k) { return float3(v.x / k, v.y / k, v.z / k); };
double inline float3::Length() const
{
return sqrt(x * x + y * y + z * z);
};
inline float3 operator/(const float3 &v, double k)
{
return float3(v.x / k, v.y / k, v.z / k);
};
inline float3 SafeNormalize(const float3 &v)
{ // bezpieczna normalizacja (wektor d³ugoœci 1.0)
double l = v.Length();
@@ -79,8 +88,14 @@ class float4
z = c;
w = d;
};
double inline float4::LengthSquared() const { return x * x + y * y + z * z + w * w; };
double inline float4::Length() const { return sqrt(x * x + y * y + z * z + w * w); };
double inline float4::LengthSquared() const
{
return x * x + y * y + z * z + w * w;
};
double inline float4::Length() const
{
return sqrt(x * x + y * y + z * z + w * w);
};
};
inline float4 operator*(const float4 &q1, const float4 &q2)
{ // mno¿enie to prawie jak mno¿enie macierzy
@@ -177,15 +192,24 @@ class float4x4
for (int i = 0; i < 16; ++i)
e[i] = f[i];
};
float *__fastcall operator()(int i) { return &e[i << 2]; }
const float *__fastcall readArray(void) { return e; }
float *__fastcall operator()(int i)
{
return &e[i << 2];
}
const float *__fastcall readArray(void)
{
return e;
}
void Identity()
{
for (int i = 0; i < 16; ++i)
e[i] = 0;
e[0] = e[5] = e[10] = e[15] = 1.0f;
}
const float *operator[](int i) const { return &e[i << 2]; };
const float *operator[](int i) const
{
return &e[i << 2];
};
void InitialRotate()
{ // taka specjalna rotacja, nie ma co ci¹gaæ trygonometrii
float f;
@@ -206,7 +230,10 @@ class float4x4
return true;
}
void Quaternion(float4 *q);
inline float3 *TranslationGet() { return (float3 *)(e + 12); }
inline float3 *TranslationGet()
{
return (float3 *)(e + 12);
}
};
inline float3 operator*(const float4x4 &m, const float3 &v)

View File

@@ -46,8 +46,8 @@ void TGauge::Clear()
fDesiredValue = 0;
};
void TGauge::Init(TSubModel *NewSubModel, TGaugeType eNewType, double fNewScale,
double fNewOffset, double fNewFriction, double fNewValue)
void TGauge::Init(TSubModel *NewSubModel, TGaugeType eNewType, double fNewScale, double fNewOffset,
double fNewFriction, double fNewValue)
{ // ustawienie parametrów animacji submodelu
if (NewSubModel)
{ // warunek na wszelki wypadek, gdyby siê submodel nie pod³¹czy³
@@ -168,7 +168,7 @@ void TGauge::Update()
case gt_Digital: // Ra 2014-07: licznik cyfrowy
sm = SubModel->ChildGet();
AnsiString n = FormatFloat("0000000000", floor(fValue)); // na razie tak trochê bez
// sensu
// sensu
do
{ // pêtla po submodelach potomnych i obracanie ich o k¹t zale¿y od cyfry w (fValue)
if (sm->pName)

12
Gauge.h
View File

@@ -22,7 +22,7 @@ typedef enum
gt_Rotate, // obrót
gt_Move, // przesuniêcie równoleg³e
gt_Wiper, // obrót trzech kolejnych submodeli o ten sam k¹t (np. wycieraczka, drzwi
// harmonijkowe)
// harmonijkowe)
gt_Digital // licznik cyfrowy, np. kilometrów
} TGaugeType;
@@ -49,15 +49,17 @@ class TGauge // zmienne "gg"
~TGauge();
void Clear();
void Init(TSubModel *NewSubModel, TGaugeType eNewTyp, double fNewScale = 1,
double fNewOffset = 0, double fNewFriction = 0, double fNewValue = 0);
bool Load(TQueryParserComp *Parser, TModel3d *md1, TModel3d *md2 = NULL,
double mul = 1.0);
double fNewOffset = 0, double fNewFriction = 0, double fNewValue = 0);
bool Load(TQueryParserComp *Parser, TModel3d *md1, TModel3d *md2 = NULL, double mul = 1.0);
void PermIncValue(double fNewDesired);
void IncValue(double fNewDesired);
void DecValue(double fNewDesired);
void UpdateValue(double fNewDesired);
void PutValue(double fNewDesired);
float GetValue() { return fValue; };
float GetValue()
{
return fValue;
};
void Update();
void Render();
void AssignFloat(float *fValue);

View File

@@ -19,11 +19,17 @@ http://mozilla.org/MPL/2.0/.
#include "Globals.h"
#include "Geom.h"
__fastcall TGeometry::TGeometry() {}
__fastcall TGeometry::TGeometry()
{
}
__fastcall TGeometry::~TGeometry() {}
__fastcall TGeometry::~TGeometry()
{
}
bool TGeometry::Init() {}
bool TGeometry::Init()
{
}
vector3 TGeometry::Load(TQueryParserComp *Parser)
{
@@ -113,7 +119,9 @@ vector3 TGeometry::Load(TQueryParserComp *Parser)
tmp->fSquareRadius += r;
}
bool TGeometry::Render() {}
bool TGeometry::Render()
{
}
//---------------------------------------------------------------------------
#pragma package(smart_init)

View File

@@ -49,9 +49,9 @@ double Global::fLuminance = 1.0; // jasno
int Global::iReCompile = 0; // zwiêkszany, gdy trzeba odœwie¿yæ siatki
HWND Global::hWnd = NULL; // uchwyt okna
int Global::iCameraLast = -1;
AnsiString Global::asRelease = "15.3.1167.470";
AnsiString Global::asRelease = "15.3.1168.471";
AnsiString Global::asVersion =
"Compilation 2015-04-14, release " + Global::asRelease + "."; // tutaj, bo wysy³any
"Compilation 2015-04-17, release " + Global::asRelease + "."; // tutaj, bo wysy³any
int Global::iViewMode = 0; // co aktualnie widaæ: 0-kabina, 1-latanie, 2-sprzêgi, 3-dokumenty
int Global::iTextMode = 0; // tryb pracy wyœwietlacza tekstowego
int Global::iScreenMode[12] = {0, 0, 0, 0, 0, 0,
@@ -263,16 +263,16 @@ void Global::ConfigParse(TQueryParserComp *qp, cParser *cp)
else if (str == AnsiString("wireframe"))
bWireFrame = (GetNextSymbol().LowerCase() == AnsiString("yes"));
else if (str == AnsiString("debugmode")) // McZapkie! - DebugModeFlag uzywana w mover.pas,
// warto tez blokowac cheaty gdy false
// warto tez blokowac cheaty gdy false
DebugModeFlag = (GetNextSymbol().LowerCase() == AnsiString("yes"));
else if (str == AnsiString("soundenabled")) // McZapkie-040302 - blokada dzwieku - przyda
// sie do debugowania oraz na komp. bez karty
// dzw.
// sie do debugowania oraz na komp. bez karty
// dzw.
bSoundEnabled = (GetNextSymbol().LowerCase() == AnsiString("yes"));
// else if (str==AnsiString("renderalpha")) //McZapkie-1312302 - dwuprzebiegowe renderowanie
// bRenderAlpha=(GetNextSymbol().LowerCase()==AnsiString("yes"));
else if (str == AnsiString("physicslog")) // McZapkie-030402 - logowanie parametrow
// fizycznych dla kazdego pojazdu z maszynista
// fizycznych dla kazdego pojazdu z maszynista
WriteLogFlag = (GetNextSymbol().LowerCase() == AnsiString("yes"));
else if (str == AnsiString("physicsdeactivation")) // McZapkie-291103 - usypianie fizyki
PhysicActivationFlag = (GetNextSymbol().LowerCase() == AnsiString("yes"));
@@ -310,7 +310,7 @@ void Global::ConfigParse(TQueryParserComp *qp, cParser *cp)
fFriction = GetNextSymbol().ToDouble();
else if (str == AnsiString("livetraction"))
{ // Winger 160404 - zaleznosc napiecia loka od trakcji; Ra 2014-03: teraz pr¹d przy braku
// sieci
// sieci
bLiveTraction = (GetNextSymbol().LowerCase() == AnsiString("yes"));
}
else if (str == AnsiString("skyenabled"))
@@ -418,7 +418,7 @@ void Global::ConfigParse(TQueryParserComp *qp, cParser *cp)
else if (str == AnsiString("slowmotion")) // tworzenie plików binarnych
iSlowMotionMask = GetNextSymbol().ToIntDef(-1); // domyœlnie -1
else if (str == AnsiString("modifytga")) // czy korygowaæ pliki TGA dla szybszego
// wczytywania
// wczytywania
iModifyTGA = GetNextSymbol().ToIntDef(0); // domyœlnie 0
else if (str == AnsiString("hideconsole")) // hunter-271211: ukrywanie konsoli
bHideConsole = (GetNextSymbol().LowerCase() == AnsiString("yes"));
@@ -465,6 +465,10 @@ void Global::ConfigParse(TQueryParserComp *qp, cParser *cp)
asLang = GetNextSymbol(); // domyœlny jêzyk - http://tools.ietf.org/html/bcp47
else if (str == AnsiString("opengl")) // deklarowana wersja OpenGL, ¿eby powstrzymaæ b³êdy
fOpenGL = GetNextSymbol().ToDouble(); // wymuszenie wersji OpenGL
else if (str == AnsiString("pyscreenrendererpriority")) // priority of python screen
// renderer
TPythonInterpreter::getInstance()->setScreenRendererPriority(
GetNextSymbol().LowerCase().c_str());
} while (str != "endconfig"); //(!Parser->EndOfFile)
// na koniec trochê zale¿noœci
if (!bLoadTraction) // wczytywanie drutów i s³upów

View File

@@ -14,16 +14,17 @@ http://mozilla.org/MPL/2.0/.
#include "system.hpp"
#include "opengl/glew.h"
#include "dumb3d.h"
#include "PyInt.h"
//#include "Classes.h"
using namespace Math3D;
// definicje klawiszy
const int k_IncMainCtrl = 0; //[Num+]
const int k_IncMainCtrl = 0; //[Num+]
const int k_IncMainCtrlFAST = 1; //[Num+] [Shift]
const int k_DecMainCtrl = 2; //[Num-]
const int k_DecMainCtrl = 2; //[Num-]
const int k_DecMainCtrlFAST = 3; //[Num-] [Shift]
const int k_IncScndCtrl = 4; //[Num/]
const int k_IncScndCtrl = 4; //[Num/]
const int k_IncScndCtrlFAST = 5;
const int k_DecScndCtrl = 6;
const int k_DecScndCtrlFAST = 7;
@@ -151,7 +152,7 @@ class TTranscripts
~TTranscripts();
void AddLine(char *txt, float show, float hide, bool it);
void Add(char *txt, float len,
bool backgorund = false); // dodanie tekstów, d³ugoœæ dŸwiêku, czy istotne
bool backgorund = false); // dodanie tekstów, d³ugoœæ dŸwiêku, czy istotne
void Update(); // usuwanie niepotrzebnych (ok. 10 razy na sekundê)
};
@@ -206,7 +207,10 @@ class Global
static AnsiString asHumanCtrlVehicle;
static void LoadIniFile(AnsiString asFileName);
static void InitKeys(AnsiString asFileName);
inline static vector3 GetCameraPosition() { return pCameraPosition; };
inline static vector3 GetCameraPosition()
{
return pCameraPosition;
};
static void SetCameraPosition(vector3 pNewCameraPosition);
static void SetCameraRotation(double Yaw);
static int iWriteLogEnabled; // maska bitowa: 1-zapis do pliku, 2-okienko

View File

@@ -276,7 +276,7 @@ void TGroundNode::RaRenderVBO()
glColor3ub(Diffuse[0], Diffuse[1], Diffuse[2]);
if (TextureID)
glBindTexture(GL_TEXTURE_2D, TextureID); // Ustaw aktywn¹ teksturê
glDrawArrays(iType, iVboPtr, iNumVerts); // Narysuj naraz wszystkie trójk¹ty
glDrawArrays(iType, iVboPtr, iNumVerts); // Narysuj naraz wszystkie trójk¹ty
}
void TGroundNode::RenderVBO()
@@ -284,7 +284,7 @@ void TGroundNode::RenderVBO()
double mgn = SquareMagnitude(pCenter - Global::pCameraPosition);
if ((mgn > fSquareRadius || (mgn < fSquareMinRadius)) &&
(iType != TP_EVLAUNCH)) // McZapkie-070602: nie rysuj odleglych obiektow ale sprawdzaj
// wyzwalacz zdarzen
// wyzwalacz zdarzen
return;
int i, a;
switch (iType)
@@ -556,8 +556,8 @@ void TGroundNode::RenderDL()
// if (pTriGroup) if (pTriGroup!=this) return; //wyœwietla go inny obiekt
double mgn = SquareMagnitude(pCenter - Global::pCameraPosition);
if ((mgn > fSquareRadius) || (mgn < fSquareMinRadius)) // McZapkie-070602: nie rysuj odleglych
// obiektow ale sprawdzaj wyzwalacz
// zdarzen
// obiektow ale sprawdzaj wyzwalacz
// zdarzen
return;
int i, a;
switch (iType)
@@ -1379,7 +1379,7 @@ TGroundNode *__fastcall TGround::DynamicFind(AnsiString asNameToFind)
void TGround::DynamicList(bool all)
{ // odes³anie nazw pojazdów dostêpnych na scenerii (nazwy, szczególnie wagonów, mog¹ siê
// powtarzaæ!)
// powtarzaæ!)
for (TGroundNode *Current = nRootDynamic; Current; Current = Current->nNext)
if (all || Current->DynamicObject->Mechanik)
WyslijString(Current->asName, 6); // same nazwy pojazdów
@@ -1626,9 +1626,8 @@ TGroundNode *__fastcall TGround::AddGroundNode(cParser *parser)
*parser >> tmp->hvTraction->NominalVoltage >> tmp->hvTraction->MaxCurrent >>
tmp->hvTraction->fResistivity;
if (tmp->hvTraction->fResistivity == 0.01) // tyle jest w sceneriach [om/km]
tmp->hvTraction->fResistivity =
0.075; // taka sensowniejsza wartoϾ za
// http://www.ikolej.pl/fileadmin/user_upload/Seminaria_IK/13_05_07_Prezentacja_Kruczek.pdf
tmp->hvTraction->fResistivity = 0.075; // taka sensowniejsza wartoϾ za
// http://www.ikolej.pl/fileadmin/user_upload/Seminaria_IK/13_05_07_Prezentacja_Kruczek.pdf
tmp->hvTraction->fResistivity *= 0.001; // teraz [om/m]
parser->getTokens();
*parser >> token;
@@ -1722,7 +1721,7 @@ TGroundNode *__fastcall TGround::AddGroundNode(cParser *parser)
if (sTracks->Update(TP_MEMCELL, tmp->asName.c_str(),
tmp)) // najpierw sprawdziæ, czy ju¿ jest
{ // przy zdublowaniu wskaŸnik zostanie podmieniony w drzewku na póŸniejszy (zgodnoœæ
// wsteczna)
// wsteczna)
ErrorLog("Duplicated memcell: " + tmp->asName); // to zg³aszaæ duplikat
}
else
@@ -1749,7 +1748,7 @@ TGroundNode *__fastcall TGround::AddGroundNode(cParser *parser)
if (sTracks->Update(TP_TRACK, tmp->asName.c_str(),
tmp)) // najpierw sprawdziæ, czy ju¿ jest
{ // przy zdublowaniu wskaŸnik zostanie podmieniony w drzewku na póŸniejszy (zgodnoœæ
// wsteczna)
// wsteczna)
if (tmp->pTrack->iCategoryFlag & 1) // jeœli jest zdublowany tor kolejowy
ErrorLog("Duplicated track: " + tmp->asName); // to zg³aszaæ duplikat
}
@@ -1802,7 +1801,7 @@ TGroundNode *__fastcall TGround::AddGroundNode(cParser *parser)
parser->getTokens();
*parser >> token;
DriverType = AnsiString(token.c_str()); // McZapkie:010303 - w przyszlosci rozne
// konfiguracje mechanik/pomocnik itp
// konfiguracje mechanik/pomocnik itp
tf3 = fTrainSetVel; // prêdkoœæ
parser->getTokens();
*parser >> token;
@@ -1827,14 +1826,14 @@ TGroundNode *__fastcall TGround::AddGroundNode(cParser *parser)
if (tf1 != -1.0)
if (fabs(tf1) > 0.5) // maksymalna odleg³oœæ miêdzy sprzêgami - do przemyœlenia
int1 = 0; // likwidacja sprzêgu, jeœli odleg³oœæ zbyt du¿a - to powinno byæ
// uwzglêdniane w fizyce sprzêgów...
// uwzglêdniane w fizyce sprzêgów...
TempConnectionType[iTrainSetWehicleNumber] = int1; // wartoϾ dodatnia
}
else
{ // pojazd wstawiony luzem
fTrainSetDist = 0; // zerowanie dodatkowego przesuniêcia
asTrainName = ""; // puste oznacza jazdê pojedynczego bez rozk³adu, "none" jest dla
// sk³adu (trainset)
// sk³adu (trainset)
parser->getTokens();
*parser >> token;
str = AnsiString(token.c_str()); // track
@@ -1898,7 +1897,7 @@ TGroundNode *__fastcall TGround::AddGroundNode(cParser *parser)
.AllowedFlag &
ctrain_depot) // jesli zablokowany
TempConnectionType[iTrainSetWehicleNumber] |= ctrain_depot; // bêdzie
// blokada
// blokada
iTrainSetWehicleNumber++;
}
else
@@ -1995,7 +1994,7 @@ TGroundNode *__fastcall TGround::AddGroundNode(cParser *parser)
if (sTracks->Update(TP_MODEL, tmp->asName.c_str(),
tmp)) // najpierw sprawdziæ, czy ju¿ jest
{ // przy zdublowaniu wskaŸnik zostanie podmieniony w drzewku na póŸniejszy (zgodnoœæ
// wsteczna)
// wsteczna)
ErrorLog("Duplicated model: " + tmp->asName); // to zg³aszaæ duplikat
}
else
@@ -2057,7 +2056,7 @@ TGroundNode *__fastcall TGround::AddGroundNode(cParser *parser)
str = AnsiString(token.c_str());
#ifdef _PROBLEND
// PROBLEND Q: 13122011 - Szociu: 27012012
PROBLEND = true; // domyslnie uruchomione nowe wyœwietlanie
PROBLEND = true; // domyslnie uruchomione nowe wyœwietlanie
tmp->PROBLEND = true; // odwolanie do tgroundnode, bo rendering jest w tej klasie
if (str.Pos("@") > 0) // sprawdza, czy w nazwie tekstury jest znak "@"
{
@@ -2336,7 +2335,7 @@ void TGround::FirstInit()
glFogi(GL_FOG_MODE, GL_LINEAR);
glFogfv(GL_FOG_COLOR, Global::FogColor); // set fog color
glFogf(GL_FOG_START, Global::fFogStart); // fog start depth
glFogf(GL_FOG_END, Global::fFogEnd); // fog end depth
glFogf(GL_FOG_END, Global::fFogEnd); // fog end depth
glEnable(GL_FOG);
}
else
@@ -2443,7 +2442,7 @@ bool TGround::Init(AnsiString asFile, HDC hDC)
if (LastNode->iType != TP_DYNAMIC)
{ // jeœli nie jest pojazdem
LastNode->nNext = nRootOfType[LastNode->iType]; // ostatni dodany do³¹czamy
// na koñcu nowego
// na koñcu nowego
nRootOfType[LastNode->iType] =
LastNode; // ustawienie nowego na pocz¹tku listy
iNumNodes++;
@@ -2516,10 +2515,10 @@ bool TGround::Init(AnsiString asFile, HDC hDC)
if (iTrainSetWehicleNumber ? !TempConnectionType[iTrainSetWehicleNumber - 1] :
false) // jeœli ostatni pojazd ma sprzêg 0
LastNode->DynamicObject->RaLightsSet(-1, 2 + 32 + 64); // to za³o¿ymy mu
// koñcówki blaszane
// (jak AI siê
// odpali, to sobie
// poprawi)
// koñcówki blaszane
// (jak AI siê
// odpali, to sobie
// poprawi)
bTrainSet = false;
fTrainSetVel = 0;
// iTrainSetConnection=0;
@@ -2569,7 +2568,7 @@ bool TGround::Init(AnsiString asFile, HDC hDC)
ErrorLog("Duplicated event: " + tmp->asName);
found->Append(tmp); // doczepka (taki wirtualny multiple bez warunków)
found->Type = tp_Ignored; // dezaktywacja pierwotnego - taka proteza na
// wsteczn¹ zgodnoœæ
// wsteczn¹ zgodnoœæ
// SafeDelete(tmp); //bezlitoœnie usuwamy wszelkie duplikaty, ¿eby nie
// zaœmiecaæ drzewka
}
@@ -2580,7 +2579,7 @@ bool TGround::Init(AnsiString asFile, HDC hDC)
RootEvent = tmp;
if (!found)
{ // jeœli nazwa wyst¹pi³a, to do kolejki i wyszukiwarki dodawany jest tylko
// pierwszy
// pierwszy
if (RootEvent->Type != tp_Ignored)
if (RootEvent->asName.Pos(
"onstart")) // event uruchamiany automatycznie po starcie
@@ -2942,7 +2941,7 @@ bool TGround::InitEvents()
Current->Params[9].asMemCell = tmp->MemCell;
if (Current->Type == tp_GetValues) // jeœli odczyt komórki
if (tmp->MemCell->IsVelocity()) // a komórka zawiera komendê SetVelocity albo
// ShuntVelocity
// ShuntVelocity
Current->bEnabled = false; // to event nie bêdzie dodawany do kolejki
}
else
@@ -3004,7 +3003,7 @@ bool TGround::InitEvents()
if (Current->Params[9].asAnimContainer)
{
Current->Params[9].asAnimContainer->WillBeAnimated(); // oflagowanie
// animacji
// animacji
if (!Current->Params[9]
.asAnimContainer->Event()) // nie szukaæ, gdy znaleziony
Current->Params[9].asAnimContainer->EventAssign(
@@ -3194,24 +3193,23 @@ void TGround::InitTracks()
if (Track->asEvent0Name.IsEmpty())
if (FindEvent(Current->asName + ":event0"))
Track->asEvent0Name = Current->asName + ":event0";
if (Track->asEvent1Name.IsEmpty())
if (Track->asEvent1Name.IsEmpty())
if (FindEvent(Current->asName + ":event1"))
Track->asEvent1Name = Current->asName + ":event1";
if (Track->asEvent2Name.IsEmpty())
if (FindEvent(Current->asName + ":event2"))
Track->asEvent2Name = Current->asName + ":event2";
if (Track->asEventall0Name.IsEmpty())
if (FindEvent(Current->asName+":eventall0"))
Track->asEventall0Name=Current->asName+":eventall0";
if (Track->asEventall1Name.IsEmpty())
if (FindEvent(Current->asName+":eventall1"))
Track->asEventall1Name=Current->asName+":eventall1";
if (Track->asEventall2Name.IsEmpty())
if (FindEvent(Current->asName+":eventall2"))
Track->asEventall2Name=Current->asName+":eventall2";
}
if (Track->asEventall0Name.IsEmpty())
if (FindEvent(Current->asName + ":eventall0"))
Track->asEventall0Name = Current->asName + ":eventall0";
if (Track->asEventall1Name.IsEmpty())
if (FindEvent(Current->asName + ":eventall1"))
Track->asEventall1Name = Current->asName + ":eventall1";
if (Track->asEventall2Name.IsEmpty())
if (FindEvent(Current->asName + ":eventall2"))
Track->asEventall2Name = Current->asName + ":eventall2";
}
Track->AssignEvents(
Track->asEvent0Name.IsEmpty() ? NULL : FindEvent(Track->asEvent0Name),
Track->asEvent1Name.IsEmpty() ? NULL : FindEventScan(Track->asEvent1Name),
@@ -3237,7 +3235,7 @@ void TGround::InitTracks()
if (!Model) // jak nie ma modelu
break; // to pewnie jest wykolejnica, a ta jest domyœlnie zamkniêta i wykoleja
case tt_Normal: // tylko proste s¹ pod³¹czane do rozjazdów, st¹d dwa rozjazdy siê nie
// po³¹cz¹ ze sob¹
// po³¹cz¹ ze sob¹
if (Track->CurrentPrev() == NULL) // tylko jeœli jeszcze nie pod³¹czony
{
tmp = FindTrack(Track->CurrentSegment()->FastGetPoint_0(), iConnection, Current);
@@ -3379,7 +3377,7 @@ void TGround::InitTraction()
nTemp->psTractionPowerSource = new TTractionPowerSource();
nTemp->psTractionPowerSource->Init(Traction->NominalVoltage, Traction->MaxCurrent);
nTemp->nNext = nRootOfType[nTemp->iType]; // ostatni dodany do³¹czamy na koñcu
// nowego
// nowego
nRootOfType[nTemp->iType] = nTemp; // ustawienie nowego na pocz¹tku listy
iNumNodes++;
}
@@ -3401,12 +3399,12 @@ void TGround::InitTraction()
}
if (Traction->hvNext[0]) // jeœli zosta³ pod³¹czony
if (Traction->psSection && tmp->psSection) // tylko przês³o z izolatorem mo¿e nie
// mieæ zasilania, bo ma 2, trzeba
// sprawdzaæ s¹siednie
// mieæ zasilania, bo ma 2, trzeba
// sprawdzaæ s¹siednie
if (Traction->psSection !=
tmp->psSection) // po³¹czone odcinki maj¹ ró¿ne zasilacze
{ // to mo¿e byæ albo pod³¹czenie podstacji lub kabiny sekcyjnej do sekcji, albo
// b³¹d
// b³¹d
if (Traction->psSection->bSection && !tmp->psSection->bSection)
{ //(tmp->psSection) jest podstacj¹, a (Traction->psSection) nazw¹ sekcji
tmp->PowerSet(Traction->psSection); // zast¹pienie wskazaniem sekcji
@@ -3436,11 +3434,11 @@ void TGround::InitTraction()
}
if (Traction->hvNext[1]) // jeœli zosta³ pod³¹czony
if (Traction->psSection && tmp->psSection) // tylko przês³o z izolatorem mo¿e nie
// mieæ zasilania, bo ma 2, trzeba
// sprawdzaæ s¹siednie
// mieæ zasilania, bo ma 2, trzeba
// sprawdzaæ s¹siednie
if (Traction->psSection != tmp->psSection)
{ // to mo¿e byæ albo pod³¹czenie podstacji lub kabiny sekcyjnej do sekcji, albo
// b³¹d
// b³¹d
if (Traction->psSection->bSection && !tmp->psSection->bSection)
{ //(tmp->psSection) jest podstacj¹, a (Traction->psSection) nazw¹ sekcji
tmp->PowerSet(Traction->psSection); // zast¹pienie wskazaniem sekcji
@@ -3462,7 +3460,7 @@ void TGround::InitTraction()
{ // operacje maj¹ce na celu wykrywanie bie¿ni wspólnych i ³¹czenie przêse³ napr¹¿ania
if (nCurrent->hvTraction->WhereIs()) // oznakowanie przedostatnich przêse³
{ // poszukiwanie bie¿ni wspólnej dla przedostatnich przêse³, równie¿ w celu po³¹czenia
// zasilania
// zasilania
// to siê nie sprawdza, bo po³¹czyæ siê mog¹ dwa niezasilane odcinki jako najbli¿sze
// sobie
// nCurrent->hvTraction->hvParallel=TractionNearestFind(nCurrent->pCenter,0,nCurrent);
@@ -3484,7 +3482,7 @@ void TGround::InitTraction()
}
int zg = 0; // zgodnoœæ kierunku przêse³, tymczasowo iterator do tabeli koñców
TGroundNode **nEnds = new TGroundNode *[iConnection]; // koñców jest ok. 10 razy mniej ni¿
// wszystkich przêse³ (Quark: 216)
// wszystkich przêse³ (Quark: 216)
for (nCurrent = nRootOfType[TP_TRACTION]; nCurrent; nCurrent = nCurrent->nNext)
{ //³¹czenie bie¿ni wspólnych, w tym oznaczanie niepodanych jawnie
Traction = nCurrent->hvTraction;
@@ -3522,36 +3520,36 @@ void TGround::InitTraction()
while (zg)
{ // ustalenie zastêpczej rezystancji dla ka¿dego przês³a
zg = 0; // flaga pod³¹czonych przêse³ koñcowych: -1=puste wskaŸniki, 0=coœ zosta³o,
// 1=wykonano ³¹czenie
// 1=wykonano ³¹czenie
for (int i = 0; i < iConnection; ++i)
if (nEnds[i]) // za³atwione bêdziemy zerowaæ
{ // ka¿dy przebieg to próba pod³¹czenia koñca segmentu naprê¿ania do innego zasilanego
// przês³a
// przês³a
if (nEnds[i]->hvTraction->hvNext[0])
{ // jeœli koñcowy ma ci¹g dalszy od strony 0 (Point1), szukamy odcinka najbli¿szego
// do Point2
// do Point2
if (TractionNearestFind(nEnds[i]->hvTraction->pPoint2, 0,
nEnds[i])) // poszukiwanie przês³a
{
nEnds[i] = NULL;
zg = 1; // jak coœ zosta³o pod³¹czone, to mo¿e zasilanie gdzieœ dodatkowo
// dotrze
// dotrze
}
}
else if (nEnds[i]->hvTraction->hvNext[1])
{ // jeœli koñcowy ma ci¹g dalszy od strony 1 (Point2), szukamy odcinka najbli¿szego
// do Point1
// do Point1
if (TractionNearestFind(nEnds[i]->hvTraction->pPoint1, 1,
nEnds[i])) // poszukiwanie przês³a
{
nEnds[i] = NULL;
zg = 1; // jak coœ zosta³o pod³¹czone, to mo¿e zasilanie gdzieœ dodatkowo
// dotrze
// dotrze
}
}
else
{ // gdy koniec jest samotny, to na razie nie zostanie pod³¹czony (nie powinno
// takich byæ)
// takich byæ)
nEnds[i] = NULL;
}
}
@@ -3711,7 +3709,7 @@ TTraction *__fastcall TGround::FindTraction(vector3 *Point, int &iConnection, TG
TTraction *__fastcall TGround::TractionNearestFind(vector3 &p, int dir, TGroundNode *n)
{ // wyszukanie najbli¿szego do (p) przês³a o tej samej nazwie sekcji (ale innego ni¿ pod³¹czone)
// oraz zasilanego z kierunku (dir)
// oraz zasilanego z kierunku (dir)
TGroundNode *nCurrent, *nBest = NULL;
int i, j, k, zg;
double d, dist = 200.0 * 200.0; //[m] odleg³oœæ graniczna
@@ -3737,7 +3735,7 @@ TTraction *__fastcall TGround::TractionNearestFind(vector3 &p, int dir, TGroundN
nCurrent->hvTraction->vParametric) >= 0 ?
dir ^ 1 :
dir)]) // ma zasilanie z odpowiedniej
// strony
// strony
if (nCurrent->hvTraction->fResistance[k] >=
0.0) //¿eby siê nie propagowa³y jakieœ ujemne
{ // znaleziony kandydat do po³¹czenia
@@ -3750,7 +3748,7 @@ TTraction *__fastcall TGround::TractionNearestFind(vector3 &p, int dir, TGroundN
dist = d; // nowy rekord odleg³oœci
nBest = nCurrent;
zg = k; // z którego koñca braæ wskaŸnik
// zasilacza
// zasilacza
}
}
if (nBest) // jak znalezione przês³o z zasilaniem, to pod³¹czenie "równoleg³e"
@@ -3774,7 +3772,7 @@ bool TGround::AddToQuery(TEvent *Event, TDynamicObject *Node)
Event->Activator = Node;
if (Event->Type == tp_AddValues ? (Event->fDelay == 0.0) : false)
{ // eventy AddValues trzeba wykonywaæ natychmiastowo, inaczej kolejka mo¿e zgubiæ
// jakieœ dodawanie
// jakieœ dodawanie
// Ra: kopiowanie wykonania tu jest bez sensu, lepiej by by³o wydzieliæ funkcjê
// wykonuj¹c¹ eventy i j¹ wywo³aæ
if (EventConditon(Event))
@@ -3784,7 +3782,7 @@ bool TGround::AddToQuery(TEvent *Event, TDynamicObject *Node)
Event->Params[2].asdouble, Event->iFlags);
if (Event->Params[6].asTrack)
{ // McZapkie-100302 - updatevalues oprocz zmiany wartosci robi putcommand dla
// wszystkich 'dynamic' na danym torze
// wszystkich 'dynamic' na danym torze
for (int i = 0; i < Event->Params[6].asTrack->iNumDynamics; ++i)
Event->Params[5].asMemCell->PutCommand(
Event->Params[6].asTrack->Dynamics[i]->Mechanik,
@@ -3956,7 +3954,7 @@ bool TGround::CheckQuery()
tmpEvent->Params[2].asdouble, tmpEvent->iFlags);
if (tmpEvent->Params[6].asTrack)
{ // McZapkie-100302 - updatevalues oprocz zmiany wartosci robi putcommand dla
// wszystkich 'dynamic' na danym torze
// wszystkich 'dynamic' na danym torze
for (int i = 0; i < tmpEvent->Params[6].asTrack->iNumDynamics; ++i)
tmpEvent->Params[5].asMemCell->PutCommand(
tmpEvent->Params[6].asTrack->Dynamics[i]->Mechanik,
@@ -3980,7 +3978,7 @@ bool TGround::CheckQuery()
// loc.Y= tmpEvent->Params[8].nGroundNode->pCenter.z;
// loc.Z= tmpEvent->Params[8].nGroundNode->pCenter.y;
if (Global::iMultiplayer) // potwierdzenie wykonania dla serwera (odczyt
// semafora ju¿ tak nie dzia³a)
// semafora ju¿ tak nie dzia³a)
WyslijEvent(tmpEvent->asName, tmpEvent->Activator->GetName());
// tmpEvent->Params[9].asMemCell->PutCommand(tmpEvent->Activator->Mechanik,loc);
tmpEvent->Params[9].asMemCell->PutCommand(
@@ -4075,7 +4073,7 @@ bool TGround::CheckQuery()
case tp_TrackVel:
if (tmpEvent->Params[9].asTrack)
{ // prêdkoœæ na zwrotnicy mo¿e byæ ograniczona z góry we wpisie, wiêkszej siê nie
// ustawi eventem
// ustawi eventem
WriteLog("type: TrackVel");
// WriteLog("Vel: ",tmpEvent->Params[0].asdouble);
tmpEvent->Params[9].asTrack->VelocitySet(tmpEvent->Params[0].asdouble);
@@ -4106,7 +4104,7 @@ bool TGround::CheckQuery()
5.0) // to musi mieæ sensowny okres powtarzania
if (tmpEvent->iQueued < 2)
{ // trzeba zrobiæ wyj¹tek, aby event móg³ siê sam dodaæ do
// kolejki, raz ju¿ jest, ale bêdzie usuniêty
// kolejki, raz ju¿ jest, ale bêdzie usuniêty
// pêtla eventowa mo¿e byæ uruchomiona wiele razy, ale tylko
// pierwsze uruchomienie zadzia³a
tmpEvent->iQueued =
@@ -4154,7 +4152,7 @@ bool TGround::CheckQuery()
tmpEvent->Params[9].asMemCell->UpdateValues(
tmpEvent->Activator->asDestination.c_str(), // adres docelowy
tmpEvent->Activator->DirectionGet(), // kierunek pojazdu wzglêdem czo³a
// sk³adu (1=zgodny,-1=przeciwny)
// sk³adu (1=zgodny,-1=przeciwny)
tmpEvent->Activator->MoverParameters
->Power, // moc pojazdu silnikowego: 0 dla wagonu
tmpEvent->iFlags & (update_memstring | update_memval1 | update_memval2));
@@ -4269,7 +4267,7 @@ bool TGround::Update(double dt, int iter)
TAnimModel::AnimUpdate(dt1); // wykonanie zakolejkowanych animacji
for (TGroundNode *Current = nRootDynamic; Current; Current = Current->nNext)
{ // Ra: zmieniæ warunek na sprawdzanie pantografów w jednej zmiennej: czy pantografy i czy
// podniesione
// podniesione
if (Current->DynamicObject->MoverParameters->EnginePowerSource.SourceType ==
CurrentCollector)
GetTraction(Current->DynamicObject); // poszukiwanie drutu dla pantografów
@@ -4277,7 +4275,7 @@ bool TGround::Update(double dt, int iter)
}
for (TGroundNode *Current = nRootDynamic; Current; Current = Current->nNext)
Current->DynamicObject->Update(dt, dt1); // Ra 2015-01: tylko tu przelicza sieæ
// trakcyjn¹
// trakcyjn¹
}
else
{ // jezeli jest tylko jedna iteracja
@@ -4363,9 +4361,9 @@ bool TGround::GetTraction(TDynamicObject *model)
else
{ // jeœli t jest w przedziale, wyznaczyæ odleg³oœæ wzd³u¿ wektorów vUp i vLeft
vStyk = p->hvPowerWire->pPoint1 + fRaParam * vParam; // punkt styku
// p³aszczyzny z drutem
// (dla generatora ³uku
// el.)
// p³aszczyzny z drutem
// (dla generatora ³uku
// el.)
vGdzie = vStyk - pant0; // wektor
// odleg³oœæ w pionie musi byæ w zasiêgu ruchu "pionowego" pantografu
fVertical = DotProduct(
@@ -4373,11 +4371,11 @@ bool TGround::GetTraction(TDynamicObject *model)
// odleg³oœæ w bok powinna byæ mniejsza ni¿ pó³ szerokoœci pantografu
fHorizontal = fabs(DotProduct(vGdzie, vLeft)) -
p->fWidth; // to siê musi mieœciæ w przedziale zale¿nym od
// szerokoœci pantografu
// szerokoœci pantografu
// jeœli w pionie albo w bok jest za daleko, to dany drut jest nieu¿yteczny
if (fHorizontal > 0) // 0.635 dla AKP-1 AKP-4E
{ // drut wyszed³ poza zakres roboczy, ale jeszcze jest nabie¿nik -
// pantograf siê unosi bez utraty pr¹du
// pantograf siê unosi bez utraty pr¹du
if (fHorizontal > p->fWidthExtra) // czy wyszed³ za nabie¿nik
{
p->hvPowerWire = NULL; // dotychczasowy drut nie liczy siê
@@ -4385,18 +4383,18 @@ bool TGround::GetTraction(TDynamicObject *model)
}
else
{ // problem jest, gdy nowy drut jest wy¿ej, wtedy pantograf od³¹cza siê
// od starego, a na podniesienie do nowego potrzebuje czasu
// od starego, a na podniesienie do nowego potrzebuje czasu
p->PantTraction =
fVertical +
0.15 * fHorizontal / p->fWidthExtra; // na razie liniowo na
// nabie¿niku, dok³adnoœæ
// poprawi siê póŸniej
// nabie¿niku, dok³adnoœæ
// poprawi siê póŸniej
// p->fHorizontal=fHorizontal; //zapamiêtanie po³o¿enia drutu
}
}
else
{ // po wyselekcjonowaniu drutu, przypisaæ go do toru, ¿eby nie trzeba by³o
// szukaæ
// szukaæ
// dla 3 koñcowych przêse³ sprawdziæ wszystkie dostêpne przês³a
// bo mog¹ byæ umieszczone równolegle nad torem - po³¹czyæ w pierœcieñ
// najlepiej, jakby odcinki równoleg³e by³y oznaczone we wpisach
@@ -4420,7 +4418,7 @@ bool TGround::GetTraction(TDynamicObject *model)
for (int j = r - 2; j <= r; j++)
for (int i = c - 2; i <= c; i++)
{ // poszukiwanie po najbli¿szych sektorach niewiele da przy wiêkszym
// zagêszczeniu
// zagêszczeniu
tmp = FastGetSubRect(i, j);
if (tmp)
{ // dany sektor mo¿e nie mieæ nic w œrodku
@@ -4438,34 +4436,35 @@ bool TGround::GetTraction(TDynamicObject *model)
DotProduct(vParam, vFront);
if ((fRaParam >= -0.001) ? (fRaParam <= 1.001) : false)
{ // jeœli tylko jest w przedziale, wyznaczyæ odleg³oœæ wzd³u¿
// wektorów vUp i vLeft
// wektorów vUp i vLeft
vStyk = node->hvTraction->pPoint1 +
fRaParam * vParam; // punkt styku p³aszczyzny z
// drutem (dla generatora ³uku
// el.)
// drutem (dla generatora ³uku
// el.)
vGdzie = vStyk - pant0; // wektor
fVertical = DotProduct(
vGdzie,
vUp); // musi siê mieœciæ w przedziale ruchu pantografu
if (fVertical >= 0.0) // jeœli ponad pantografem (bo mo¿e
// ³apaæ druty spod wiaduktu)
// ³apaæ druty spod wiaduktu)
if (Global::bEnableTraction ?
fVertical < p->PantWys - 0.15 :
false) // jeœli drut jest ni¿ej ni¿ 15cm pod
// œlizgiem
// œlizgiem
{ // prze³¹czamy w tryb po³amania, o ile jedzie;
// (bEnableTraction) aby da³o siê jeŸdziæ na koœlawych
// sceneriach
// (bEnableTraction) aby da³o siê jeŸdziæ na
// koœlawych
// sceneriach
fHorizontal = fabs(DotProduct(vGdzie, vLeft)) -
p->fWidth; // i do tego jeszcze
// wejdzie pod œlizg
// wejdzie pod œlizg
if (fHorizontal <= 0.0) // 0.635 dla AKP-1 AKP-4E
{
p->PantWys =
-1.0; // ujemna liczba oznacza po³amanie
p->hvPowerWire = NULL; // bo inaczej siê zasila
// w nieskoñczonoœæ z
// po³amanego
// w nieskoñczonoœæ z
// po³amanego
// p->fHorizontal=fHorizontal; //zapamiêtanie
// po³o¿enia drutu
if (model->MoverParameters->EnginePowerSource
@@ -4474,7 +4473,7 @@ bool TGround::GetTraction(TDynamicObject *model)
--model->MoverParameters->EnginePowerSource
.CollectorParameters
.CollectorsNo; // teraz bêdzie
// mniejsza
// mniejsza
if (DebugModeFlag)
ErrorLog(
"Pant. break: at " +
@@ -4486,14 +4485,14 @@ bool TGround::GetTraction(TDynamicObject *model)
}
}
else if (fVertical < p->PantTraction) // ale ni¿ej, ni¿
// poprzednio
// znaleziony
// poprzednio
// znaleziony
{
fHorizontal =
fabs(DotProduct(vGdzie, vLeft)) - p->fWidth;
if (fHorizontal <= 0.0) // 0.635 dla AKP-1 AKP-4E
{ // to siê musi mieœciæ w przedziale zaleznym od
// szerokoœci pantografu
// szerokoœci pantografu
p->hvPowerWire =
node->hvTraction; // jakiœ znaleziony
p->PantTraction =
@@ -4503,28 +4502,28 @@ bool TGround::GetTraction(TDynamicObject *model)
}
else if (fHorizontal <
p->fWidthExtra) // czy zmieœci³ siê w
// zakresie nabie¿nika?
// zakresie nabie¿nika?
{ // problem jest, gdy nowy drut jest wy¿ej, wtedy
// pantograf od³¹cza siê od starego, a na
// podniesienie do nowego potrzebuje czasu
// pantograf od³¹cza siê od starego, a na
// podniesienie do nowego potrzebuje czasu
fVertical +=
0.15 * fHorizontal /
p->fWidthExtra; // korekta wysokoœci o
// nabie¿nik - drut nad
// nabie¿nikiem jest
// geometrycznie jakby nieco
// wy¿ej
// nabie¿nik - drut nad
// nabie¿nikiem jest
// geometrycznie jakby nieco
// wy¿ej
if (fVertical <
p->PantTraction) // gdy po korekcie jest
// ni¿ej, ni¿ poprzednio
// znaleziony
// ni¿ej, ni¿ poprzednio
// znaleziony
{ // gdyby to wystarczy³o, to mo¿emy go uznaæ
p->hvPowerWire =
node->hvTraction; // mo¿e byæ
p->PantTraction =
fVertical; // na razie liniowo na
// nabie¿niku, dok³adnoœæ
// poprawi siê póŸniej
// nabie¿niku, dok³adnoœæ
// poprawi siê póŸniej
// p->fHorizontal=fHorizontal;
// //zapamiêtanie po³o¿enia drutu
}
@@ -4584,7 +4583,7 @@ bool TGround::RenderDL(vector3 pPosition)
for (node = tmp->nRenderHidden; node; node = node->nNext3)
node->RenderHidden();
tmp->RenderSounds(); // jeszcze dŸwiêki pojazdów by siê przyda³y, równie¿
// niewidocznych
// niewidocznych
}
// renderowanie progresywne - zale¿ne od FPS oraz kierunku patrzenia
iRendered = 0; // iloœæ renderowanych sektorów
@@ -4597,7 +4596,7 @@ bool TGround::RenderDL(vector3 pPosition)
{
if (j <= 0)
i = -i; // pierwszy przebieg: j<=0, i>=0; drugi: j>=0, i<=0; trzeci: j<=0, i<=0
// czwarty: j>=0, i>=0;
// czwarty: j>=0, i>=0;
j = -j; // i oraz j musi byæ zmienione wczeœniej, ¿eby continue dzia³a³o
direction = vector3(i, 0, j); // wektor od kamery do danego sektora
if (LengthSquared3(direction) > 5) // te blisko s¹ zawsze wyœwietlane
@@ -4674,7 +4673,7 @@ bool TGround::RenderVBO(vector3 pPosition)
for (node = tmp->nRenderHidden; node; node = node->nNext3)
node->RenderHidden();
tmp->RenderSounds(); // jeszcze dŸwiêki pojazdów by siê przyda³y, równie¿
// niewidocznych
// niewidocznych
}
}
// renderowanie progresywne - zale¿ne od FPS oraz kierunku patrzenia
@@ -4688,7 +4687,7 @@ bool TGround::RenderVBO(vector3 pPosition)
{
if (j <= 0)
i = -i; // pierwszy przebieg: j<=0, i>=0; drugi: j>=0, i<=0; trzeci: j<=0, i<=0
// czwarty: j>=0, i>=0;
// czwarty: j>=0, i>=0;
j = -j; // i oraz j musi byæ zmienione wczeœniej, ¿eby continue dzia³a³o
direction = vector3(i, 0, j); // wektor od kamery do danego sektora
if (LengthSquared3(direction) > 5) // te blisko s¹ zawsze wyœwietlane
@@ -5049,7 +5048,7 @@ void TGround::TerrainWrite()
if (Current->TextureID)
switch (Current->iType)
{ // pêtla po trójk¹tach - zliczanie wierzcho³ków, dodaje submodel dla
// ka¿dej tekstury
// ka¿dej tekstury
case GL_TRIANGLES:
Current->iVboPtr = sk->TriangleAdd(
m, Current->TextureID,
@@ -5058,10 +5057,10 @@ void TGround::TerrainWrite()
Current->iNumVerts; // zwiêkszenie ca³kowitej iloœci wierzcho³ków
break;
case GL_TRIANGLE_STRIP: // na razie nie, bo trzeba przerabiaæ na pojedyncze
// trójk¹ty
// trójk¹ty
break;
case GL_TRIANGLE_FAN: // na razie nie, bo trzeba przerabiaæ na pojedyncze
// trójk¹ty
// trójk¹ty
break;
}
for (Current = Rects[i][j].nRootNode; Current; Current = Current->nNext2)
@@ -5092,10 +5091,10 @@ void TGround::TerrainWrite()
}
break;
case GL_TRIANGLE_STRIP: // na razie nie, bo trzeba przerabiaæ na pojedyncze
// trójk¹ty
// trójk¹ty
break;
case GL_TRIANGLE_FAN: // na razie nie, bo trzeba przerabiaæ na pojedyncze
// trójk¹ty
// trójk¹ty
break;
}
}

View File

@@ -160,7 +160,7 @@ class TGroundNode : public Resource
void RenderHidden(); // obsługa dźwięków i wyzwalaczy zdarzeń
void RenderDL(); // renderowanie nieprzezroczystych w Display Lists
void RenderAlphaDL(); // renderowanie przezroczystych w Display Lists
// (McZapkie-131202)
// (McZapkie-131202)
void RaRenderVBO(); // renderowanie (nieprzezroczystych) ze wspólnego VBO
void RenderVBO(); // renderowanie nieprzezroczystych z własnego VBO
void RenderAlphaVBO(); // renderowanie przezroczystych z (własnego) VBO
@@ -193,19 +193,18 @@ class TSubRect : public Resource, public CMesh
TSubRect();
virtual ~TSubRect();
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
void RaNodeAdd(TGroundNode *Node); // dodanie obiektu do listy renderowania
void Sort(); // optymalizacja obiektów w sektorze (sortowanie wg tekstur)
TTrack *__fastcall FindTrack(vector3 *Point, int &iConnection, TTrack *Exclude);
TTraction *__fastcall FindTraction(vector3 *Point, int &iConnection, TTraction *Exclude);
bool StartVBO(); // ustwienie VBO sektora dla (nRenderRect), (nRenderRectAlpha) i
// (nRenderWires)
// (nRenderWires)
bool RaTrackAnimAdd(TTrack *t); // zgłoszenie toru do animacji
void RaAnimate(); // przeliczenie animacji torów
void RenderDL(); // renderowanie nieprzezroczystych w Display Lists
void RenderAlphaDL(); // renderowanie przezroczystych w Display Lists
// (McZapkie-131202)
// (McZapkie-131202)
void RenderVBO(); // renderowanie nieprzezroczystych z własnego VBO
void RenderAlphaVBO(); // renderowanie przezroczystych z (własnego) VBO
void RenderSounds(); // dźwięki pojazdów z niewidocznych sektorów
@@ -227,7 +226,10 @@ class TGroundRect : public TSubRect
private:
int iLastDisplay; // numer klatki w której był ostatnio wyświetlany
TSubRect *pSubRects;
void Init() { pSubRects = new TSubRect[iNumSubRects * iNumSubRects]; };
void Init()
{
pSubRects = new TSubRect[iNumSubRects * iNumSubRects];
};
public:
static int iFrameNumber; // numer kolejny wyświetlanej klatki
@@ -359,8 +361,14 @@ class TGround
};
TSubRect *__fastcall GetSubRect(int iCol, int iRow);
TSubRect *__fastcall FastGetSubRect(int iCol, int iRow);
int GetRowFromZ(double z) { return (z / fSubRectSize + fHalfTotalNumSubRects); };
int GetColFromX(double x) { return (x / fSubRectSize + fHalfTotalNumSubRects); };
int GetRowFromZ(double z)
{
return (z / fSubRectSize + fHalfTotalNumSubRects);
};
int GetColFromX(double x)
{
return (x / fSubRectSize + fHalfTotalNumSubRects);
};
TEvent *__fastcall FindEvent(const AnsiString &asEventName);
TEvent *__fastcall FindEventScan(const AnsiString &asEventName);
void TrackJoin(TGroundNode *Current);

View File

@@ -15,9 +15,14 @@ http://mozilla.org/MPL/2.0/.
#include "Timer.h"
#include "Globals.h"
__fastcall TMachajka::TMachajka() : TTrain() { TTrain::TTrain(); }
__fastcall TMachajka::TMachajka() : TTrain()
{
TTrain::TTrain();
}
__fastcall TMachajka::~TMachajka() {}
__fastcall TMachajka::~TMachajka()
{
}
bool TMachajka::Init(TDynamicObject *NewDynamicObject)
{
@@ -63,11 +68,20 @@ void TMachajka::OnKeyPress(int cKey)
}
}
bool TMachajka::Update(double dt) { TTrain::Update(dt); }
bool TMachajka::Update(double dt)
{
TTrain::Update(dt);
}
bool TMachajka::UpdateMechPosition() { TTrain::UpdateMechPosition(); }
bool TMachajka::UpdateMechPosition()
{
TTrain::UpdateMechPosition();
}
bool TMachajka::Render() { TTrain::Render(); }
bool TMachajka::Render()
{
TTrain::Render();
}
//---------------------------------------------------------------------------
#pragma package(smart_init)

View File

@@ -57,7 +57,10 @@ __fastcall TModelsManager::~TModelsManager()
Free();
};
*/
void TModelsManager::Free() { SafeDeleteArray(Models); }
void TModelsManager::Free()
{
SafeDeleteArray(Models);
}
TModel3d *__fastcall TModelsManager::LoadModel(char *Name, bool dynamic)
{ // wczytanie modelu do tablicy
@@ -75,7 +78,7 @@ TModel3d *__fastcall TModelsManager::LoadModel(char *Name, bool dynamic)
TModel3d *__fastcall TModelsManager::GetModel(const char *Name, bool dynamic)
{ // model mo¿e byæ we wpisie "node...model" albo "node...dynamic", a tak¿e byæ dodatkowym w dynamic
// (kabina, wnêtrze, ³adunek)
// (kabina, wnêtrze, ³adunek)
// dla "node...dynamic" mamy podan¹ œcie¿kê w "\dynamic\" i musi byæ co najmniej 1 poziom, zwkle
// s¹ 2
// dla "node...model" mo¿e byæ typowy model statyczny ze œcie¿k¹, domyœlnie w "\scenery\" albo
@@ -97,7 +100,7 @@ TModel3d *__fastcall TModelsManager::GetModel(const char *Name, bool dynamic)
// - wczytanie modelu animowanego - Init() - sprawdziæ
char buf[255];
AnsiString buftp = Global::asCurrentTexturePath; // zapamiêtanie aktualnej œcie¿ki do tekstur,
// bo bêdzie tyczmasowo zmieniana
// bo bêdzie tyczmasowo zmieniana
/*
// Ra: niby tak jest lepiej, ale dzia³a gorzej, wiêc przywrócone jest oryginalne
//nawet jeœli model bêdzie pobrany z tablicy, to trzeba ustaliæ œcie¿kê dla tekstur

View File

@@ -34,19 +34,23 @@ TMemCell::TMemCell(vector3 *p)
{
fValue1 = fValue2 = 0;
szText = new char[256]; // musi byæ dla automatycznie tworzonych komórek dla odcinków
// izolowanych
// izolowanych
vPosition =
p ? *p : vector3(0, 0, 0); // ustawienie wspó³rzêdnych, bo do TGroundNode nie ma dostêpu
bCommand = false; // komenda wys³ana
OnSent = NULL;
}
TMemCell::~TMemCell() { SafeDeleteArray(szText); }
TMemCell::~TMemCell()
{
SafeDeleteArray(szText);
}
void TMemCell::Init() {}
void TMemCell::Init()
{
}
void TMemCell::UpdateValues(char *szNewText, double fNewValue1, double fNewValue2,
int CheckMask)
void TMemCell::UpdateValues(char *szNewText, double fNewValue1, double fNewValue2, int CheckMask)
{
if (CheckMask & update_memadd)
{ // dodawanie wartoœci
@@ -140,8 +144,7 @@ void TMemCell::PutCommand(TController *Mech, vector3 *Loc)
Mech->PutCommand(szText, fValue1, fValue2, Loc);
}
bool TMemCell::Compare(char *szTestText, double fTestValue1, double fTestValue2,
int CheckMask)
bool TMemCell::Compare(char *szTestText, double fTestValue1, double fTestValue2, int CheckMask)
{ // porównanie zawartoœci komórki pamiêci z podanymi wartoœciami
if (TestFlag(CheckMask, conditional_memstring))
{ // porównaæ teksty
@@ -161,7 +164,10 @@ bool TMemCell::Compare(char *szTestText, double fTestValue1, double fTestValue2,
(!TestFlag(CheckMask, conditional_memval2) || (fValue2 == fTestValue2)));
};
bool TMemCell::Render() { return true; }
bool TMemCell::Render()
{
return true;
}
bool TMemCell::IsVelocity()
{ // sprawdzenie, czy event odczytu tej komórki ma byæ do skanowania, czy do kolejkowania

View File

@@ -30,19 +30,35 @@ class TMemCell
TMemCell(vector3 *p);
~TMemCell();
void Init();
void UpdateValues(char *szNewText, double fNewValue1, double fNewValue2,
int CheckMask);
void UpdateValues(char *szNewText, double fNewValue1, double fNewValue2, int CheckMask);
bool Load(cParser *parser);
void PutCommand(TController *Mech, vector3 *Loc);
bool Compare(char *szTestText, double fTestValue1, double fTestValue2,
int CheckMask);
bool Compare(char *szTestText, double fTestValue1, double fTestValue2, int CheckMask);
bool Render();
inline char *__fastcall Text() { return szText; };
inline double Value1() { return fValue1; };
inline double Value2() { return fValue2; };
inline vector3 Position() { return vPosition; };
inline TCommandType Command() { return eCommand; };
inline bool StopCommand() { return bCommand; };
inline char *__fastcall Text()
{
return szText;
};
inline double Value1()
{
return fValue1;
};
inline double Value2()
{
return fValue2;
};
inline vector3 Position()
{
return vPosition;
};
inline TCommandType Command()
{
return eCommand;
};
inline bool StopCommand()
{
return bCommand;
};
void StopCommandSent();
TCommandType CommandCheck();
bool IsVelocity();

View File

@@ -178,8 +178,7 @@ void TSubModel::NameSet(const char *n)
// int TSubModel::SeekFaceNormal(DWORD *Masks, int f,DWORD dwMask,vector3 *pt,GLVERTEX
// *Vertices)
int TSubModel::SeekFaceNormal(DWORD *Masks, int f, DWORD dwMask, float3 *pt,
float8 *Vertices)
int TSubModel::SeekFaceNormal(DWORD *Masks, int f, DWORD dwMask, float3 *pt, float8 *Vertices)
{ // szukanie punktu stycznego do (pt), zwraca numer wierzcho³ka, a nie trójk¹ta
int iNumFaces = iNumVerts / 3; // bo maska powierzchni jest jedna na trójk¹t
// GLVERTEX *p; //roboczy wskaŸnik
@@ -458,7 +457,7 @@ int TSubModel::Load(cParser &parser, TModel3d *Model, int Pos, bool dynamic)
parser.getToken(token);
if (token[0] == '*')
{ // jeœli pierwszy znak jest gwiazdk¹, poszukaæ submodelu o nazwie bez tej gwiazdki i wzi¹æ
// z niego wierzcho³ki
// z niego wierzcho³ki
Error("Verticles reference not yet supported!");
}
else
@@ -476,7 +475,7 @@ int TSubModel::Load(cParser &parser, TModel3d *Model, int Pos, bool dynamic)
Vertices = new float8[iNumVerts];
iNumFaces = iNumVerts / 3;
sg = new DWORD[iNumFaces]; // maski powierzchni: 0 oznacza brak u¿redniania wektorów
// normalnych
// normalnych
int *wsp = new int[iNumVerts]; // z którego wierzcho³ka kopiowaæ wektor normalny
int maska = 0;
for (int i = 0; i < iNumVerts; i++)
@@ -484,10 +483,10 @@ int TSubModel::Load(cParser &parser, TModel3d *Model, int Pos, bool dynamic)
wsp[i] = -1; // wektory normalne nie s¹ policzone dla tego wierzcho³ka
if ((i % 3) == 0)
{ // jeœli bêdzie maska -1, to dalej bêd¹ wierzcho³ki z wektorami normalnymi,
// podanymi jawnie
// podanymi jawnie
parser.getToken(maska); // maska powierzchni trójk¹ta
sg[i / 3] = (maska == -1) ? 0 : maska; // dla maski -1 bêdzie 0, czyli nie
// ma wspólnych wektorów normalnych
// ma wspólnych wektorów normalnych
}
parser.getToken(Vertices[i].Point.x);
parser.getToken(Vertices[i].Point.y);
@@ -514,14 +513,14 @@ int TSubModel::Load(cParser &parser, TModel3d *Model, int Pos, bool dynamic)
AnsiString(pName) + "\", verticle " + AnsiString(i));
}
if (i > 0) // jeœli pierwszy trójk¹t bêdzie zdegenerowany, to zostanie
// usuniêty i nie ma co sprawdzaæ
// usuniêty i nie ma co sprawdzaæ
if (((Vertices[i].Point - Vertices[i - 1].Point).Length() > 1000.0) ||
((Vertices[i - 1].Point - Vertices[i - 2].Point).Length() >
1000.0) ||
((Vertices[i - 2].Point - Vertices[i].Point).Length() > 1000.0))
{ // je¿eli s¹ dalej ni¿ 2km od siebie //Ra 15-01: obiekt wstawiany nie
// powinien byæ wiêkszy ni¿ 300m (trójk¹ty terenu w E3D mog¹ mieæ
// 1.5km)
// powinien byæ wiêkszy ni¿ 300m (trójk¹ty terenu w E3D mog¹ mieæ
// 1.5km)
--iNumFaces; // o jeden trójk¹t mniej
iNumVerts -= 3; // czyli o 3 wierzcho³ki
i -= 3; // wczytanie kolejnego w to miejsce
@@ -533,7 +532,7 @@ int TSubModel::Load(cParser &parser, TModel3d *Model, int Pos, bool dynamic)
int i; // indeks dla trójk¹tów
float3 *n = new float3[iNumFaces]; // tablica wektorów normalnych dla trójk¹tów
for (i = 0; i < iNumFaces; i++) // pêtla po trójk¹tach - bêdzie szybciej, jak
// wstêpnie przeliczymy normalne trójk¹tów
// wstêpnie przeliczymy normalne trójk¹tów
n[i] = SafeNormalize(
CrossProduct(Vertices[i * 3].Point - Vertices[i * 3 + 1].Point,
Vertices[i * 3].Point - Vertices[i * 3 + 2].Point));
@@ -554,7 +553,7 @@ int TSubModel::Load(cParser &parser, TModel3d *Model, int Pos, bool dynamic)
while (f >= 0)
{ // sumowanie z wektorem normalnym s¹siada (w³¹cznie ze sob¹)
wsp[f] = v; // informacja, ¿e w tym wierzcho³ku jest ju¿ policzony
// wektor normalny
// wektor normalny
norm += n[f / 3];
f = SeekFaceNormal(sg, f / 3 + 1, sg[i], &Vertices[v].Point,
Vertices); // i szukanie od kolejnego trójk¹ta
@@ -776,7 +775,7 @@ void TSubModel::InitialRotate(bool doit)
(*mat)(3)[0] = (*mat)(3)[1] = (*mat)(3)[2] =
0.0; // zerujemy przesuniêcie przed obracaniem normalnych
if (eType != TP_STARS) // gwiazdki maj¹ kolory zamiast normalnych, to ich wtedy
// nie ruszamy
// nie ruszamy
for (int i = 0; i < iNumVerts; ++i)
Vertices[i].Normal = SafeNormalize((*mat) * Vertices[i].Normal);
}
@@ -916,7 +915,10 @@ void TSubModel::SetRotateIK1(float3 vNewAngles)
struct ToLower
{
char operator()(char input) { return tolower(input); }
char operator()(char input)
{
return tolower(input);
}
};
TSubModel *__fastcall TSubModel::GetFromName(AnsiString search, bool i)
@@ -1003,7 +1005,7 @@ void TSubModel::RaAnimation(TAnimType a)
case at_Billboard: // obrót w pionie do kamery
{
matrix4x4 mat; // potrzebujemy wspó³rzêdne przesuniêcia œrodka uk³adu wspó³rzêdnych
// submodelu
// submodelu
glGetDoublev(GL_MODELVIEW_MATRIX, mat.getArray()); // pobranie aktualnej matrycy
float3 gdzie = float3(mat[3][0], mat[3][1],
mat[3][2]); // pocz¹tek uk³adu wspó³rzêdnych submodelu wzglêdem kamery
@@ -1092,7 +1094,7 @@ void TSubModel::RenderDL()
{
double Distdimm = 1.0;
if (fCosViewAngle < fCosHotspotAngle) // zmniejszona jasnoœæ miêdzy Hotspot a
// Falloff
// Falloff
if (fCosFalloffAngle < fCosHotspotAngle)
Distdimm = 1.0 -
(fCosHotspotAngle - fCosViewAngle) /
@@ -1188,9 +1190,9 @@ void TSubModel::RenderAlphaDL()
char c;
if (!smLetter)
{ // jeœli nie ma tablicy, to j¹ stworzyæ; miejsce nieodpowiednie, ale tymczasowo
// mo¿e byæ
// mo¿e byæ
smLetter = new TSubModel *[256]; // tablica wskaŸników submodeli dla
// wyœwietlania tekstu
// wyœwietlania tekstu
ZeroMemory(smLetter, 256 * sizeof(TSubModel *)); // wype³nianie zerami
p = Child;
while (p)
@@ -1270,7 +1272,7 @@ void TSubModel::RenderVBO()
{
double Distdimm = 1.0;
if (fCosViewAngle < fCosHotspotAngle) // zmniejszona jasnoœæ miêdzy Hotspot a
// Falloff
// Falloff
if (fCosFalloffAngle < fCosHotspotAngle)
Distdimm = 1.0 -
(fCosHotspotAngle - fCosViewAngle) /
@@ -1523,8 +1525,8 @@ void TSubModel::InfoSet(TSubModelInfo *info)
pTexture = pName = NULL;
};
void TSubModel::BinInit(TSubModel *s, float4x4 *m, float8 *v, TStringPack *t,
TStringPack *n, bool dynamic)
void TSubModel::BinInit(TSubModel *s, float4x4 *m, float8 *v, TStringPack *t, TStringPack *n,
bool dynamic)
{ // ustawienie wskaŸników w submodelu
iVisible = 1; // tymczasowo u¿ywane
Child = ((int)Child > 0) ? s + (int)Child : NULL; // zerowy nie mo¿e byæ potomnym
@@ -1539,7 +1541,7 @@ void TSubModel::BinInit(TSubModel *s, float4x4 *m, float8 *v, TStringPack *t,
{ // jeœli dany submodel jest zgaszonym œwiat³em, to domyœlnie go ukrywamy
if (s.SubString(1, 8) == "Light_On") // jeœli jest œwiat³em numerowanym
iVisible = 0; // to domyœlnie wy³¹czyæ, ¿eby siê nie nak³ada³o z obiektem
// "Light_Off"
// "Light_Off"
else if (dynamic) // inaczej wy³¹cza³o smugê w latarniach
if (s.SubString(s.Length() - 2, 3) ==
"_on") // jeœli jest kontrolk¹ w stanie zapalonym
@@ -1783,12 +1785,12 @@ void TModel3d::LoadFromBinFile(char *FileName, bool dynamic)
case 'SUB0': // submodele: 'SUB0',len,(256 bajtów na submodel)
iSubModelsCount = (k - 2) / 64;
Root = (TSubModel *)(iModel + i + 2); // numery na wskaŸniki przetworzymy
// póŸniej
// póŸniej
break;
case 'SUB1': // submodele: 'SUB1',len,(320 bajtów na submodel)
iSubModelsCount = (k - 2) / 80;
Root = (TSubModel *)(iModel + i + 2); // numery na wskaŸniki przetworzymy
// póŸniej
// póŸniej
for (ch = 1; ch < iSubModelsCount;
++ch) // trzeba przesun¹æ bli¿ej, bo 256 wystarczy
MoveMemory(((char *)Root) + 256 * ch, ((char *)Root) + 320 * ch, 256);
@@ -1909,7 +1911,7 @@ void TModel3d::Init()
if (Global::fDistanceFactor !=
1.0) // trochê zaoszczêdzi czasu na modelach z wieloma submocelami
Root->AdjustDist(); // aktualizacja odleg³oœci faz LoD, zale¿nie od rozdzielczoœci
// pionowej oraz multisamplingu
// pionowej oraz multisamplingu
if (Global::bUseVBO)
{
if (!m_pVNT) // jeœli nie ma jeszcze tablicy (wczytano z pliku tekstowego)
@@ -2019,7 +2021,10 @@ void TModel3d::SaveToBinFile(char *FileName)
delete[] info;
};
void TModel3d::BreakHierarhy() { Error("Not implemented yet :("); };
void TModel3d::BreakHierarhy()
{
Error("Not implemented yet :(");
};
/*
void TModel3d::Render(vector3 pPosition,double fAngle,GLuint ReplacableSkinId,int iAlpha)
@@ -2122,8 +2127,7 @@ void TModel3d::RaRender(double fSquareDistance, GLuint *ReplacableSkinId, int iA
}
};
void TModel3d::RaRenderAlpha(double fSquareDistance, GLuint *ReplacableSkinId,
int iAlpha)
void TModel3d::RaRenderAlpha(double fSquareDistance, GLuint *ReplacableSkinId, int iAlpha)
{ // renderowanie specjalne, np. kabiny
if (iAlpha & iFlags & 0x2F2F002F) // czy w ogóle jest co robiæ w tym cyklu?
{
@@ -2159,8 +2163,7 @@ iAlpha)
// 2011-03-16 cztery nowe funkcje renderowania z mo¿liwoœci¹ pochylania obiektów
//-----------------------------------------------------------------------------
void TModel3d::Render(vector3 *vPosition, vector3 *vAngle, GLuint *ReplacableSkinId,
int iAlpha)
void TModel3d::Render(vector3 *vPosition, vector3 *vAngle, GLuint *ReplacableSkinId, int iAlpha)
{ // nieprzezroczyste, Display List
glPushMatrix();
glTranslated(vPosition->x, vPosition->y, vPosition->z);
@@ -2178,7 +2181,7 @@ void TModel3d::Render(vector3 *vPosition, vector3 *vAngle, GLuint *ReplacableSki
glPopMatrix();
};
void TModel3d::RenderAlpha(vector3 *vPosition, vector3 *vAngle, GLuint *ReplacableSkinId,
int iAlpha)
int iAlpha)
{ // przezroczyste, Display List
glPushMatrix();
glTranslated(vPosition->x, vPosition->y, vPosition->z);
@@ -2194,8 +2197,7 @@ void TModel3d::RenderAlpha(vector3 *vPosition, vector3 *vAngle, GLuint *Replacab
Root->RenderAlphaDL();
glPopMatrix();
};
void TModel3d::RaRender(vector3 *vPosition, vector3 *vAngle, GLuint *ReplacableSkinId,
int iAlpha)
void TModel3d::RaRender(vector3 *vPosition, vector3 *vAngle, GLuint *ReplacableSkinId, int iAlpha)
{ // nieprzezroczyste, VBO
glPushMatrix();
glTranslated(vPosition->x, vPosition->y, vPosition->z);
@@ -2215,8 +2217,8 @@ void TModel3d::RaRender(vector3 *vPosition, vector3 *vAngle, GLuint *ReplacableS
}
glPopMatrix();
};
void TModel3d::RaRenderAlpha(vector3 *vPosition, vector3 *vAngle,
GLuint *ReplacableSkinId, int iAlpha)
void TModel3d::RaRenderAlpha(vector3 *vPosition, vector3 *vAngle, GLuint *ReplacableSkinId,
int iAlpha)
{ // przezroczyste, VBO
glPushMatrix();
glTranslated(vPosition->x, vPosition->y, vPosition->z);
@@ -2280,7 +2282,7 @@ void TModel3d::TerrainRenderVBO(int n)
while (r)
{
if (r->iVisible == n) // tylko jeœli ma byæ widoczny w danej ramce (problem dla
// 0==false)
// 0==false)
r->RenderVBO(); // sub kolejne (Next) siê nie wyrenderuj¹
r = r->NextGet();
}

109
Model3d.h
View File

@@ -36,21 +36,33 @@ class TStringPack
//+8 - tabela indeksów
public:
char *String(int n);
char *StringAt(int n) { return data + 9 + n; };
char *StringAt(int n)
{
return data + 9 + n;
};
TStringPack()
{
data = NULL;
index = NULL;
};
void Init(char *d) { data = d; };
void InitIndex(int *i) { index = i; };
void Init(char *d)
{
data = d;
};
void InitIndex(int *i)
{
index = i;
};
};
class TMaterialColor
{
public:
TMaterialColor(){};
TMaterialColor(char V) { r = g = b = V; };
TMaterialColor(char V)
{
r = g = b = V;
};
// TMaterialColor(double R, double G, double B)
TMaterialColor(char R, char G, char B)
{
@@ -199,7 +211,7 @@ class TSubModel
float fFarDecayRadius; // normalizacja j.w.
float fCosFalloffAngle; // cosinus kąta stożka pod którym widać światło
float fCosHotspotAngle; // cosinus kąta stożka pod którym widać aureolę i zwiększone natężenie
// światła
// światła
float fCosViewAngle; // cos kata pod jakim sie teraz patrzy
// Ra: dalej są zmienne robocze, można je przestawiać z zachowaniem rozmiaru klasy
int TextureID; // numer tekstury, -1 wymienna, 0 brak
@@ -250,8 +262,14 @@ class TSubModel
int Load(cParser &Parser, TModel3d *Model, int Pos, bool dynamic);
void ChildAdd(TSubModel *SubModel);
void NextAdd(TSubModel *SubModel);
TSubModel *__fastcall NextGet() { return Next; };
TSubModel *__fastcall ChildGet() { return Child; };
TSubModel *__fastcall NextGet()
{
return Next;
};
TSubModel *__fastcall ChildGet()
{
return Child;
};
int TriangleAdd(TModel3d *m, int tex, int tri);
float8 *__fastcall TrianglePtr(int tex, int pos, int *la, int *ld, int *ls);
// float8* TrianglePtr(const char *tex,int tri);
@@ -269,9 +287,15 @@ class TSubModel
void RenderVBO();
void RenderAlphaVBO();
// inline matrix4x4* GetMatrix() {return dMatrix;};
inline float4x4 *__fastcall GetMatrix() { return fMatrix; };
inline float4x4 *__fastcall GetMatrix()
{
return fMatrix;
};
// matrix4x4* GetTransform() {return Matrix;};
inline void Hide() { iVisible = 0; };
inline void Hide()
{
iVisible = 0;
};
void RaArrayFill(CVertNormTex *Vert);
// void Render();
int FlagsCheck();
@@ -284,8 +308,8 @@ class TSubModel
void DisplayLists();
void Info();
void InfoSet(TSubModelInfo *info);
void BinInit(TSubModel *s, float4x4 *m, float8 *v, TStringPack *t,
TStringPack *n = NULL, bool dynamic = false);
void BinInit(TSubModel *s, float4x4 *m, float8 *v, TStringPack *t, TStringPack *n = NULL,
bool dynamic = false);
void ReplacableSet(GLuint *r, int a)
{
ReplacableSkinId = r;
@@ -294,8 +318,14 @@ class TSubModel
void TextureNameSet(const char *n);
void NameSet(const char *n);
// Ra: funkcje do budowania terenu z E3D
int Flags() { return iFlags; };
void UnFlagNext() { iFlags &= 0x00FFFFFF; };
int Flags()
{
return iFlags;
};
void UnFlagNext()
{
iFlags &= 0x00FFFFFF;
};
void ColorsSet(int *a, int *d, int *s);
inline float3 Translation1Get()
{
@@ -305,6 +335,10 @@ class TSubModel
{
return *(fMatrix->TranslationGet()) + Child->Translation1Get();
}
int GetTextureId()
{
return TextureID;
}
void ParentMatrix(float4x4 *m);
float MaxY(const float4x4 &m);
void AdjustDist();
@@ -356,7 +390,10 @@ class TModel3d : public CMesh
int iSubModelsCount; // Ra: używane do tworzenia binarnych
AnsiString asBinary; // nazwa pod którą zapisać model binarny
public:
inline TSubModel *__fastcall GetSMRoot() { return (Root); };
inline TSubModel *__fastcall GetSMRoot()
{
return (Root);
};
// double Radius; //Ra: nie używane
TModel3d();
TModel3d(char *FileName);
@@ -371,36 +408,40 @@ class TModel3d : public CMesh
void SaveToBinFile(char *FileName);
void BreakHierarhy();
// renderowanie specjalne
void Render(double fSquareDistance, GLuint *ReplacableSkinId = NULL,
int iAlpha = 0x30300030);
void Render(double fSquareDistance, GLuint *ReplacableSkinId = NULL, int iAlpha = 0x30300030);
void RenderAlpha(double fSquareDistance, GLuint *ReplacableSkinId = NULL,
int iAlpha = 0x30300030);
void RaRender(double fSquareDistance, GLuint *ReplacableSkinId = NULL,
int iAlpha = 0x30300030);
int iAlpha = 0x30300030);
void RaRender(double fSquareDistance, GLuint *ReplacableSkinId = NULL, int iAlpha = 0x30300030);
void RaRenderAlpha(double fSquareDistance, GLuint *ReplacableSkinId = NULL,
int iAlpha = 0x30300030);
int iAlpha = 0x30300030);
// jeden kąt obrotu
void Render(vector3 pPosition, double fAngle = 0, GLuint *ReplacableSkinId = NULL,
int iAlpha = 0x30300030);
void RenderAlpha(vector3 pPosition, double fAngle = 0,
GLuint *ReplacableSkinId = NULL, int iAlpha = 0x30300030);
int iAlpha = 0x30300030);
void RenderAlpha(vector3 pPosition, double fAngle = 0, GLuint *ReplacableSkinId = NULL,
int iAlpha = 0x30300030);
void RaRender(vector3 pPosition, double fAngle = 0, GLuint *ReplacableSkinId = NULL,
int iAlpha = 0x30300030);
void RaRenderAlpha(vector3 pPosition, double fAngle = 0,
GLuint *ReplacableSkinId = NULL, int iAlpha = 0x30300030);
int iAlpha = 0x30300030);
void RaRenderAlpha(vector3 pPosition, double fAngle = 0, GLuint *ReplacableSkinId = NULL,
int iAlpha = 0x30300030);
// trzy kąty obrotu
void Render(vector3 *vPosition, vector3 *vAngle, GLuint *ReplacableSkinId = NULL,
int iAlpha = 0x30300030);
void RenderAlpha(vector3 *vPosition, vector3 *vAngle,
GLuint *ReplacableSkinId = NULL, int iAlpha = 0x30300030);
int iAlpha = 0x30300030);
void RenderAlpha(vector3 *vPosition, vector3 *vAngle, GLuint *ReplacableSkinId = NULL,
int iAlpha = 0x30300030);
void RaRender(vector3 *vPosition, vector3 *vAngle, GLuint *ReplacableSkinId = NULL,
int iAlpha = 0x30300030);
void RaRenderAlpha(vector3 *vPosition, vector3 *vAngle,
GLuint *ReplacableSkinId = NULL, int iAlpha = 0x30300030);
int iAlpha = 0x30300030);
void RaRenderAlpha(vector3 *vPosition, vector3 *vAngle, GLuint *ReplacableSkinId = NULL,
int iAlpha = 0x30300030);
// inline int GetSubModelsCount() { return (SubModelsCount); };
int Flags() { return iFlags; };
int Flags()
{
return iFlags;
};
void Init();
char *__fastcall NameGet() { return Root ? Root->pName : NULL; };
char *__fastcall NameGet()
{
return Root ? Root->pName : NULL;
};
int TerrainCount();
TSubModel *__fastcall TerrainSquare(int n);
void TerrainRenderVBO(int n);

View File

@@ -16,9 +16,8 @@ http://mozilla.org/MPL/2.0/.
const dEpsilon = 0.01; // 1cm (zale¿y od typu sprzêgu...)
TMoverParameters::TMoverParameters(double VelInitial, AnsiString TypeNameInit,
AnsiString NameInit, int LoadInitial,
AnsiString LoadTypeInitial, int Cab)
TMoverParameters::TMoverParameters(double VelInitial, AnsiString TypeNameInit, AnsiString NameInit,
int LoadInitial, AnsiString LoadTypeInitial, int Cab)
: T_MoverParameters(VelInitial, TypeNameInit, NameInit, LoadInitial, LoadTypeInitial, Cab)
{ // g³ówny konstruktor
DimHalf.x = 0.5 * Dim.W; // po³owa szerokoœci, OX jest w bok?
@@ -32,13 +31,13 @@ TMoverParameters::TMoverParameters(double VelInitial, AnsiString TypeNameInit,
};
double TMoverParameters::Distance(const TLocation &Loc1, const TLocation &Loc2,
const TDimension &Dim1, const TDimension &Dim2)
const TDimension &Dim1, const TDimension &Dim2)
{ // zwraca odleg³oœæ pomiêdzy pojazdami (Loc1) i (Loc2) z uwzglêdnieneim ich d³ugoœci (kule!)
return hypot(Loc2.X - Loc1.X, Loc1.Y - Loc2.Y) - 0.5 * (Dim2.L + Dim1.L);
};
double TMoverParameters::Distance(const vector3 &s1, const vector3 &s2,
const vector3 &d1, const vector3 &d2){
double TMoverParameters::Distance(const vector3 &s1, const vector3 &s2, const vector3 &d1,
const vector3 &d2){
// obliczenie odleg³oœci prostopad³oœcianów o œrodkach (s1) i (s2) i wymiarach (d1) i (d2)
// return 0.0; //bêdzie zg³aszaæ warning - funkcja do usuniêcia, chyba ¿e siê przyda...
};
@@ -50,9 +49,8 @@ double TMoverParameters::CouplerDist(Byte Coupler)
Couplers[Coupler].Connected->Dim); // odleg³oœæ pomiêdzy sprzêgami (kula!)
};
bool TMoverParameters::Attach(Byte ConnectNo, Byte ConnectToNr,
TMoverParameters *ConnectTo, Byte CouplingType,
bool Forced)
bool TMoverParameters::Attach(Byte ConnectNo, Byte ConnectToNr, TMoverParameters *ConnectTo,
Byte CouplingType, bool Forced)
{ //³¹czenie do swojego sprzêgu (ConnectNo) pojazdu (ConnectTo) stron¹ (ConnectToNr)
// Ra: zwykle wykonywane dwukrotnie, dla ka¿dego pojazdu oddzielnie
// Ra: trzeba by odró¿niæ wymóg dociœniêcia od uszkodzenia sprzêgu przy podczepianiu AI do
@@ -91,12 +89,11 @@ bool TMoverParameters::Attach(Byte ConnectNo, Byte ConnectToNr,
}
}
return false; // brak pod³¹czanego pojazdu, zbyt du¿a odleg³oœæ, niezgodny typ sprzêgu, brak
// sprzêgu, brak haka
// sprzêgu, brak haka
};
bool TMoverParameters::Attach(Byte ConnectNo, Byte ConnectToNr,
T_MoverParameters *ConnectTo, Byte CouplingType,
bool Forced)
bool TMoverParameters::Attach(Byte ConnectNo, Byte ConnectToNr, T_MoverParameters *ConnectTo,
Byte CouplingType, bool Forced)
{ //³¹czenie do (ConnectNo) pojazdu (ConnectTo) stron¹ (ConnectToNr)
return Attach(ConnectNo, ConnectToNr, (TMoverParameters *)ConnectTo, CouplingType, Forced);
};
@@ -139,7 +136,7 @@ bool TMoverParameters::Dettach(Byte ConnectNo)
}
else if (i > 0)
{ // od³¹czamy wê¿e i resztê, pozostaje sprzêg fizyczny, który wymaga dociœniêcia (z wirtualnym
// nic)
// nic)
Couplers[ConnectNo].CouplingFlag &= ctrain_coupler;
Couplers[ConnectNo].Connected->Couplers[Couplers[ConnectNo].ConnectedNr].CouplingFlag =
Couplers[ConnectNo].CouplingFlag;
@@ -196,7 +193,7 @@ void TMoverParameters::BrakeLevelSet(double b)
else if (fBrakeCtrlPos > Handle->GetPos(bh_MAX))
fBrakeCtrlPos = Handle->GetPos(bh_MAX);
int x = floor(fBrakeCtrlPos); // jeœli odwo³ujemy siê do BrakeCtrlPos w poœrednich, to musi byæ
// obciête a nie zaokr¹gone
// obciête a nie zaokr¹gone
while ((x > BrakeCtrlPos) && (BrakeCtrlPos < BrakeCtrlPosNo)) // jeœli zwiêkszy³o siê o 1
if (!T_MoverParameters::IncBrakeLevelOld())
break; // wyjœcie awaryjne
@@ -234,10 +231,13 @@ bool TMoverParameters::BrakeLevelAdd(double b)
bool TMoverParameters::IncBrakeLevel()
{ // nowa wersja na u¿ytek AI, false gdy osi¹gniêto pozycjê BrakeCtrlPosNo
return BrakeLevelAdd(1.0); };
return BrakeLevelAdd(1.0);
};
bool TMoverParameters::DecBrakeLevel()
{ return BrakeLevelAdd(-1.0); }; // nowa wersja na u¿ytek AI, false gdy osi¹gniêto pozycjê -1
bool TMoverParameters::DecBrakeLevel()
{ // nowa wersja na u¿ytek AI, false gdy osi¹gniêto pozycjê -1
return BrakeLevelAdd(-1.0);
};
bool TMoverParameters::ChangeCab(int direction)
{ // zmiana kabiny i resetowanie ustawien
@@ -298,7 +298,7 @@ bool TMoverParameters::CurrentSwitch(int direction)
void TMoverParameters::UpdatePantVolume(double dt)
{ // KURS90 - sprê¿arka pantografów; Ra 2014-07: teraz jest to zbiornik rozrz¹du, chocia¿ to jeszcze
// nie tak
// nie tak
if (EnginePowerSource.SourceType == CurrentCollector) // tylko jeœli pantografuj¹cy
{
// Ra 2014-07: zasadniczo, to istnieje zbiornik rozrz¹du i zbiornik pantografów - na razie
@@ -310,7 +310,7 @@ void TMoverParameters::UpdatePantVolume(double dt)
if ((TrainType == dt_EZT) ? (PantPress < ScndPipePress) :
bPantKurek3) // kurek zamyka po³¹czenie z ZG
{ // zbiornik pantografu po³¹czony ze zbiornikiem g³ównym - ma³¹ sprê¿ark¹ siê tego nie
// napompuje
// napompuje
// Ra 2013-12: Niebugoc³aw mówi, ¿e w EZT nie ma potrzeby odcinaæ kurkiem
PantPress = EnginePowerSource.CollectorParameters
.MaxPress; // ograniczenie ciœnienia do MaxPress (tylko w pantografach!)
@@ -335,7 +335,7 @@ void TMoverParameters::UpdatePantVolume(double dt)
if ((TrainType & (dt_EZT | dt_ET40 | dt_ET41 | dt_ET42)) ?
(GetTrainsetVoltage() < EnginePowerSource.CollectorParameters.MinV) :
true) // to jest trochê proteza; zasilanie cz³onu mo¿e byæ przez sprzêg
// WN
// WN
if (MainSwitch(false))
EventFlag = true; // wywalenie szybkiego z powodu niskiego ciœnienia
if (TrainType != dt_EZT) // w EN57 pompuje siê tylko w silnikowym
@@ -377,7 +377,7 @@ void TMoverParameters::UpdateBatteryVoltage(double dt)
else
sn3 = 0;
if (iLights[0] & 63) // 64=blachy, nie ci¹gn¹ pr¹du //rozpisaæ na poszczególne
// ¿arówki...
// ¿arówki...
sn4 = dt * 0.003;
else
sn4 = 0;
@@ -475,9 +475,8 @@ ZN //masa
*/
double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShape &Shape,
TTrackParam &Track,
TTractionParam &ElectricTraction,
const TLocation &NewLoc, TRotation &NewRot)
TTrackParam &Track, TTractionParam &ElectricTraction,
const TLocation &NewLoc, TRotation &NewRot)
{ // trzeba po ma³u przenosiæ tu tê funkcjê
double d;
T_MoverParameters::ComputeMovement(dt, dt1, Shape, Track, ElectricTraction, NewLoc, NewRot);
@@ -554,8 +553,8 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap
};
double TMoverParameters::FastComputeMovement(double dt, const TTrackShape &Shape,
TTrackParam &Track, const TLocation &NewLoc,
TRotation &NewRot)
TTrackParam &Track, const TLocation &NewLoc,
TRotation &NewRot)
{ // trzeba po ma³u przenosiæ tu tê funkcjê
double d;
T_MoverParameters::FastComputeMovement(dt, Shape, Track, NewLoc, NewRot);

26
Mover.h
View File

@@ -36,7 +36,7 @@ class TMoverParameters : public T_MoverParameters
unsigned char WarningSignal; // tymczasowo 8bit, ze wzglêdu na funkcje w MTools
double fBrakeCtrlPos; // p³ynna nastawa hamulca zespolonego
bool bPantKurek3; // kurek trójdrogowy (pantografu): true=po³¹czenie z ZG, false=po³¹czenie z
// ma³¹ sprê¿ark¹
// ma³¹ sprê¿ark¹
int iProblem; // flagi problemów z taborem, aby AI nie musia³o porównywaæ; 0=mo¿e jechaæ
int iLights[2]; // bity zapalonych œwiate³ tutaj, ¿eby da³o siê liczyæ pobór pr¹du
private:
@@ -44,16 +44,16 @@ class TMoverParameters : public T_MoverParameters
public:
TMoverParameters(double VelInitial, AnsiString TypeNameInit, AnsiString NameInit,
int LoadInitial, AnsiString LoadTypeInitial, int Cab);
int LoadInitial, AnsiString LoadTypeInitial, int Cab);
// obs³uga sprzêgów
double Distance(const TLocation &Loc1, const TLocation &Loc2, const TDimension &Dim1,
const TDimension &Dim2);
const TDimension &Dim2);
double Distance(const vector3 &Loc1, const vector3 &Loc2, const vector3 &Dim1,
const vector3 &Dim2);
bool Attach(Byte ConnectNo, Byte ConnectToNr, TMoverParameters *ConnectTo,
Byte CouplingType, bool Forced = false);
bool Attach(Byte ConnectNo, Byte ConnectToNr, T_MoverParameters *ConnectTo,
Byte CouplingType, bool Forced = false);
const vector3 &Dim2);
bool Attach(Byte ConnectNo, Byte ConnectToNr, TMoverParameters *ConnectTo, Byte CouplingType,
bool Forced = false);
bool Attach(Byte ConnectNo, Byte ConnectToNr, T_MoverParameters *ConnectTo, Byte CouplingType,
bool Forced = false);
int DettachStatus(Byte ConnectNo);
bool Dettach(Byte ConnectNo);
void SetCoupleDist();
@@ -65,11 +65,11 @@ class TMoverParameters : public T_MoverParameters
bool ChangeCab(int direction);
bool CurrentSwitch(int direction);
void UpdateBatteryVoltage(double dt);
double ComputeMovement(double dt, double dt1, const TTrackShape &Shape,
TTrackParam &Track, TTractionParam &ElectricTraction,
const TLocation &NewLoc, TRotation &NewRot);
double ComputeMovement(double dt, double dt1, const TTrackShape &Shape, TTrackParam &Track,
TTractionParam &ElectricTraction, const TLocation &NewLoc,
TRotation &NewRot);
double FastComputeMovement(double dt, const TTrackShape &Shape, TTrackParam &Track,
const TLocation &NewLoc, TRotation &NewRot);
const TLocation &NewLoc, TRotation &NewRot);
double ShowEngineRotation(int VehN);
// double GetTrainsetVoltage(void);
// bool Physic_ReActivation(void);
@@ -170,7 +170,7 @@ class TMoverParameters : public T_MoverParameters
// TLocation &NewLoc, TRotation &NewRot);
// bool ChangeOffsetH(double DeltaOffset);
//__fastcall T_MoverParameters(double VelInitial, AnsiString TypeNameInit, AnsiString NameInit,
//int LoadInitial
// int LoadInitial
// , AnsiString LoadTypeInitial, int Cab);
// bool LoadChkFile(AnsiString chkpath);
// bool CheckLocomotiveParameters(bool ReadyFlag, int Dir);

13
Names.h
View File

@@ -26,8 +26,14 @@ class ItemRecord
// typedef
void ListGet(ItemRecord *r, int *&n);
void TreeAdd(ItemRecord *r, int c);
template <typename TOut> inline TOut *DataGet() { return (TOut *)pData; };
template <typename TOut> inline void DataSet(TOut *x) { pData = (void *)x; };
template <typename TOut> inline TOut *DataGet()
{
return (TOut *)pData;
};
template <typename TOut> inline void DataSet(TOut *x)
{
pData = (void *)x;
};
void *__fastcall TreeFind(const char *n);
ItemRecord *__fastcall TreeFindRecord(const char *n);
};
@@ -46,8 +52,7 @@ class TNames
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, int d); // dodanie obiektu z numerem
bool Update(int t, const char *n,
void *d); // dodanie jeœli nie ma, wymiana (d), gdy jest
bool Update(int t, const char *n, void *d); // dodanie jeœli nie ma, wymiana (d), gdy jest
void TreeSet();
ItemRecord *__fastcall TreeSet(int *n, int d, int u);
void Sort(int t); // przebudowa drzewa typu (t)

601
PyInt.cpp Normal file
View File

@@ -0,0 +1,601 @@
#include "PyInt.h"
#include "Train.h"
#include "Logs.h"
#include <process.h>
#include <windows.h>
#include <stdlib.h>
TPythonInterpreter *TPythonInterpreter::_instance = NULL;
//#define _PY_INT_MORE_LOG
TPythonInterpreter::TPythonInterpreter()
{
WriteLog("Loading Python ...");
Py_SetPythonHome("python");
Py_Initialize();
_main = PyImport_ImportModule("__main__");
if (_main == NULL)
{
WriteLog("Cannot import Python module __main__");
}
_screenRendererPriority = THREAD_PRIORITY_NORMAL; // domyslny priorytet normalny
PyObject *cStringModule = PyImport_ImportModule("cStringIO");
_stdErr = NULL;
if (cStringModule == NULL)
return;
PyObject *cStringClassName = PyObject_GetAttrString(cStringModule, "StringIO");
if (cStringClassName == NULL)
return;
PyObject *cString = PyObject_CallObject(cStringClassName, NULL);
if (cString == NULL)
return;
if (PySys_SetObject("stderr", cString) != 0)
return;
_stdErr = cString;
}
TPythonInterpreter *TPythonInterpreter::getInstance()
{
if (!_instance)
{
_instance = new TPythonInterpreter();
}
return _instance;
}
bool TPythonInterpreter::loadClassFile(const char *lookupPath, const char *className)
{
std::set<const char *, ltstr>::const_iterator it = _classes.find(className);
if (it == _classes.end())
{
FILE *sourceFile = _getFile(lookupPath, className);
if (sourceFile != NULL)
{
fseek(sourceFile, 0, SEEK_END);
long fsize = ftell(sourceFile);
char *buffer = (char *)calloc(fsize + 1, sizeof(char));
fseek(sourceFile, 0, SEEK_SET);
long freaded = fread(buffer, sizeof(char), fsize, sourceFile);
buffer[freaded] = 0; // z jakiegos powodu czytamy troche mniej i trzczeba dodac konczace
// zero do bufora (mimo ze calloc teoretycznie powiniene zwrocic
// wyzerowana pamiec)
#ifdef _PY_INT_MORE_LOG
char buf[255];
sprintf(buf, "readed %d / %d characters for %s", freaded, fsize, className);
WriteLog(buf);
#endif // _PY_INT_MORE_LOG
fclose(sourceFile);
if (PyRun_SimpleString(buffer) != 0)
{
handleError();
return false;
}
char *classNameToRemember = (char *)calloc(strlen(className) + 1, sizeof(char));
strcpy(classNameToRemember, className);
_classes.insert(classNameToRemember);
free(buffer);
return true;
}
return false;
}
return true;
}
PyObject *TPythonInterpreter::newClass(const char *className)
{
return newClass(className, NULL);
}
FILE *TPythonInterpreter::_getFile(const char *lookupPath, const char *className)
{
char *sourceFilePath;
if (lookupPath != NULL)
{
sourceFilePath = (char *)calloc(strlen(lookupPath) + strlen(className) + 4, sizeof(char));
strcat(sourceFilePath, lookupPath);
strcat(sourceFilePath, className);
strcat(sourceFilePath, ".py");
FILE *file = fopen(sourceFilePath, "r");
#ifdef _PY_INT_MORE_LOG
WriteLog(sourceFilePath);
#endif // _PY_INT_MORE_LOG
free(sourceFilePath);
if (file != NULL)
{
return file;
}
}
char *basePath = "python\\local\\";
sourceFilePath = (char *)calloc(strlen(basePath) + strlen(className) + 4, sizeof(char));
strcat(sourceFilePath, basePath);
strcat(sourceFilePath, className);
strcat(sourceFilePath, ".py");
FILE *file = fopen(sourceFilePath, "r");
#ifdef _PY_INT_MORE_LOG
WriteLog(sourceFilePath);
#endif // _PY_INT_MORE_LOG
free(sourceFilePath);
if (file != NULL)
{
return file;
}
return NULL;
}
void TPythonInterpreter::handleError()
{
#ifdef _PY_INT_MORE_LOG
WriteLog("Python Error occured");
#endif // _PY_INT_MORE_LOG
if (_stdErr != NULL)
{ // std err pythona jest buforowane
PyErr_Print();
PyObject *bufferContent = PyObject_CallMethod(_stdErr, "getvalue", NULL);
PyObject_CallMethod(_stdErr, "truncate", "i", 0); // czyscimy bufor na kolejne bledy
WriteLog(PyString_AsString(bufferContent));
}
else
{ // nie dziala buffor pythona
if (PyErr_Occurred() != NULL)
{
PyObject *ptype, *pvalue, *ptraceback;
PyErr_Fetch(&ptype, &pvalue, &ptraceback);
if (ptype == NULL)
{
WriteLog("Don't konw how to handle NULL exception");
}
PyErr_NormalizeException(&ptype, &pvalue, &ptraceback);
if (ptype == NULL)
{
WriteLog("Don't konw how to handle NULL exception");
}
PyObject *pStrType = PyObject_Str(ptype);
if (pStrType != NULL)
{
WriteLog(PyString_AsString(pStrType));
}
WriteLog(PyString_AsString(pvalue));
PyObject *pStrTraceback = PyObject_Str(ptraceback);
if (pStrTraceback != NULL)
{
WriteLog(PyString_AsString(pStrTraceback));
}
else
{
WriteLog("Python Traceback cannot be shown");
}
}
else
{
#ifdef _PY_INT_MORE_LOG
WriteLog("Called python error handler when no error occured!");
#endif // _PY_INT_MORE_LOG
}
}
}
PyObject *TPythonInterpreter::newClass(const char *className, PyObject *argsTuple)
{
if (_main == NULL)
{
WriteLog("main turned into null");
return NULL;
}
PyObject *classNameObj = PyObject_GetAttrString(_main, className);
if (classNameObj == NULL)
{
#ifdef _PY_INT_MORE_LOG
char buf[255];
sprintf(buf, "Python class %s not defined!", className);
WriteLog(buf);
#endif // _PY_INT_MORE_LOG
return NULL;
}
PyObject *object = PyObject_CallObject(classNameObj, argsTuple);
if (PyErr_Occurred() != NULL)
{
handleError();
return NULL;
}
return object;
}
void TPythonInterpreter::setScreenRendererPriority(const char *priority)
{
if (strncmp(priority, "normal", 6) == 0)
{
_screenRendererPriority = THREAD_PRIORITY_NORMAL;
#ifdef _PY_INT_MORE_LOG
WriteLog("Python screen renderer priority: Normal");
#endif // _PY_INT_MORE_LOG
}
else if (strncmp(priority, "lower", 5) == 0)
{
_screenRendererPriority = THREAD_PRIORITY_BELOW_NORMAL;
#ifdef _PY_INT_MORE_LOG
WriteLog("Python screen renderer priority: Lower");
#endif // _PY_INT_MORE_LOG
}
else if (strncmp(priority, "lowest", 6) == 0)
{
_screenRendererPriority = THREAD_PRIORITY_LOWEST;
#ifdef _PY_INT_MORE_LOG
WriteLog("Python screen renderer priority: Lowest");
#endif // _PY_INT_MORE_LOG
}
else if (strncmp(priority, "idle", 4) == 0)
{
_screenRendererPriority = THREAD_PRIORITY_IDLE;
#ifdef _PY_INT_MORE_LOG
WriteLog("Python screen renderer priority: Idle");
#endif // _PY_INT_MORE_LOG
}
}
TPythonScreenRenderer::TPythonScreenRenderer(int textureId, PyObject *renderer)
{
_textureId = textureId;
_pyRenderer = renderer;
}
void TPythonScreenRenderer::updateTexture()
{
int width, height;
if (_pyWidth == NULL || _pyHeight == NULL)
{
WriteLog("Unknown python texture size!");
return;
}
width = PyInt_AsLong(_pyWidth);
height = PyInt_AsLong(_pyHeight);
if (_pyTexture != NULL)
{
char *textureData = PyString_AsString(_pyTexture);
if (textureData != NULL)
{
#ifdef _PY_INT_MORE_LOG
char buff[255];
sprintf(buff, "Sending texture id: %d w: %d h: %d", _textureId, width, height);
WriteLog(buff);
#endif // _PY_INT_MORE_LOG
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glBindTexture(GL_TEXTURE_2D, _textureId);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE,
textureData);
#ifdef _PY_INT_MORE_LOG
GLenum status = glGetError();
switch (status)
{
case GL_INVALID_ENUM:
WriteLog("An unacceptable value is specified for an enumerated argument. The "
"offending function is ignored, having no side effect other than to set "
"the error flag.");
break;
case GL_INVALID_VALUE:
WriteLog("A numeric argument is out of range. The offending function is ignored, "
"having no side effect other than to set the error flag.");
break;
case GL_INVALID_OPERATION:
WriteLog("The specified operation is not allowed in the current state. The "
"offending function is ignored, having no side effect other than to set "
"the error flag.");
break;
case GL_NO_ERROR:
WriteLog("No error has been recorded. The value of this symbolic constant is "
"guaranteed to be zero.");
break;
case GL_STACK_OVERFLOW:
WriteLog("This function would cause a stack overflow. The offending function is "
"ignored, having no side effect other than to set the error flag.");
break;
case GL_STACK_UNDERFLOW:
WriteLog("This function would cause a stack underflow. The offending function is "
"ignored, having no side effect other than to set the error flag.");
break;
case GL_OUT_OF_MEMORY:
WriteLog("There is not enough memory left to execute the function. The state of "
"OpenGL is undefined, except for the state of the error flags, after this "
"error is recorded.");
break;
};
#endif // _PY_INT_MORE_LOG
}
else
{
WriteLog("RAW python texture data is NULL!");
}
}
else
{
WriteLog("Python texture object is NULL!");
}
}
void TPythonScreenRenderer::render(PyObject *trainState)
{
#ifdef _PY_INT_MORE_LOG
WriteLog("Python rendering texture ...");
#endif // _PY_INT_MORE_LOG
_pyTexture = PyObject_CallMethod(_pyRenderer, "render", "O", trainState);
if (_pyTexture == NULL)
{
TPythonInterpreter::getInstance()->handleError();
}
else
{
_pyWidth = PyObject_CallMethod(_pyRenderer, "get_width", NULL);
if (_pyWidth == NULL)
{
TPythonInterpreter::getInstance()->handleError();
}
_pyHeight = PyObject_CallMethod(_pyRenderer, "get_height", NULL);
if (_pyHeight == NULL)
{
TPythonInterpreter::getInstance()->handleError();
}
}
}
TPythonScreenRenderer::~TPythonScreenRenderer()
{
#ifdef _PY_INT_MORE_LOG
WriteLog("PythonScreenRenderer descturctor called");
#endif // _PY_INT_MORE_LOG
if (_pyRenderer != NULL)
{
Py_CLEAR(_pyRenderer);
}
cleanup();
#ifdef _PY_INT_MORE_LOG
WriteLog("PythonScreenRenderer desctructor finished");
#endif // _PY_INT_MORE_LOG
}
void TPythonScreenRenderer::cleanup()
{
if (_pyTexture != NULL)
{
Py_CLEAR(_pyTexture);
_pyTexture = NULL;
}
if (_pyWidth != NULL)
{
Py_CLEAR(_pyWidth);
_pyWidth = NULL;
}
if (_pyHeight != NULL)
{
Py_CLEAR(_pyHeight);
_pyHeight = NULL;
}
}
void TPythonScreens::reset(void *train)
{
_terminationFlag = true;
if (_thread != NULL)
{
WriteLog("Awaiting python thread to end");
WaitForSingleObject(_thread, INFINITE);
_thread = NULL;
}
_terminationFlag = false;
_cleanupReadyFlag = false;
_renderReadyFlag = false;
for (std::vector<TPythonScreenRenderer *>::iterator i = _screens.begin(); i != _screens.end();
++i)
{
delete *i;
}
#ifdef _PY_INT_MORE_LOG
WriteLog("Clearing renderer vector");
#endif // _PY_INT_MORE_LOG
_screens.clear();
_train = train;
}
void TPythonScreens::init(TQueryParserComp *parser, TModel3d *model, AnsiString name, int cab)
{
char buff[255];
AnsiString asSubModelName = parser->GetNextSymbol();
AnsiString asPyClassName = parser->GetNextSymbol();
char *subModelName = (char *)calloc(asSubModelName.Length() + 1, sizeof(char));
strcpy(subModelName, asSubModelName.LowerCase().c_str());
char *pyClassName = (char *)calloc(asPyClassName.Length() + 1, sizeof(char));
strcpy(pyClassName, asPyClassName.LowerCase().c_str());
TSubModel *subModel = model->GetFromName(subModelName);
if (subModel == NULL)
{
sprintf(buff, "Python Screen: submodel %s not found - Ignoring screen", subModelName);
WriteLog(buff);
free(subModelName);
free(pyClassName);
return; // nie ma takiego sub modelu w danej kabinie pomijamy
}
int textureId = subModel->GetTextureId();
if (textureId <= 0)
{
sprintf(buff, "Python Screen: invalid texture id %d - Ignoring screen", textureId);
WriteLog(buff);
free(subModelName);
free(pyClassName);
return; // sub model nie posiada tekstury lub tekstura wymienna - nie obslugiwana
}
TPythonInterpreter *python = TPythonInterpreter::getInstance();
python->loadClassFile(_lookupPath, pyClassName);
PyObject *args = Py_BuildValue("(ssi)", _lookupPath, name.c_str(), cab);
if (args == NULL)
{
WriteLog("Python Screen: cannot create __init__ arguments");
free(subModelName);
free(pyClassName);
return;
}
PyObject *pyRenderer = python->newClass(pyClassName, args);
Py_CLEAR(args);
if (pyRenderer == NULL)
{
sprintf(buff, "Python Screen: null renderer for %s - Ignoring screen", pyClassName);
WriteLog(buff);
free(subModelName);
free(pyClassName);
return; // nie mozna utworzyc obiektu Pythonowego
}
TPythonScreenRenderer *renderer = new TPythonScreenRenderer(textureId, pyRenderer);
_screens.push_back(renderer);
sprintf(buff, "Created python screen %s on submodel %s (%d)", pyClassName, subModelName,
textureId);
WriteLog(buff);
free(subModelName);
free(pyClassName);
}
void TPythonScreens::update()
{
if (!_renderReadyFlag)
{
return;
}
_renderReadyFlag = false;
for (std::vector<TPythonScreenRenderer *>::iterator i = _screens.begin(); i != _screens.end();
++i)
{
(*i)->updateTexture();
}
_cleanupReadyFlag = true;
}
void TPythonScreens::setLookupPath(AnsiString path)
{
if (_lookupPath != NULL)
{
free(_lookupPath);
}
_lookupPath = (char *)calloc(path.Length() + 1, sizeof(char));
strcpy(_lookupPath, path.c_str());
}
TPythonScreens::TPythonScreens()
{
_lookupPath = NULL;
TPythonInterpreter::getInstance()->loadClassFile(NULL, "abstractscreenrenderer");
_terminationFlag = false;
_renderReadyFlag = false;
_cleanupReadyFlag = false;
_thread = NULL;
}
TPythonScreens::~TPythonScreens()
{
#ifdef _PY_INT_MORE_LOG
WriteLog("Called python sceeens destructor");
#endif // _PY_INT_MORE_LOG
reset(NULL);
if (_lookupPath != NULL)
{
#ifdef _PY_INT_MORE_LOG
WriteLog("Freeing lookup path");
#endif // _PY_INT_MORE_LOG
free(_lookupPath);
}
}
void TPythonScreens::run()
{
while (1)
{
if (_terminationFlag)
{
return;
}
TTrain *train = (TTrain *)_train;
_trainState = train->GetTrainState();
if (_terminationFlag)
{
_freeTrainState();
return;
}
for (std::vector<TPythonScreenRenderer *>::iterator i = _screens.begin();
i != _screens.end(); ++i)
{
(*i)->render(_trainState);
}
_freeTrainState();
if (_terminationFlag)
{
_cleanup();
return;
}
_renderReadyFlag = true;
while (!_cleanupReadyFlag && !_terminationFlag)
{
Sleep(100);
}
if (_terminationFlag)
{
return;
}
_cleanup();
}
}
void TPythonScreens::finish()
{
_thread == NULL;
}
DWORD WINAPI ScreenRendererThread(LPVOID lpParam)
{
TPythonScreens *renderer = (TPythonScreens *)lpParam;
renderer->run();
renderer->finish();
#ifdef _PY_INT_MORE_LOG
WriteLog("Python Screen Renderer Thread Ends");
#endif // _PY_INT_MORE_LOG
return true;
}
void TPythonScreens::start()
{
if (_screens.size() > 0)
{
_thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ScreenRendererThread, this,
CREATE_SUSPENDED, &_threadId);
if (_thread != NULL)
{
SetThreadPriority(_thread,
TPythonInterpreter::getInstance()->getScreenRendererPriotity());
if (ResumeThread(_thread) != (DWORD)-1)
{
return;
}
}
WriteLog("Python Screen Renderer Thread Did Not Start");
}
}
void TPythonScreens::_cleanup()
{
_cleanupReadyFlag = false;
for (std::vector<TPythonScreenRenderer *>::iterator i = _screens.begin(); i != _screens.end();
++i)
{
(*i)->cleanup();
}
}
void TPythonScreens::_freeTrainState()
{
if (_trainState != NULL)
{
PyDict_Clear(_trainState);
Py_CLEAR(_trainState);
_trainState = NULL;
}
}

95
PyInt.h Normal file
View File

@@ -0,0 +1,95 @@
#ifndef PyIntH
#define PyIntH
#undef _DEBUG // bez tego macra Py_DECREF powoduja problemy przy linkowaniu
#include "Python.h"
#include "QueryParserComp.hpp"
#include "Model3d.h"
#include <vector>
#include <set>
#define PyGetFloat(param) PyFloat_FromDouble(param >= 0 ? param : -param)
#define PyGetInt(param) PyInt_FromLong(param)
#define PyGetBool(param) param ? Py_True : Py_False
struct ltstr
{
bool operator()(const char *s1, const char *s2) const
{
return strcmp(s1, s2) < 0;
}
};
class TPythonInterpreter
{
protected:
TPythonInterpreter();
~TPythonInterpreter()
{
}
static TPythonInterpreter *_instance;
int _screenRendererPriority;
std::set<const char *, ltstr> _classes;
PyObject *_main;
PyObject *_stdErr;
FILE *_getFile(const char *lookupPath, const char *className);
public:
static TPythonInterpreter *getInstance();
bool loadClassFile(const char *lookupPath, const char *className);
PyObject *newClass(const char *className);
PyObject *newClass(const char *className, PyObject *argsTuple);
int getScreenRendererPriotity()
{
return _screenRendererPriority;
};
void setScreenRendererPriority(const char *priority);
void handleError();
};
class TPythonScreenRenderer
{
protected:
PyObject *_pyRenderer;
PyObject *_pyTexture;
int _textureId;
PyObject *_pyWidth;
PyObject *_pyHeight;
public:
TPythonScreenRenderer(int textureId, PyObject *renderer);
~TPythonScreenRenderer();
void render(PyObject *trainState);
void cleanup();
void updateTexture();
};
class TPythonScreens
{
protected:
bool _cleanupReadyFlag;
bool _renderReadyFlag;
bool _terminationFlag;
HANDLE _thread;
DWORD _threadId;
std::vector<TPythonScreenRenderer *> _screens;
char *_lookupPath;
void *_train;
void _cleanup();
void _freeTrainState();
PyObject *_trainState;
public:
void reset(void *train);
void setLookupPath(AnsiString path);
void init(TQueryParserComp *parser, TModel3d *model, AnsiString name, int cab);
void update();
TPythonScreens();
~TPythonScreens();
void run();
void start();
void finish();
};
#endif // PyIntH

View File

@@ -45,10 +45,12 @@ TRealSound::~TRealSound()
// if (this) if (pSound) pSound->Stop();
}
void TRealSound::Free() {}
void TRealSound::Free()
{
}
void TRealSound::Init(char *SoundName, double DistanceAttenuation, double X, double Y,
double Z, bool Dynamic, bool freqmod, double rmin)
void TRealSound::Init(char *SoundName, double DistanceAttenuation, double X, double Y, double Z,
bool Dynamic, bool freqmod, double rmin)
{
// Nazwa=SoundName; //to tak raczej nie zadziała, (SoundName) jest tymczasowe
pSound = TSoundsManager::GetFromName(SoundName, Dynamic, &fFrequency);
@@ -57,7 +59,7 @@ void TRealSound::Init(char *SoundName, double DistanceAttenuation, double X, dou
if (freqmod)
if (fFrequency != 22050.0)
{ // dla modulowanych nie może być zmiany mnożnika, bo częstotliwość w nagłówku byłą
// ignorowana, a mogła być inna niż 22050
// ignorowana, a mogła być inna niż 22050
fFrequency = 22050.0;
ErrorLog("Bad sound: " + AnsiString(SoundName) +
", as modulated, should have 22.05kHz in header");
@@ -95,8 +97,7 @@ double TRealSound::ListenerDistance(vector3 ListenerPosition)
}
}
void TRealSound::Play(double Volume, int Looping, bool ListenerInside,
vector3 NewPosition)
void TRealSound::Play(double Volume, int Looping, bool ListenerInside, vector3 NewPosition)
{
if (!pSound)
return;
@@ -168,7 +169,8 @@ void TRealSound::Play(double Volume, int Looping, bool ListenerInside,
}
};
void TRealSound::Start(){// włączenie dźwięku
void TRealSound::Start(){
// włączenie dźwięku
};
@@ -185,8 +187,7 @@ void TRealSound::Stop()
}
};
void TRealSound::AdjFreq(double Freq,
double dt) // McZapkie TODO: dorobic tu efekt Dopplera
void TRealSound::AdjFreq(double Freq, double dt) // McZapkie TODO: dorobic tu efekt Dopplera
// Freq moze byc liczba dodatnia mniejsza od 1 lub wieksza od 1
{
float df, Vlist, Vsrc;
@@ -223,7 +224,10 @@ double TRealSound::GetWaveTime() // McZapkie: na razie tylko dla 22KHz/8bps
fFrequency; //(pSound->); // wielkosc w bajtach przez czestotliwosc probkowania
}
void TRealSound::SetPan(int Pan) { pSound->SetPan(Pan); }
void TRealSound::SetPan(int Pan)
{
pSound->SetPan(Pan);
}
int TRealSound::GetStatus()
{
@@ -243,8 +247,8 @@ void TRealSound::ResetPosition()
pSound->SetCurrentPosition(0);
}
void TTextSound::Init(char *SoundName, double SoundAttenuation, double X, double Y,
double Z, bool Dynamic, bool freqmod, double rmin)
void TTextSound::Init(char *SoundName, double SoundAttenuation, double X, double Y, double Z,
bool Dynamic, bool freqmod, double rmin)
{ // dodatkowo doczytuje plik tekstowy
TRealSound::Init(SoundName, SoundAttenuation, X, Y, Z, Dynamic, freqmod, rmin);
fTime = GetWaveTime();
@@ -264,8 +268,7 @@ void TTextSound::Init(char *SoundName, double SoundAttenuation, double X, double
delete ts;
}
};
void TTextSound::Play(double Volume, int Looping, bool ListenerInside,
vector3 NewPosition)
void TTextSound::Play(double Volume, int Looping, bool ListenerInside, vector3 NewPosition)
{
if (!asText.IsEmpty())
{ // jeśli ma powiązany tekst

View File

@@ -32,8 +32,8 @@ class TRealSound
TRealSound();
~TRealSound();
void Free();
void Init(char *SoundName, double SoundAttenuation, double X, double Y, double Z,
bool Dynamic, bool freqmod = false, double rmin = 0.0);
void Init(char *SoundName, double SoundAttenuation, double X, double Y, double Z, bool Dynamic,
bool freqmod = false, double rmin = 0.0);
double ListenerDistance(vector3 ListenerPosition);
void Play(double Volume, int Looping, bool ListenerInside, vector3 NewPosition);
void Start();
@@ -51,8 +51,8 @@ class TTextSound : public TRealSound
AnsiString asText;
float fTime; // czas trwania
public:
void Init(char *SoundName, double SoundAttenuation, double X, double Y, double Z,
bool Dynamic, bool freqmod = false, double rmin = 0.0);
void Init(char *SoundName, double SoundAttenuation, double X, double Y, double Z, bool Dynamic,
bool freqmod = false, double rmin = 0.0);
void Play(double Volume, int Looping, bool ListenerInside, vector3 NewPosition);
};

View File

@@ -17,7 +17,10 @@ double ResourceManager::_expiry = 5.0f;
double ResourceManager::_lastUpdate = 0.0f;
double ResourceManager::_lastReport = 0.0f;
void ResourceManager::Register(Resource *resource) { _resources.push_back(resource); };
void ResourceManager::Register(Resource *resource)
{
_resources.push_back(resource);
};
void ResourceManager::Unregister(Resource *resource)
{
@@ -33,7 +36,10 @@ class ResourceExpired
{
public:
ResourceExpired(double time) : _time(time){};
bool operator()(Resource *resource) { return (resource->GetLastUsage() < _time); }
bool operator()(Resource *resource)
{
return (resource->GetLastUsage() < _time);
}
private:
double _time;

View File

@@ -20,10 +20,16 @@ class Resource
public:
virtual void Release() = 0;
double GetLastUsage() const { return _lastUsage; }
double GetLastUsage() const
{
return _lastUsage;
}
protected:
void SetLastUsage(double lastUsage) { _lastUsage = lastUsage; }
void SetLastUsage(double lastUsage)
{
_lastUsage = lastUsage;
}
private:
double _lastUsage;
@@ -37,7 +43,10 @@ class ResourceManager
static void Unregister(Resource *resource);
static void Sweep(double currentTime);
static void SetExpiry(double expiry) { _expiry = expiry; }
static void SetExpiry(double expiry)
{
_expiry = expiry;
}
private:
typedef std::vector<Resource *> Resources;

View File

@@ -41,10 +41,13 @@ TSegment::TSegment(TTrack *owner)
pOwner = owner;
};
TSegment::~TSegment() { SafeDeleteArray(fTsBuffer); };
TSegment::~TSegment()
{
SafeDeleteArray(fTsBuffer);
};
bool TSegment::Init(vector3 NewPoint1, vector3 NewPoint2, double fNewStep,
double fNewRoll1, double fNewRoll2)
bool TSegment::Init(vector3 NewPoint1, vector3 NewPoint2, double fNewStep, double fNewRoll1,
double fNewRoll2)
{ // wersja dla prostego - wyliczanie punktów kontrolnych
vector3 dir;
if (fNewRoll1 == fNewRoll2)
@@ -62,8 +65,8 @@ bool TSegment::Init(vector3 NewPoint1, vector3 NewPoint2, double fNewStep,
};
bool TSegment::Init(vector3 &NewPoint1, vector3 NewCPointOut, vector3 NewCPointIn,
vector3 &NewPoint2, double fNewStep, double fNewRoll1,
double fNewRoll2, bool bIsCurve)
vector3 &NewPoint2, double fNewStep, double fNewRoll1, double fNewRoll2,
bool bIsCurve)
{ // wersja uniwersalna (dla krzywej i prostego)
Point1 = NewPoint1;
CPointOut = NewCPointOut;
@@ -329,9 +332,8 @@ vector3 TSegment::FastGetPoint(double t)
return (bCurve ? RaInterpolate(t) : ((1.0 - t) * Point1 + (t)*Point2));
}
void TSegment::RenderLoft(const vector6 *ShapePoints, int iNumShapePoints,
double fTextureLength, int iSkip, int iQualityFactor,
vector3 **p, bool bRender)
void TSegment::RenderLoft(const vector6 *ShapePoints, int iNumShapePoints, double fTextureLength,
int iSkip, int iQualityFactor, vector3 **p, bool bRender)
{ // generowanie trójkątów dla odcinka trajektorii ruchu
// standardowo tworzy triangle_strip dla prostego albo ich zestaw dla łuku
// po modyfikacji - dla ujemnego (iNumShapePoints) w dodatkowych polach tabeli
@@ -401,7 +403,7 @@ void TSegment::RenderLoft(const vector6 *ShapePoints, int iNumShapePoints,
pt.y += jmm1 * ShapePoints[j].y + m1 * ShapePoints[j + iNumShapePoints].y;
if (bRender)
{ // skrzyżowania podczas łączenia siatek mogą nie renderować poboczy, ale
// potrzebować punktów
// potrzebować punktów
glNormal3f(norm.x, norm.y, norm.z);
glTexCoord2f(
jmm1 * ShapePoints[j].z + m1 * ShapePoints[j + iNumShapePoints].z, tv1);
@@ -424,7 +426,7 @@ void TSegment::RenderLoft(const vector6 *ShapePoints, int iNumShapePoints,
pt.y += jmm2 * ShapePoints[j].y + m2 * ShapePoints[j + iNumShapePoints].y;
if (bRender)
{ // skrzyżowania podczas łączenia siatek mogą nie renderować poboczy, ale
// potrzebować punktów
// potrzebować punktów
glNormal3f(norm.x, norm.y, norm.z);
glTexCoord2f(
jmm2 * ShapePoints[j].z + m2 * ShapePoints[j + iNumShapePoints].z, tv2);
@@ -511,8 +513,8 @@ void TSegment::RenderLoft(const vector6 *ShapePoints, int iNumShapePoints,
};
void TSegment::RenderSwitchRail(const vector6 *ShapePoints1, const vector6 *ShapePoints2,
int iNumShapePoints, double fTextureLength, int iSkip,
double fOffsetX)
int iNumShapePoints, double fTextureLength, int iSkip,
double fOffsetX)
{ // tworzenie siatki trójkątów dla iglicy
vector3 pos1, pos2, dir, parallel1, parallel2, pt;
double a1, a2, s, step, offset, tv1, tv2, t, t2, t2step, oldt2, sp, oldsp;
@@ -696,9 +698,8 @@ void TSegment::Render()
}
}
void TSegment::RaRenderLoft(CVertNormTex *&Vert, const vector6 *ShapePoints,
int iNumShapePoints, double fTextureLength, int iSkip,
int iEnd, double fOffsetX)
void TSegment::RaRenderLoft(CVertNormTex *&Vert, const vector6 *ShapePoints, int iNumShapePoints,
double fTextureLength, int iSkip, int iEnd, double fOffsetX)
{ // generowanie trójkątów dla odcinka trajektorii ruchu
// standardowo tworzy triangle_strip dla prostego albo ich zestaw dla łuku
// po modyfikacji - dla ujemnego (iNumShapePoints) w dodatkowych polach tabeli
@@ -896,9 +897,8 @@ void TSegment::RaRenderLoft(CVertNormTex *&Vert, const vector6 *ShapePoints,
}
};
void TSegment::RaAnimate(CVertNormTex *&Vert, const vector6 *ShapePoints,
int iNumShapePoints, double fTextureLength, int iSkip, int iEnd,
double fOffsetX)
void TSegment::RaAnimate(CVertNormTex *&Vert, const vector6 *ShapePoints, int iNumShapePoints,
double fTextureLength, int iSkip, int iEnd, double fOffsetX)
{ // jak wyżej, tylko z pominięciem mapowania i braku trapezowania
vector3 pos1, pos2, dir, parallel1, parallel2, pt;
double s, step, fOffset, t, fEnd;

View File

@@ -77,22 +77,36 @@ class TSegment
// (0-Bezier,1-prosty,2/3-³uk w lewo/prawo,6/7-przejœciowa w lewo/prawo)
TSegment(TTrack *owner);
~TSegment();
bool Init(vector3 NewPoint1, vector3 NewPoint2, double fNewStep,
double fNewRoll1 = 0, double fNewRoll2 = 0);
bool Init(vector3 &NewPoint1, vector3 NewCPointOut, vector3 NewCPointIn,
vector3 &NewPoint2, double fNewStep, double fNewRoll1 = 0,
double fNewRoll2 = 0, bool bIsCurve = true);
bool Init(vector3 NewPoint1, vector3 NewPoint2, double fNewStep, double fNewRoll1 = 0,
double fNewRoll2 = 0);
bool Init(vector3 &NewPoint1, vector3 NewCPointOut, vector3 NewCPointIn, vector3 &NewPoint2,
double fNewStep, double fNewRoll1 = 0, double fNewRoll2 = 0, bool bIsCurve = true);
inline double ComputeLength(); // McZapkie-150503
inline vector3 GetDirection1() { return bCurve ? CPointOut - Point1 : CPointOut; };
inline vector3 GetDirection2() { return bCurve ? CPointIn - Point2 : CPointIn; };
inline vector3 GetDirection1()
{
return bCurve ? CPointOut - Point1 : CPointOut;
};
inline vector3 GetDirection2()
{
return bCurve ? CPointIn - Point2 : CPointIn;
};
vector3 GetDirection(double fDistance);
vector3 GetDirection() { return CPointOut; };
vector3 GetDirection()
{
return CPointOut;
};
vector3 FastGetDirection(double fDistance, double fOffset);
vector3 GetPoint(double fDistance);
void RaPositionGet(double fDistance, vector3 &p, vector3 &a);
vector3 FastGetPoint(double t);
inline vector3 FastGetPoint_0() { return Point1; };
inline vector3 FastGetPoint_1() { return Point2; };
inline vector3 FastGetPoint_0()
{
return Point1;
};
inline vector3 FastGetPoint_1()
{
return Point2;
};
inline double GetRoll(double s)
{
s /= fLength;
@@ -103,14 +117,16 @@ class TSegment
r1 = fRoll1;
r2 = fRoll2;
}
void RenderLoft(const vector6 *ShapePoints, int iNumShapePoints,
double fTextureLength, int iSkip = 0, int iQualityFactor = 1,
vector3 **p = NULL, bool bRender = true);
void RenderLoft(const vector6 *ShapePoints, int iNumShapePoints, double fTextureLength,
int iSkip = 0, int iQualityFactor = 1, vector3 **p = NULL, bool bRender = true);
void RenderSwitchRail(const vector6 *ShapePoints1, const vector6 *ShapePoints2,
int iNumShapePoints, double fTextureLength, int iSkip = 0,
double fOffsetX = 0.0f);
int iNumShapePoints, double fTextureLength, int iSkip = 0,
double fOffsetX = 0.0f);
void Render();
inline double GetLength() { return fLength; };
inline double GetLength()
{
return fLength;
};
void MoveMe(vector3 pPosition)
{
Point1 += pPosition;
@@ -121,14 +137,18 @@ class TSegment
CPointOut += pPosition;
}
}
int RaSegCount() { return fTsBuffer ? iSegCount : 1; };
void RaRenderLoft(CVertNormTex *&Vert, const vector6 *ShapePoints,
int iNumShapePoints, double fTextureLength, int iSkip = 0,
int iEnd = 0, double fOffsetX = 0.0);
int RaSegCount()
{
return fTsBuffer ? iSegCount : 1;
};
void RaRenderLoft(CVertNormTex *&Vert, const vector6 *ShapePoints, int iNumShapePoints,
double fTextureLength, int iSkip = 0, int iEnd = 0, double fOffsetX = 0.0);
void RaAnimate(CVertNormTex *&Vert, const vector6 *ShapePoints, int iNumShapePoints,
double fTextureLength, int iSkip = 0, int iEnd = 0,
double fOffsetX = 0.0);
void AngleSet(int i, double a) { fAngle[i] = a; };
double fTextureLength, int iSkip = 0, int iEnd = 0, double fOffsetX = 0.0);
void AngleSet(int i, double a)
{
fAngle[i] = a;
};
void Rollment(double w1, double w2); // poprawianie przechy³ki
};

View File

@@ -34,7 +34,7 @@ int TSoundsManager::Count = 0;
TSoundContainer *TSoundsManager::First = NULL;
TSoundContainer::TSoundContainer(LPDIRECTSOUND pDS, char *Directory, char *strFileName,
int NConcurrent)
int NConcurrent)
{ // wczytanie pliku dŸwiêkowego
int hr = 111;
DSBuffer = NULL; // na pocz¹tek, gdyby uruchomiæ dŸwiêków siê nie uda³o
@@ -94,7 +94,7 @@ TSoundContainer::TSoundContainer(LPDIRECTSOUND pDS, char *Directory, char *strFi
//----------------------------------------------------------
BYTE *pbWavData; // Pointer to actual wav data
UINT cbWavSize; // Size of data
UINT cbWavSize; // Size of data
VOID *pbData = NULL;
VOID *pbData2 = NULL;
DWORD dwLength;
@@ -171,7 +171,10 @@ LPDIRECTSOUNDBUFFER TSoundContainer::GetUnique(LPDIRECTSOUND pDS)
return DSBuffers.top();
};
TSoundsManager::~TSoundsManager() { Free(); };
TSoundsManager::~TSoundsManager()
{
Free();
};
void TSoundsManager::Free()
{
@@ -200,8 +203,7 @@ void TSoundsManager::LoadSounds(char *Directory)
FindClose(handle);
};
LPDIRECTSOUNDBUFFER TSoundsManager::GetFromName(char *Name, bool Dynamic,
float *fSamplingRate)
LPDIRECTSOUNDBUFFER TSoundsManager::GetFromName(char *Name, bool Dynamic, float *fSamplingRate)
{ // wyszukanie dŸwiêku w pamiêci albo wczytanie z pliku
AnsiString file;
if (Dynamic)

View File

@@ -39,8 +39,7 @@ class TSoundContainer
TSoundContainer *Next;
std::stack<LPDIRECTSOUNDBUFFER> DSBuffers;
LPDIRECTSOUNDBUFFER GetUnique(LPDIRECTSOUND pDS);
TSoundContainer(LPDIRECTSOUND pDS, char *Directory, char *strFileName,
int NConcurrent);
TSoundContainer(LPDIRECTSOUND pDS, char *Directory, char *strFileName, int NConcurrent);
~TSoundContainer();
};
@@ -62,8 +61,7 @@ class TSoundsManager
static void Free();
static void Init(char *Name, int Concurrent);
static void LoadSounds(char *Directory);
static LPDIRECTSOUNDBUFFER GetFromName(char *Name, bool Dynamic,
float *fSamplingRate = NULL);
static LPDIRECTSOUNDBUFFER GetFromName(char *Name, bool Dynamic, float *fSamplingRate = NULL);
static void RestoreAll();
};

View File

@@ -73,7 +73,9 @@ __fastcall TKnot::TKnot(int n)
}
}
__fastcall TKnot::~TKnot() {}
__fastcall TKnot::~TKnot()
{
}
vector3 TKnot::GetDirection(float t)
{

View File

@@ -24,7 +24,9 @@ TSpring::TSpring()
restLen = 0;
}
TSpring::~TSpring() {}
TSpring::~TSpring()
{
}
void TSpring::Init(double nrestLen, double nKs, double nKd)
{
@@ -43,7 +45,7 @@ bool TSpring::ComputateForces(vector3 pPosition1, vector3 pPosition2)
// VectorDifference(&p1->pos,&p2->pos,&deltaP); // Vector distance
deltaP = pPosition1 - pPosition2;
// dist = VectorLength(&deltaP); // Magnitude of
//deltaP
// deltaP
dist = deltaP.Length();
if (dist == 0)
{
@@ -72,7 +74,9 @@ bool TSpring::ComputateForces(vector3 pPosition1, vector3 pPosition2)
return true;
}
void TSpring::Render() {}
void TSpring::Render()
{
}
//---------------------------------------------------------------------------

View File

@@ -13,7 +13,7 @@ http://mozilla.org/MPL/2.0/.
#define STATIC_THRESHOLD 0.17f
// efine STATIC_THRESHOLD 0.03f
const double m_Kd = 0.02f; // DAMPING FACTOR
const double m_Kr = 0.8f; // 1.0 = SUPERBALL BOUNCE 0.0 = DEAD WEIGHT
const double m_Kr = 0.8f; // 1.0 = SUPERBALL BOUNCE 0.0 = DEAD WEIGHT
const double m_Ksh = 5.0f; // HOOK'S SPRING CONSTANT
const double m_Ksd = 0.1f; // SPRING DAMPING CONSTANT
@@ -35,8 +35,8 @@ class TSpring
void Render();
vector3 vForce1, vForce2;
double restLen; // LENGTH OF SPRING AT REST
double Ks; // SPRING CONSTANT
double Kd; // SPRING DAMPING
double Ks; // SPRING CONSTANT
double Kd; // SPRING DAMPING
private:
};

View File

@@ -89,7 +89,10 @@ TTexturesManager::Names::iterator TTexturesManager::LoadFromFile(std::string fil
struct ReplaceSlash
{
const char operator()(const char input) { return input == '/' ? '\\' : input; }
const char operator()(const char input)
{
return input == '/' ? '\\' : input;
}
};
GLuint TTexturesManager::GetTextureID(char *dir, char *where, std::string fileName, int filter)
@@ -397,7 +400,7 @@ TTexturesManager::AlphaValue TTexturesManager::LoadTGA(std::string fileName, int
copybytes += (1 + (chunkheader & 127)) * bytesPerPixel; // iloϾ pikseli
if (chunkheader < 128) // jeœli kopiowanie, pikseli jest wiêcej
copyto += (chunkheader)*bytesPerPixel; // rozmiar kopiowanego obszaru (bez
// jednego piksela)
// jednego piksela)
}
if (copybytes > imageSize)
{ // nie ma prawa byæ wiêksze
@@ -440,7 +443,7 @@ TTexturesManager::AlphaValue TTexturesManager::LoadTGA(std::string fileName, int
chunkheader = (unsigned char)*copyfrom; // jeden bajt, pozosta³e zawsze zerowe
if (copyto > copyfrom)
{ // jeœli piksele maj¹ byæ kopiowane, to mo¿liwe jest przesuniêcie ich o 1 bajt, na
// miejsce licznika
// miejsce licznika
filesize = (imageData + imageSize - copyto) /
bytesPerPixel; // ile pikseli pozosta³o do koñca
// WriteLog("Decompression buffer overflow at pixel
@@ -455,7 +458,7 @@ TTexturesManager::AlphaValue TTexturesManager::LoadTGA(std::string fileName, int
if ((filesize > 128) ||
!(Global::iModifyTGA & 4)) // gdy za du¿o pikseli albo wy³¹czone
writeback = -1; // zapis mo¿liwe jeœli iloœæ problematycznych pikseli nie
// przekaracza 128
// przekaracza 128
break; // bufor siê zatka³, dalej w ten sposób siê nie da
}
if (chunkheader < 128)
@@ -511,7 +514,7 @@ TTexturesManager::AlphaValue TTexturesManager::LoadTGA(std::string fileName, int
};
if (chunkheader < 128)
{ // if the header is < 128, it means the that is the number of RAW color packets minus
// 1
// 1
chunkheader++; // add 1 to get number of following color values
file.read(copyto, chunkheader * bytesPerPixel);
copyto += chunkheader * bytesPerPixel;

View File

@@ -274,8 +274,8 @@ void DecompressDXT5(DDS_IMAGE_DATA lImage, const GLubyte *lCompData, GLubyte *Da
alphas[3] = (3 * alphas[0] + 2 * alphas[1] + 2) / 5; // Bit code 011
alphas[4] = (2 * alphas[0] + 3 * alphas[1] + 2) / 5; // Bit code 100
alphas[5] = (1 * alphas[0] + 4 * alphas[1] + 2) / 5; // Bit code 101
alphas[6] = 0x00; // Bit code 110
alphas[7] = 0xFF; // Bit code 111
alphas[6] = 0x00; // Bit code 110
alphas[7] = 0xFF; // Bit code 111
}
// Note: Have to separate the next two loops,

View File

@@ -25,7 +25,10 @@ double fSimulationTime = 0;
double fSoundTimer = 0;
double fSinceStart = 0;
double GetTime() { return fSimulationTime; }
double GetTime()
{
return fSimulationTime;
}
double GetDeltaTime()
{ // czas symulacji (stoi gdy pauza)
@@ -37,19 +40,35 @@ double GetDeltaRenderTime()
return DeltaRenderTime;
}
double GetfSinceStart() { return fSinceStart; }
double GetfSinceStart()
{
return fSinceStart;
}
void SetDeltaTime(double t) { DeltaTime = t; }
void SetDeltaTime(double t)
{
DeltaTime = t;
}
double GetSimulationTime() { return fSimulationTime; }
double GetSimulationTime()
{
return fSimulationTime;
}
void SetSimulationTime(double t) { fSimulationTime = t; }
void SetSimulationTime(double t)
{
fSimulationTime = t;
}
bool GetSoundTimer()
{ // Ra: byæ mo¿e, by dŸwiêki nie modyfikowa³y siê zbyt czêsto, po 0.1s zeruje siê ten licznik
return (fSoundTimer == 0.0f); }
return (fSoundTimer == 0.0f);
}
double GetFPS() { return fFPS; }
double GetFPS()
{
return fFPS;
}
void ResetTimers()
{

View File

@@ -68,8 +68,8 @@ TSwitchExtension::TSwitchExtension(TTrack *owner, int what)
Segments[2] = (what >= 3) ?
new TSegment(owner) :
NULL; // z punktu 2 do 4 skrzyżowanie od góry: wersja "-1":
Segments[3] = (what >= 4) ? new TSegment(owner) :
NULL; // z punktu 4 do 1 1 1=4 0 0=3
Segments[3] =
(what >= 4) ? new TSegment(owner) : NULL; // z punktu 4 do 1 1 1=4 0 0=3
Segments[4] =
(what >= 5) ? new TSegment(owner) : NULL; // z punktu 1 do 3 4 x 3 3 3 x 2 2
Segments[5] = (what >= 6) ? new TSegment(owner) :
@@ -102,16 +102,17 @@ TIsolated::TIsolated(const AnsiString &n, TIsolated *i)
pMemCell = NULL; // podpiąć istniejącą albo utworzyć pustą
};
TIsolated::~TIsolated(){// usuwanie
/*
TIsolated *p=pRoot;
while (pRoot)
{
p=pRoot;
p->pNext=NULL;
delete p;
}
*/
TIsolated::~TIsolated(){
// usuwanie
/*
TIsolated *p=pRoot;
while (pRoot)
{
p=pRoot;
p->pNext=NULL;
delete p;
}
*/
};
TIsolated *__fastcall TIsolated::Find(const AnsiString &n)
@@ -324,7 +325,7 @@ TTrack *__fastcall TTrack::NullCreate(int dir)
trk2->bVisible = false;
trk2->fVelocity = 20.0; // zawracanie powoli
trk2->fRadius = 20.0; // promień, aby się dodawało do tabelki prędkości i liczyło
// narastająco
// narastająco
trk2->Init(); // utworzenie segmentu
switch (dir)
{ //łączenie z nowym torem
@@ -796,7 +797,7 @@ void TTrack::Load(cParser *parser, vector3 pOrigin, AnsiString name)
if (SwitchExtension) // jeśli tor ruchomy
if (fabs(fVelocity) >= 1.0) //żeby zero nie ograniczało dożywotnio
SwitchExtension->fVelocity = fVelocity; // zapamiętanie głównego ograniczenia; a
// np. -40 ogranicza tylko na bok
// np. -40 ogranicza tylko na bok
}
else if (str == "isolated")
{ // obwód izolowany, do którego tor należy
@@ -830,16 +831,16 @@ void TTrack::Load(cParser *parser, vector3 pOrigin, AnsiString name)
}
else if (str == "overhead")
{ // informacja o stanie sieci: 0-jazda bezprądowa, >0-z opuszczonym i ograniczeniem
// prędkości
// prędkości
parser->getTokens();
*parser >> fOverhead;
if (fOverhead > 0.0)
iAction |= 0x40; // flaga opuszczenia pantografu (tor uwzględniany w skanowaniu jako
// ograniczenie dla pantografujących)
// ograniczenie dla pantografujących)
}
else if (str == "colides")
{ // informacja o stanie sieci: 0-jazda bezprądowa, >0-z opuszczonym i ograniczeniem
// prędkości
// prędkości
parser->getTokens();
*parser >> token;
// trColides=; //tor kolizyjny, na którym trzeba sprawdzać pojazdy pod kątem zderzenia
@@ -1222,7 +1223,7 @@ void TTrack::Compile(GLuint tex)
switch (eType) // dalej zależnie od typu
{
case tt_Table: // obrotnica jak zwykły tor, animacja wykonywana w RaAnimate(), tutaj tylko
// regeneracja siatek
// regeneracja siatek
case tt_Normal:
if (TextureID2)
if (tex ? TextureID2 == tex : true) // jeśli pasuje do grupy (tex)
@@ -1232,7 +1233,7 @@ void TTrack::Compile(GLuint tex)
if (fTexLength ==
4.0) // jeśli stare mapowanie na profil 0.2 0.5 1.1 (również 6-9-9/noil)
{ // stare mapowanie z różną gęstością pikseli i oddzielnymi teksturami na każdy
// profil
// profil
if (iTrapezoid) // trapez albo przechyłki
{ // podsypka z podkladami trapezowata
// ewentualnie poprawić mapowanie, żeby środek mapował się na
@@ -1272,9 +1273,9 @@ void TTrack::Compile(GLuint tex)
}
else
{ // mapowanie proporcjonalne do powierzchni, rozmiar w poprzek określa
// fTexLength
// fTexLength
double max = fTexRatio2 * fTexLength; // szerokość proporcjonalna do
// długości
// długości
double map11 =
max > 0.0 ? (fHTW + side) / max : 0.25; // załamanie od strony 1
double map12 =
@@ -1451,7 +1452,7 @@ void TTrack::Compile(GLuint tex)
if (TextureID2)
if (tex ? TextureID2 == tex : true) // jeśli pasuje do grupy (tex)
{ // pobocze drogi - poziome przy przechyłce (a może krawężnik i chodnik zrobić jak
// w Midtown Madness 2?)
// w Midtown Madness 2?)
if (!tex)
glBindTexture(GL_TEXTURE_2D, TextureID2);
vector6 rpts1[6],
@@ -1469,7 +1470,7 @@ void TTrack::Compile(GLuint tex)
rpts2[2] = vector6(-rozp, -fTexHeight1, 0.0); // prawy brzeg podstawy
if (iTrapezoid) // trapez albo przechyłki
{ // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony
// odcinka
// odcinka
rpts1[3] =
vector6(rozp2, -fTexHeight2, 0.0); // lewy brzeg lewego pobocza
rpts1[4] =
@@ -1509,7 +1510,7 @@ void TTrack::Compile(GLuint tex)
0.484375 - map1l); // lewy brzeg lewego chodnika
if (iTrapezoid) // trapez albo przechyłki
{ // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony
// odcinka
// odcinka
slop2 = fabs((iTrapezoid & 2) ? slop2 :
slop); // szerokość chodnika po prawej
double map2l =
@@ -1534,7 +1535,7 @@ void TTrack::Compile(GLuint tex)
}
if (iTrapezoid) // trapez albo przechyłki
{ // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony
// odcinka
// odcinka
if ((fTexHeight1 >= 0.0) ? true : (slop != 0.0))
Segment->RenderLoft(rpts1, -3, fTexLength); // tylko jeśli jest z prawej
if ((fTexHeight1 >= 0.0) ? true : (side != 0.0))
@@ -1595,7 +1596,7 @@ void TTrack::Compile(GLuint tex)
SwitchExtension->Segments[5]->RaSegCount(); // mogą być tylko 3 drogi
SwitchExtension->vPoints =
new vector3[SwitchExtension->iPoints]; // tablica utworzona z zapasem, ale nie
// wypełniona współrzędnymi
// wypełniona współrzędnymi
}
vector3 *b =
SwitchExtension->bPoints ?
@@ -1630,7 +1631,7 @@ void TTrack::Compile(GLuint tex)
// if (TextureID2)
// if (tex?TextureID2==tex:true) //jeśli pasuje do grupy (tex)
{ // pobocze drogi - poziome przy przechyłce (a może krawężnik i chodnik zrobić jak w
// Midtown Madness 2?)
// Midtown Madness 2?)
if (TextureID2)
if (!tex)
glBindTexture(GL_TEXTURE_2D, TextureID2);
@@ -1642,7 +1643,7 @@ void TTrack::Compile(GLuint tex)
{ // standardowo: od zewnątrz pochylenie, a od wewnątrz poziomo
rpts1[0] = vector6(rozp, -fTexHeight1, 0.0); // lewy brzeg podstawy
rpts1[1] = vector6(bpts1[0].x + side, bpts1[0].y, 0.5); // lewa krawędź
// załamania
// załamania
rpts1[2] = vector6(bpts1[0].x, bpts1[0].y,
1.0); // lewy brzeg pobocza (mapowanie może być inne
rpts2[0] = vector6(bpts1[1].x, bpts1[1].y, 1.0); // prawy brzeg pobocza
@@ -1651,15 +1652,15 @@ void TTrack::Compile(GLuint tex)
rpts2[2] = vector6(-rozp, -fTexHeight1, 0.0); // prawy brzeg podstawy
// if (iTrapezoid) //trapez albo przechyłki
{ // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony
// odcinka
// odcinka
rpts1[3] = vector6(rozp2, -fTexHeight2, 0.0); // lewy brzeg lewego pobocza
rpts1[4] = vector6(bpts1[2].x + side2, bpts1[2].y, 0.5); // krawędź
// załamania
// załamania
rpts1[5] = vector6(bpts1[2].x, bpts1[2].y, 1.0); // brzeg pobocza
rpts2[3] = vector6(bpts1[3].x, bpts1[3].y, 1.0);
rpts2[4] = vector6(bpts1[3].x - side2, bpts1[3].y, 0.5);
rpts2[5] = vector6(-rozp2, -fTexHeight2, 0.0); // prawy brzeg prawego
// pobocza
// pobocza
}
}
else
@@ -1690,7 +1691,7 @@ void TTrack::Compile(GLuint tex)
0.484375 - map1l); // lewy brzeg lewego chodnika
// if (iTrapezoid) //trapez albo przechyłki
{ // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony
// odcinka
// odcinka
slop2 =
fabs((iTrapezoid & 2) ? slop2 : slop); // szerokość chodnika po prawej
double map2l = max > 0.0 ?
@@ -1715,7 +1716,7 @@ void TTrack::Compile(GLuint tex)
}
bool render = TextureID2 ? (tex ? TextureID2 == tex : true) :
false; // renderować nie trzeba, ale trzeba wyznaczyć
// punkty brzegowe nawierzchni
// punkty brzegowe nawierzchni
// if (iTrapezoid) //trapez albo przechyłki
if (SwitchExtension->iRoads == 4)
{ // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony odcinka
@@ -1734,7 +1735,7 @@ void TTrack::Compile(GLuint tex)
}
else // to będzie ewentualnie dla prostego na skrzyżowaniu trzech dróg
{ // punkt 3 pokrywa się z punktem 1, jak w zwrotnicy; połączenie 1->2 nie musi być
// prostoliniowe
// prostoliniowe
if ((fTexHeight1 >= 0.0) ? true : (side != 0.0)) // OK
SwitchExtension->Segments[2]->RenderLoft(rpts2, -3, fTexLength, 0, 1, &b,
render); // z P2 do P4
@@ -1760,15 +1761,15 @@ void TTrack::Compile(GLuint tex)
{ // coś się gubi w obliczeniach na wskaźnikach
i = (int((void *)(b)) - int((void *)(SwitchExtension->vPoints))) /
sizeof(vector3); // ustalenie liczby punktów, bo mogło wyjść inaczej niż
// policzone z góry
// policzone z góry
if (i > 0)
{ // jeśli zostało to właśnie utworzone
if (SwitchExtension->iPoints > i) // jeśli wyszło mniej niż było miejsca
SwitchExtension->iPoints = i; // domknięcie wachlarza
else
--SwitchExtension->iPoints; // jak tutaj wejdzie, to błąd jest - zrobić
// miejsce na powtórzenie pierwszego punktu
// na końcu
// miejsce na powtórzenie pierwszego punktu
// na końcu
SwitchExtension->vPoints[SwitchExtension->iPoints++] =
SwitchExtension->vPoints[0];
SwitchExtension->bPoints = true; // tablica punktów została wypełniona
@@ -2077,7 +2078,7 @@ void TTrack::RaArrayFill(CVertNormTex *Vert, const CVertNormTex *Start)
vector6 bpts1[8]; // punkty głównej płaszczyzny nie przydają się do robienia boków
if (fTexLength == 4.0) // jeśli stare mapowanie
{ // stare mapowanie z różną gęstością pikseli i oddzielnymi teksturami na każdy
// profil
// profil
if (iTrapezoid) // trapez albo przechyłki
{ // podsypka z podkladami trapezowata
// ewentualnie poprawić mapowanie, żeby środek mapował się na 1.435/4.671
@@ -2259,7 +2260,7 @@ void TTrack::RaArrayFill(CVertNormTex *Vert, const CVertNormTex *Start)
}
if (TextureID2)
{ // pobocze drogi - poziome przy przechyłce (a może krawężnik i chodnik zrobić jak w
// Midtown Madness 2?)
// Midtown Madness 2?)
vector6 rpts1[6],
rpts2[6]; // współrzędne przekroju i mapowania dla prawej i lewej strony
if (fTexHeight1 >= 0.0)
@@ -2275,15 +2276,15 @@ void TTrack::RaArrayFill(CVertNormTex *Vert, const CVertNormTex *Start)
rpts2[2] = vector6(-rozp, -fTexHeight1, 0.0); // prawy brzeg podstawy
if (iTrapezoid) // trapez albo przechyłki
{ // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony
// odcinka
// odcinka
rpts1[3] = vector6(rozp2, -fTexHeight2, 0.0); // lewy brzeg lewego pobocza
rpts1[4] = vector6(bpts1[2].x + side2, bpts1[2].y, 0.5); // krawędź
// załamania
// załamania
rpts1[5] = vector6(bpts1[2].x, bpts1[2].y, 1.0); // brzeg pobocza
rpts2[3] = vector6(bpts1[3].x, bpts1[3].y, 1.0);
rpts2[4] = vector6(bpts1[3].x - side2, bpts1[3].y, 0.5);
rpts2[5] = vector6(-rozp2, -fTexHeight2, 0.0); // prawy brzeg prawego
// pobocza
// pobocza
Segment->RaRenderLoft(Vert, rpts1, -3, fTexLength);
Segment->RaRenderLoft(Vert, rpts2, -3, fTexLength);
}
@@ -2323,7 +2324,7 @@ void TTrack::RaArrayFill(CVertNormTex *Vert, const CVertNormTex *Start)
0.484375 - map1l); // lewy brzeg lewego chodnika
if (iTrapezoid) // trapez albo przechyłki
{ // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony
// odcinka
// odcinka
slop2 =
fabs((iTrapezoid & 2) ? slop2 : slop); // szerokość chodnika po prawej
double map2l = max > 0.0 ?
@@ -2400,7 +2401,7 @@ void TTrack::RaArrayFill(CVertNormTex *Vert, const CVertNormTex *Start)
}
if (TextureID2)
{ // pobocze drogi - poziome przy przechyłce (a może krawężnik i chodnik zrobić jak w
// Midtown Madness 2?)
// Midtown Madness 2?)
vector6 rpts1[6],
rpts2[6]; // współrzędne przekroju i mapowania dla prawej i lewej strony
rpts1[0] = vector6(rozp, -fTexHeight1, 0.0); // lewy brzeg podstawy
@@ -2681,7 +2682,7 @@ bool TTrack::Switch(int i, double t, double d)
{ // nie ma się co bawić
SwitchExtension->fOffset = SwitchExtension->fDesiredOffset;
RaAnimate(); // przeliczenie położenia iglic; czy zadziała na niewyświetlanym
// sektorze w VBO?
// sektorze w VBO?
}
return true;
}
@@ -2950,7 +2951,7 @@ TTrack *__fastcall TTrack::RaAnimate()
SwitchExtension->vTrans)) // czy przemieściło się od ostatniego sprawdzania
{
double hlen = 0.5 * SwitchExtension->Segments[0]->GetLength(); // połowa
// długości
// długości
SwitchExtension->fOffset = ac->AngleGet(); // pobranie kąta z submodelu
double sina = -hlen * sin(DegToRad(SwitchExtension->fOffset)),
cosa = -hlen * cos(DegToRad(SwitchExtension->fOffset));
@@ -2962,7 +2963,7 @@ TTrack *__fastcall TTrack::RaAnimate()
middle - vector3(sina, 0.0, cosa), 5.0); // nowy odcinek
for (int i = 0; i < iNumDynamics; i++)
Dynamics[i]->Move(0.000001); // minimalny ruch, aby przeliczyć pozycję i
// kąty
// kąty
if (Global::bUseVBO)
{ // dla OpenGL 1.4 odświeży się cały sektor, w późniejszych poprawiamy fragment
// aktualizacja pojazdów na torze
@@ -3147,7 +3148,7 @@ void TTrack::ConnectionsLog()
TTrack *__fastcall TTrack::Neightbour(int s, double &d)
{ // zwraca wskaźnik na sąsiedni tor, w kierunku określonym znakiem (s), odwraca (d) w razie
// niezgodności kierunku torów
// niezgodności kierunku torów
TTrack *t; // nie zmieniamy kierunku (d), jeśli nie ma toru dalej
if (eType != tt_Cross)
{ // jeszcze trzeba sprawdzić zgodność
@@ -3155,7 +3156,7 @@ TTrack *__fastcall TTrack::Neightbour(int s, double &d)
if (t) // o ile jest na co przejść, zmieniamy znak kierunku na nowym torze
if (t->eType == tt_Cross)
{ // jeśli wjazd na skrzyżowanie, trzeba ustalić segment, bo od tego zależy zmiana
// kierunku (d)
// kierunku (d)
// if (r) //gdy nie podano (r), to nie zmieniać (d)
// if (s*t->CrossSegment(((s>0)?iNextDirection:iPrevDirection),r)<0)
// d=-d;

51
Track.h
View File

@@ -51,7 +51,7 @@ class TSwitchExtension
TSwitchExtension(TTrack *owner, int what);
~TSwitchExtension();
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
// dotychczasowe [2]+[2] wskaźniki zamienić na nowe [4]
TTrack *pNexts[2]; // tory dołączone do punktów 2 i 4
@@ -111,9 +111,18 @@ class TIsolated
static TIsolated *__fastcall Find(
const AnsiString &n); // znalezienie obiektu albo utworzenie nowego
void Modify(int i, TDynamicObject *o); // dodanie lub odjęcie osi
bool Busy() { return (iAxles > 0); };
static TIsolated *__fastcall Root() { return (pRoot); };
TIsolated *__fastcall Next() { return (pNext); };
bool Busy()
{
return (iAxles > 0);
};
static TIsolated *__fastcall Root()
{
return (pRoot);
};
TIsolated *__fastcall Next()
{
return (pNext);
};
};
class TTrack : public Resource
@@ -168,7 +177,7 @@ class TTrack : public Resource
bool bVisible; // czy rysowany
int iAction; // czy modyfikowany eventami (specjalna obsługa przy skanowaniu)
float fOverhead; // informacja o stanie sieci: 0-jazda bezprądowa, >0-z opuszczonym i
// ograniczeniem prędkości
// ograniczeniem prędkości
private:
double fVelocity; // prędkość dla AI (powyżej rośnie prawdopowobieństwo wykolejenia)
public:
@@ -185,15 +194,30 @@ class TTrack : public Resource
void Init();
static TTrack *__fastcall Create400m(int what, double dx);
TTrack *__fastcall NullCreate(int dir);
inline bool IsEmpty() { return (iNumDynamics <= 0); };
inline bool IsEmpty()
{
return (iNumDynamics <= 0);
};
void ConnectPrevPrev(TTrack *pNewPrev, int typ);
void ConnectPrevNext(TTrack *pNewPrev, int typ);
void ConnectNextPrev(TTrack *pNewNext, int typ);
void ConnectNextNext(TTrack *pNewNext, int typ);
inline double Length() { return Segment->GetLength(); };
inline TSegment *__fastcall CurrentSegment() { return Segment; };
inline TTrack *__fastcall CurrentNext() { return (trNext); };
inline TTrack *__fastcall CurrentPrev() { return (trPrev); };
inline double Length()
{
return Segment->GetLength();
};
inline TSegment *__fastcall CurrentSegment()
{
return Segment;
};
inline TTrack *__fastcall CurrentNext()
{
return (trNext);
};
inline TTrack *__fastcall CurrentPrev()
{
return (trPrev);
};
TTrack *__fastcall Neightbour(int s, double &d);
bool SetConnections(int i);
bool Switch(int i, double t = -1.0, double d = -1.0);
@@ -222,7 +246,7 @@ class TTrack : public Resource
void RenderDyn(); // renderowanie nieprzezroczystych pojazdów (oba tryby)
void RenderDynAlpha(); // renderowanie przezroczystych pojazdów (oba tryby)
void RenderDynSounds(); // odtwarzanie dźwięków pojazdów jest niezależne od ich
// wyświetlania
// wyświetlania
void RaOwnerSet(TSubRect *o)
{
@@ -244,7 +268,10 @@ class TTrack : public Resource
AnsiString IsolatedName();
bool IsolatedEventsAssign(TEvent *busy, TEvent *free);
double WidthTotal();
GLuint TextureGet(int i) { return i ? TextureID1 : TextureID2; };
GLuint TextureGet(int i)
{
return i ? TextureID1 : TextureID2;
};
bool IsGroupable();
int TestPoint(vector3 *Point);
void MovedUp1(double dh);

View File

@@ -664,7 +664,7 @@ void TTraction::PowerSet(TTractionPowerSource *ps)
{ // ustalenie punktu zasilania (nie ma jeszcze połączeń między przęsłami)
psPowered = ps; // ustawienie bezpośredniego zasilania dla przęsła
psPower[0] = psPower[1] = ps; // a to chyba nie jest dobry pomysł, bo nawet zasilane przęsło
// powinno mieć wskazania na inne
// powinno mieć wskazania na inne
fResistance[0] = fResistance[1] = 0.0; // a liczy się tylko rezystancja zasilacza
}
};

View File

@@ -56,7 +56,7 @@ class TTraction
AnsiString asParallel; // nazwa przês³a, z którym mo¿e byæ bie¿nia wspólna
TTraction *hvParallel; // jednokierunkowa i zapêtlona lista przêse³ ewentualnej bie¿ni wspólnej
float fResistance[2]; // rezystancja zastêpcza do punktu zasilania (0: przês³o zasilane, <0: do
// policzenia)
// policzenia)
int iTries;
// bool bVisible;
// DWORD dwFlags;

View File

@@ -79,20 +79,22 @@ bool TTractionPowerSource::Load(cParser *parser)
Recuperation = true;
else if (token.compare("section") == 0) // od³¹cznik sekcyjny
bSection = true; // nie jest Ÿród³em zasilania, a jedynie informuje o pr¹dzie od³¹czenia
// sekcji z obwodu
// sekcji z obwodu
parser->getTokens();
*parser >> token;
if (token.compare("end") != 0)
Error("tractionpowersource end statement missing");
// if (!bSection) //od³¹cznik sekcji zasadniczo nie ma impedancji (0.01 jest OK)
if (InternalRes < 0.1) // coœ ma³a ta rezystancja by³a...
InternalRes =
0.2; // tak oko³o 0.2, wg
// http://www.ikolej.pl/fileadmin/user_upload/Seminaria_IK/13_05_07_Prezentacja_Kruczek.pdf
InternalRes = 0.2; // tak oko³o 0.2, wg
// http://www.ikolej.pl/fileadmin/user_upload/Seminaria_IK/13_05_07_Prezentacja_Kruczek.pdf
return true;
};
bool TTractionPowerSource::Render() { return true; };
bool TTractionPowerSource::Render()
{
return true;
};
bool TTractionPowerSource::Update(double dt)
{ // powinno byæ wykonane raz na krok fizyki
@@ -151,7 +153,7 @@ double TTractionPowerSource::CurrentGet(double res)
0.0; // napiêcie dzielone przez sumê rezystancji wewnêtrznej i obci¹¿enia
OutputVoltage = NominalVoltage - InternalRes * TotalCurrent; // napiêcie na obci¹¿eniu
return TotalCurrent / (res * TotalPreviousAdmitance); // pr¹d proporcjonalny do udzia³u (1/res)
// w ca³kowitej admitancji
// w ca³kowitej admitancji
};
void TTractionPowerSource::PowerSet(TTractionPowerSource *ps)

View File

@@ -48,7 +48,10 @@ class TTractionPowerSource
bool Render();
bool Update(double dt);
double CurrentGet(double res);
void VoltageSet(double v) { NominalVoltage = v; };
void VoltageSet(double v)
{
NominalVoltage = v;
};
void PowerSet(TTractionPowerSource *ps);
};

129
Train.cpp
View File

@@ -49,8 +49,8 @@ TCab::TCab()
iButtons = 0;
}
void TCab::Init(double Initx1, double Inity1, double Initz1, double Initx2,
double Inity2, double Initz2, bool InitEnabled, bool InitOccupied)
void TCab::Init(double Initx1, double Inity1, double Initz1, double Initx2, double Inity2,
double Initz2, bool InitEnabled, bool InitOccupied)
{
CabPos1.x = Initx1;
CabPos1.y = Inity1;
@@ -260,6 +260,38 @@ bool TTrain::Init(TDynamicObject *NewDynamicObject, bool e3d)
return true;
}
PyObject *TTrain::GetTrainState()
{
PyObject *dict = PyDict_New();
if (dict == NULL)
{
return NULL;
}
PyDict_SetItemString(dict, "direction", PyGetInt(DynamicObject->MoverParameters->ActiveDir));
PyDict_SetItemString(dict, "slipping_wheels",
PyGetBool(DynamicObject->MoverParameters->SlippingWheels));
PyDict_SetItemString(dict, "converter",
PyGetBool(DynamicObject->MoverParameters->ConverterFlag));
PyDict_SetItemString(dict, "main_ctrl_actual_pos",
PyGetInt(DynamicObject->MoverParameters->MainCtrlActualPos));
PyDict_SetItemString(dict, "scnd_ctrl_actual_pos",
PyGetInt(DynamicObject->MoverParameters->ScndCtrlActualPos));
PyDict_SetItemString(dict, "fuse", PyGetBool(DynamicObject->MoverParameters->FuseFlag));
PyDict_SetItemString(dict, "converter_overload",
PyGetBool(DynamicObject->MoverParameters->ConvOvldFlag));
PyDict_SetItemString(dict, "voltage", PyGetFloat(DynamicObject->MoverParameters->Voltage));
PyDict_SetItemString(dict, "velocity", PyGetFloat(DynamicObject->MoverParameters->Vel));
PyDict_SetItemString(dict, "im", PyGetFloat(DynamicObject->MoverParameters->Im));
PyDict_SetItemString(dict, "compress",
PyGetBool(DynamicObject->MoverParameters->CompressorFlag));
PyDict_SetItemString(dict, "hours", PyGetInt(GlobalTime->hh));
PyDict_SetItemString(dict, "minutes", PyGetInt(GlobalTime->mm));
PyDict_SetItemString(dict, "seconds", PyGetInt(GlobalTime->mr));
PyDict_SetItemString(dict, "velocity_desired", PyGetFloat(DynamicObject->Mechanik->VelDesired));
return dict;
}
void TTrain::OnKeyDown(int cKey)
{ // naciœniêcie klawisza
bool isEztOer;
@@ -272,7 +304,7 @@ void TTrain::OnKeyDown(int cKey)
if (GetAsyncKeyState(VK_SHIFT) < 0)
{ // wciœniêty [Shift]
if (cKey == Global::Keys[k_IncMainCtrlFAST]) // McZapkie-200702: szybkie przelaczanie na
// poz. bezoporowa
// poz. bezoporowa
{
if (mvControlled->IncMainCtrl(2))
{
@@ -511,8 +543,8 @@ void TTrain::OnKeyDown(int cKey)
!mvOccupied->ActiveCab) // tylko w maszynowym
if (Console::Pressed(VK_CONTROL)) // z [Ctrl]
mvControlled->bPantKurek3 = true; // zbiornik pantografu po³¹czony jest ze
// zbiornikiem g³ównym (pompowanie nie ma
// sensu)
// zbiornikiem g³ównym (pompowanie nie ma
// sensu)
else if (!mvControlled->PantCompFlag) // jeœli wy³¹czona
if (mvControlled->Battery) // jeszcze musi byæ za³¹czona bateria
if (mvControlled->PantPress < 4.8) // pisz¹, ¿e to tak nie dzia³a
@@ -563,7 +595,7 @@ void TTrain::OnKeyDown(int cKey)
}
}
else if (cKey == Global::Keys[k_FailedEngineCutOff]) // McZapkie-060103: E - wylaczanie
// sekcji silnikow
// sekcji silnikow
{
if (mvControlled->CutOffEngine())
{
@@ -700,7 +732,7 @@ void TTrain::OnKeyDown(int cKey)
}
else if (cKey == Global::Keys[k_Active]) // yB 300407: przelacznik rozrzadu
{ // Ra 2014-06: uruchomi³em to, aby aktywowaæ czuwak w zajmowanym cz³onie, a wy³¹czyæ w
// innych
// innych
// Ra 2014-03: aktywacja czuwaka przepiêta na ustawienie kierunku w mvOccupied
// if (mvControlled->Battery) //jeœli bateria jest ju¿ za³¹czona
// mvOccupied->BatterySwitch(true); //to w ten oto durny sposób aktywuje siê CA/SHP
@@ -1080,7 +1112,7 @@ void TTrain::OnKeyDown(int cKey)
else
;
else // Ra 1014-06: AI potrafi zahamowaæ pomocniczym mimo jego braku - odhamowaæ
// jakoœ trzeba
// jakoœ trzeba
if ((mvOccupied->LocalBrake != ManualBrake) || mvOccupied->LocalBrakePos)
mvOccupied->DecLocalBrakeLevel(1);
}
@@ -1166,10 +1198,10 @@ void TTrain::OnKeyDown(int cKey)
(mvOccupied->BrakeHandle == FV4a ? 1 : 0));
if (GetAsyncKeyState(VK_CONTROL) < 0)
mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_NP)); // yB: czy ten stos
// funkcji nie
// powinien byæ jako
// oddzielna funkcja
// movera?
// funkcji nie
// powinien byæ jako
// oddzielna funkcja
// movera?
}
else if (cKey == Global::Keys[k_Brake1])
{
@@ -1460,8 +1492,8 @@ void TTrain::OnKeyDown(int cKey)
!mvOccupied->ActiveCab) // tylko w maszynowym
if (Console::Pressed(VK_CONTROL)) // z [Ctrl]
mvControlled->bPantKurek3 = false; // zbiornik pantografu po³¹czony jest z ma³¹
// sprê¿ark¹ (pompowanie ma sens, ale potem
// trzeba prze³¹czyæ)
// sprê¿ark¹ (pompowanie ma sens, ale potem
// trzeba prze³¹czyæ)
else if (!mvControlled->PantCompFlag) // jeœli wy³¹czona
if (mvControlled->Battery) // jeszcze musi byæ za³¹czona bateria
if (mvControlled->PantPress < 4.8) // pisz¹, ¿e to tak nie dzia³a
@@ -1714,7 +1746,7 @@ void TTrain::OnKeyDown(int cKey)
if (iCabn > 0)
{
if (!FreeFlyModeFlag) // tryb 'kabinowy' (pozwala równie¿ roz³¹czyæ sprzêgi
// zablokowane)
// zablokowane)
{
if (DynamicObject->DettachStatus(iCabn - 1) < 0) // jeœli jest co odczepiæ
if (DynamicObject->Dettach(iCabn - 1)) // iCab==1:przód,iCab==2:ty³
@@ -2036,7 +2068,7 @@ void TTrain::OnKeyDown(int cKey)
}
}
if (cKey == Global::Keys[k_RightSign]) // Winger 070304: swiatla tylne (koncowki) -
// wlaczenie
// wlaczenie
{
if ((GetAsyncKeyState(VK_CONTROL) < 0) &&
(ggRearRightLightButton.SubModel)) // hunter-230112 - z controlem gasi z tylu
@@ -2182,7 +2214,7 @@ void TTrain::OnKeyDown(int cKey)
if (DynamicObject->Mechanik)
if (!FreeFlyModeFlag) //¿eby nie mieszaæ obserwuj¹c z zewn¹trz
DynamicObject->Mechanik->RouteSwitch(1); // na skrzy¿owaniu skrêci w
// lewo
// lewo
}
else if (cKey == Global::Keys[k_MechRight])
{
@@ -2458,7 +2490,7 @@ bool TTrain::Update()
}
else
fHCurrent[0] = fHCurrent[1] = fHCurrent[2] = fHCurrent[3] = 0.0; // gdy nie ma
// cz³ona
// cz³ona
}
else
{ // normalne pokazywanie
@@ -2472,17 +2504,17 @@ bool TTrain::Update()
Console::ValueSet(0,
mvOccupied->Compressor); // Ra: sterowanie miernikiem: zbiornik g³ówny
Console::ValueSet(1, mvOccupied->PipePress); // Ra: sterowanie miernikiem: przewód
// g³ówny
// g³ówny
Console::ValueSet(
2, mvOccupied->BrakePress); // Ra: sterowanie miernikiem: cylinder hamulcowy
Console::ValueSet(3, fHVoltage); // woltomierz wysokiego napiêcia
Console::ValueSet(4, fHCurrent[2]); // Ra: sterowanie miernikiem: drugi amperomierz
Console::ValueSet(
5, fHCurrent[(mvControlled->TrainType & dt_EZT) ? 0 : 1]); // pierwszy amperomierz;
// dla EZT pr¹d ca³kowity
// dla EZT pr¹d ca³kowity
Console::ValueSet(6, fTachoVelocity); ////Ra: prêdkoœæ na pin 43 - wyjœcie analogowe (to
///nie jest PWM); skakanie zapewnia mechanika
///napêdu
/// nie jest PWM); skakanie zapewnia mechanika
/// napêdu
}
// hunter-080812: wyrzucanie szybkiego na elektrykach gdy nie ma napiecia przy dowolnym
@@ -2517,7 +2549,7 @@ bool TTrain::Update()
(mvControlled->TrainType == dt_EZT)) &&
(DynamicObject->Controller == Humandriver)) // hunter-110212: poprawka dla EZT
{ // hunter-091012: poprawka (zmiana warunku z CompressorPower /rozne od 0/ na /rowne
// 1/)
// 1/)
if (fConverterTimer < fConverterPrzekaznik)
{
mvControlled->ConvOvldFlag = true;
@@ -3056,7 +3088,7 @@ bool TTrain::Update()
if (mvControlled->SlippingWheels)
{ // Ra 2014-12: lokomotywy 181/182 dostaj¹ SlippingWheels po zahamowaniu powy¿ej 2.85 bara
// i bucza³y
// i bucza³y
double veldiff = (DynamicObject->GetVelocity() - fTachoVelocity) / mvControlled->Vmax;
if (veldiff <
-0.01) // 1% Vmax rezerwy, ¿eby 181/182 nie bucza³y po zahamowaniu, ale to proteza
@@ -3101,7 +3133,7 @@ bool TTrain::Update()
if ((mvControlled->Itot != 0) || (mvOccupied->BrakePress > 2) ||
(mvOccupied->PipePress < 3.6))
btLampkaStyczn.TurnOff(); // Ra: czy to jest udawanie dzia³ania styczników
// liniowych?
// liniowych?
else if (mvOccupied->BrakePress < 1)
btLampkaStyczn.TurnOn(); // mozna prowadzic rozruch
if (((TestFlag(mvControlled->Couplers[1].CouplingFlag, ctrain_controll)) &&
@@ -3115,9 +3147,9 @@ bool TTrain::Update()
// if ((TestFlag(mvControlled->BrakeStatus,+b_Rused+b_Ractive)))//Lampka
// drugiego stopnia hamowania
btLampkaHamPosp.Turn((TestFlag(mvOccupied->BrakeStatus, 1))); // lampka drugiego stopnia
// hamowania //TODO:
// youBy wyci¹gn¹æ flagê
// wysokiego stopnia
// hamowania //TODO:
// youBy wyci¹gn¹æ flagê
// wysokiego stopnia
// hunter-111211: wylacznik cisnieniowy - Ra: tutaj? w kabinie? //yBARC -
// omujborzegrzesiuzniszczylesmicalydzien
@@ -3214,7 +3246,7 @@ bool TTrain::Update()
{ // yB - wskazniki drugiego czlonu
TDynamicObject *
tmp; //=mvControlled->mvSecond; //Ra 2014-07: trzeba to jeszcze wyj¹æ z kabiny...
// Ra 2014-07: no nie ma potrzeby szukaæ tego w ka¿dej klatce
// Ra 2014-07: no nie ma potrzeby szukaæ tego w ka¿dej klatce
tmp = NULL;
if ((TestFlag(mvControlled->Couplers[1].CouplingFlag, ctrain_controll)) &&
(mvOccupied->ActiveCab > 0))
@@ -4058,10 +4090,10 @@ bool TTrain::Update()
if (!FreeFlyModeFlag)
{
if (Console::Pressed(Global::Keys[k_Releaser])) // yB: odluzniacz caly czas trzymany,
// warunki powinny byc takie same, jak
// przy naciskaniu. Wlasciwie stamtad
// mozna wyrzucic sprawdzanie
// nacisniecia.
// warunki powinny byc takie same, jak
// przy naciskaniu. Wlasciwie stamtad
// mozna wyrzucic sprawdzanie
// nacisniecia.
{
if ((mvControlled->EngineType == ElectricSeriesMotor) ||
(mvControlled->EngineType == DieselElectric))
@@ -4123,8 +4155,8 @@ bool TTrain::Update()
if (ggUniversal3Button.SubModel)
{
ggUniversal3Button.PutValue(1); // hunter-131211: z UpdateValue na PutValue
// - by zachowywal sie jak pozostale
// przelaczniki
// - by zachowywal sie jak pozostale
// przelaczniki
if (btLampkaUniversal3.Active())
LampkaUniversal3_st = true;
}
@@ -4146,8 +4178,8 @@ bool TTrain::Update()
if (ggUniversal3Button.SubModel)
{
ggUniversal3Button.PutValue(0); // hunter-131211: z UpdateValue na PutValue
// - by zachowywal sie jak pozostale
// przelaczniki
// - by zachowywal sie jak pozostale
// przelaczniki
if (btLampkaUniversal3.Active())
LampkaUniversal3_st = false;
}
@@ -4259,8 +4291,8 @@ bool TTrain::Update()
if (ggCabLightDimButton.SubModel)
{
ggCabLightDimButton.PutValue(0); // hunter-131211: z UpdateValue na PutValue
// - by zachowywal sie jak pozostale
// przelaczniki
// - by zachowywal sie jak pozostale
// przelaczniki
}
}
else
@@ -4589,6 +4621,8 @@ bool TTrain::Update()
ggDepartureSignalButton.UpdateValue(0);
ggFuseButton.UpdateValue(0);
ggConverterFuseButton.UpdateValue(0);
pyScreens.update();
}
// wyprowadzenie sygna³ów dla haslera na PoKeys (zaznaczanie na taœmie)
btHaslerBrakes.Turn(DynamicObject->MoverParameters->BrakePress > 0.4); // ciœnienie w cylindrach
@@ -4619,7 +4653,7 @@ bool TTrain::CabChange(int iDirection)
return true; // uda³o siê zmieniæ kabinê
}
DynamicObject->MoverParameters->CabActivisation(); // aktywizacja poprzedniej, bo jeszcze
// nie wiadomo, czy jakiœ pojazd jest
// nie wiadomo, czy jakiœ pojazd jest
}
return false; // ewentualna zmiana pojazdu
}
@@ -4895,13 +4929,15 @@ bool TTrain::LoadMMediaFile(AnsiString asFileName)
{
if (DynamicObject->Controller == Humandriver)
DynamicObject->bDisplayCab = true; // McZapkie-030303: mozliwosc wyswietlania kabiny, w
// przyszlosci dac opcje w mmd
// przyszlosci dac opcje w mmd
return true;
}
}
bool TTrain::InitializeCab(int NewCabNo, AnsiString asFileName)
{
pyScreens.reset(this);
pyScreens.setLookupPath(DynamicObject->asBaseDir);
bool parse = false;
double dSDist;
TFileStream *fs;
@@ -4998,7 +5034,7 @@ bool TTrain::InitializeCab(int NewCabNo, AnsiString asFileName)
if (k)
DynamicObject->mdKabina = k; // nowa kabina
//(mdKabina) mo¿e zostaæ to samo po przejœciu do innego cz³onu bez zmiany
//kabiny, przy powrocie musi byæ wi¹zanie ponowne
// kabiny, przy powrocie musi byæ wi¹zanie ponowne
// else
// break; //wyjœcie z pêtli, bo model zostaje bez zmian
}
@@ -5183,7 +5219,7 @@ bool TTrain::InitializeCab(int NewCabNo, AnsiString asFileName)
else if (str == AnsiString("fuse_bt:")) // bezp. nadmiarowy
ggFuseButton.Load(Parser, DynamicObject->mdKabina);
else if (str == AnsiString("converterfuse_bt:")) // hunter-261211: odblokowanie
// przekaznika nadm. przetw. i ogrz.
// przekaznika nadm. przetw. i ogrz.
ggConverterFuseButton.Load(Parser, DynamicObject->mdKabina);
else if (str == AnsiString("stlinoff_bt:")) // st. liniowe
ggStLinOffButton.Load(Parser, DynamicObject->mdKabina);
@@ -5386,7 +5422,7 @@ bool TTrain::InitializeCab(int NewCabNo, AnsiString asFileName)
gg->AssignDouble(&mvControlled->dizel_engage);
} // ggEngageRatio.Load(Parser,DynamicObject->mdKabina);
else if (str == AnsiString("maingearstatus:")) // np. ciœnienie sterownika skrzyni
// biegów
// biegów
ggMainGearStatus.Load(Parser, DynamicObject->mdKabina);
else if (str == AnsiString("ignitionkey:")) //
ggIgnitionKey.Load(Parser, DynamicObject->mdKabina);
@@ -5508,6 +5544,8 @@ bool TTrain::InitializeCab(int NewCabNo, AnsiString asFileName)
btLampkaBackward.Load(Parser, DynamicObject->mdKabina);
else if (str == AnsiString("i-cablight:")) // hunter-171012
btCabLight.Load(Parser, DynamicObject->mdKabina);
else if (str == AnsiString("pyscreen:"))
pyScreens.init(Parser, DynamicObject->mdKabina, DynamicObject->GetName(), NewCabNo);
// btLampkaUnknown.Init("unknown",mdKabina,false);
}
}
@@ -5518,6 +5556,7 @@ bool TTrain::InitializeCab(int NewCabNo, AnsiString asFileName)
}
// ABu 050205: tego wczesniej nie bylo:
delete Parser;
pyScreens.start();
if (DynamicObject->mdKabina)
{
DynamicObject->mdKabina
@@ -5553,7 +5592,7 @@ vector3 TTrain::MirrorPosition(bool lewe)
void TTrain::DynamicSet(TDynamicObject *d)
{ // taka proteza: chcê pod³¹czyæ kabinê EN57 bezpoœrednio z silnikowym, aby nie robiæ tego przez
// ukrotnienie
// ukrotnienie
// drugi silnikowy i tak musi byæ ukrotniony, podobnie jak kolejna jednostka
// problem siê robi ze œwiat³ami, które bêd¹ zapalane w silnikowym, ale musz¹ œwieciæ siê w
// rozrz¹dczych

33
Train.h
View File

@@ -23,6 +23,7 @@ http://mozilla.org/MPL/2.0/.
#include "AdvSound.h"
#include "RealSound.h"
#include "FadeSound.h"
#include "PyInt.h"
// typedef enum {st_Off, st_Starting, st_On, st_ShuttingDown} T4State;
@@ -44,7 +45,7 @@ class TCab
TCab();
~TCab();
void Init(double Initx1, double Inity1, double Initz1, double Initx2, double Inity2,
double Initz2, bool InitEnabled, bool InitOccupied);
double Initz2, bool InitEnabled, bool InitOccupied);
void Load(TQueryParserComp *Parser);
vector3 CabPos1;
vector3 CabPos2;
@@ -83,14 +84,21 @@ class TTrain
// bool SHP() { fShpTimer= 0; };
inline vector3 GetDirection() { return DynamicObject->VectorFront(); };
inline vector3 GetUp() { return DynamicObject->VectorUp(); };
inline vector3 GetDirection()
{
return DynamicObject->VectorFront();
};
inline vector3 GetUp()
{
return DynamicObject->VectorUp();
};
void UpdateMechPosition(double dt);
bool Update();
void MechStop();
// virtual bool RenderAlpha();
// McZapkie-310302: ladowanie parametrow z pliku
bool LoadMMediaFile(AnsiString asFileName);
PyObject *GetTrainState();
private: //瞠by go nic z zewn靖rz nie przestawia這
TDynamicObject *DynamicObject; // przestawia zmiana pojazdu [F5]
@@ -145,7 +153,7 @@ class TTrain
TGauge ggAntiSlipButton;
TGauge ggFuseButton;
TGauge ggConverterFuseButton; // hunter-261211: przycisk odblokowania nadmiarowego przetwornic i
// ogrzewania
// ogrzewania
TGauge ggStLinOffButton;
TGauge ggRadioButton;
TGauge ggUpperLightButton;
@@ -372,10 +380,21 @@ class TTrain
float fSPPress, fSNPress;
int iSekunda; // Ra: sekunda aktualizacji pr璠ko𦣇i
int iRadioChannel; // numer aktualnego kana逝 radiowego
TPythonScreens pyScreens;
public:
int RadioChannel() { return iRadioChannel; };
inline TDynamicObject *__fastcall Dynamic() { return DynamicObject; };
inline TMoverParameters *__fastcall Controlled() { return mvControlled; };
int RadioChannel()
{
return iRadioChannel;
};
inline TDynamicObject *__fastcall Dynamic()
{
return DynamicObject;
};
inline TMoverParameters *__fastcall Controlled()
{
return mvControlled;
};
void DynamicSet(TDynamicObject *d);
void Silence();
};

View File

@@ -37,7 +37,9 @@ TTrackFollower::TTrackFollower()
fOffsetH = 0.0; // na starcie stoi na środku
}
TTrackFollower::~TTrackFollower() {}
TTrackFollower::~TTrackFollower()
{
}
bool TTrackFollower::Init(TTrack *pTrack, TDynamicObject *NewOwner, double fDir)
{
@@ -76,7 +78,7 @@ TTrack *__fastcall TTrackFollower::SetCurrentTrack(TTrack *pTrack, int end)
// bezpośrednio
if (iSegment == 0)
{ // to jest błędna sytuacja - generuje pętle zawracające za skrzyżowaniem - ustalić,
// kiedy powstaje!
// kiedy powstaje!
iSegment = 1; // doraźna poprawka
}
if ((end ? iSegment : -iSegment) < 0)
@@ -129,14 +131,14 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
if (fDistance < 0)
{
if (iSetFlag(iEventFlag, -1)) // zawsze zeruje flagę sprawdzenia, jak mechanik
// dosiądzie, to się nie wykona
// dosiądzie, to się nie wykona
if (Owner->Mechanik) // tylko dla jednego członu
// if (TestFlag(iEventFlag,1)) //McZapkie-280503: wyzwalanie event tylko dla
// pojazdow z obsada
if (bPrimary && pCurrentTrack->evEvent1 &&
(!pCurrentTrack->evEvent1->iQueued))
Global::AddToQuery(pCurrentTrack->evEvent1, Owner); // dodanie do
// kolejki
// kolejki
// Owner->RaAxleEvent(pCurrentTrack->Event1); //Ra: dynamic zdecyduje, czy dodać do
// kolejki
// if (TestFlag(iEventallFlag,1))
@@ -151,7 +153,7 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
else if (fDistance > 0)
{
if (iSetFlag(iEventFlag, -2)) // zawsze ustawia flagę sprawdzenia, jak mechanik
// dosiądzie, to się nie wykona
// dosiądzie, to się nie wykona
if (Owner->Mechanik) // tylko dla jednego członu
// if (TestFlag(iEventFlag,2)) //sprawdzanie jest od razu w pierwszym
// warunku

View File

@@ -26,7 +26,7 @@ class TTrackFollower
int iEventFlag; // McZapkie-020602: informacja o tym czy wyzwalac zdarzenie: 0,1,2,3
int iEventallFlag;
int iSegment; // który segment toru jest u¿ywany (¿eby nie przeskakiwa³o po przestawieniu
// zwrotnicy pod taborem)
// zwrotnicy pod taborem)
public:
double fOffsetH; // Ra: odleg³oœæ œrodka osi od osi toru (dla samochodów) - u¿yæ do wê¿ykowania
vector3 pPosition; // wspó³rzêdne XYZ w uk³adzie scenerii
@@ -35,14 +35,23 @@ class TTrackFollower
~TTrackFollower();
TTrack *__fastcall SetCurrentTrack(TTrack *pTrack, int end);
bool Move(double fDistance, bool bPrimary);
inline TTrack *__fastcall GetTrack() { return pCurrentTrack; };
inline TTrack *__fastcall GetTrack()
{
return pCurrentTrack;
};
inline double GetRoll()
{
return vAngles.x;
}; // przechy³ka policzona przy ustalaniu pozycji
//{return pCurrentSegment->GetRoll(fCurrentDistance)*fDirection;}; //zamiast liczyæ mo¿na pobraæ
inline double GetDirection() { return fDirection; }; // zwrot na torze
inline double GetTranslation() { return fCurrentDistance; }; // ABu-030403
inline double GetDirection()
{
return fDirection;
}; // zwrot na torze
inline double GetTranslation()
{
return fCurrentDistance;
}; // ABu-030403
// inline double GetLength(vector3 p1, vector3 cp1, vector3 cp2, vector3 p2)
//{ return pCurrentSegment->ComputeLength(p1,cp1,cp2,p2); };
// inline double GetRadius(double L, double d); //McZapkie-150503

View File

@@ -233,7 +233,7 @@ bool TWorld::Init(HWND NhWnd, HDC hDC)
if (Global::fOpenGL >=
1.4) // 1.4 mia³o obs³ugê VBO, ale bez opcji modyfikacji fragmentu bufora
Global::bUseVBO = true; // VBO w³¹czane tylko, jeœli jest obs³uga oraz nie ustawiono
// ni¿szego numeru
// ni¿szego numeru
}
if (Global::bUseVBO)
WriteLog("Ra: The VBO is found and will be used.");
@@ -269,7 +269,7 @@ bool TWorld::Init(HWND NhWnd, HDC hDC)
if (Global::fOpenGL >= 1.2) // poni¿sze nie dzia³a w 1.1
glTexEnvf(TEXTURE_FILTER_CONTROL_EXT, TEXTURE_LOD_BIAS_EXT, -1);
GLfloat FogColor[] = {1.0f, 1.0f, 1.0f, 1.0f};
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear screen and depth buffer
glLoadIdentity();
// WriteLog("glClearColor (FogColor[0], FogColor[1], FogColor[2], 0.0); ");
@@ -404,8 +404,9 @@ bool TWorld::Init(HWND NhWnd, HDC hDC)
glFogi(GL_FOG_MODE, GL_LINEAR); // Fog Mode
WriteLog("glFogfv(GL_FOG_COLOR, FogColor);");
glFogfv(GL_FOG_COLOR, FogColor); // Set Fog Color
// glFogf(GL_FOG_DENSITY, 0.594f); // How Dense Will The Fog
//Be
// glFogf(GL_FOG_DENSITY, 0.594f); // How Dense Will The
//Fog
// Be
// glHint(GL_FOG_HINT, GL_NICEST); // Fog Hint Value
WriteLog("glFogf(GL_FOG_START, 1000.0f);");
glFogf(GL_FOG_START, 10.0f); // Fog Start Depth
@@ -836,7 +837,7 @@ void TWorld::OnKeyDown(int cKey)
if ((Global::iWriteLogEnabled & 2) == 0) // nie by³o okienka
{ // otwarcie okna
AllocConsole(); // jeœli konsola ju¿ jest, to zwróci b³¹d; uwalniaæ nie ma po
// co, bo siê od³¹czy
// co, bo siê od³¹czy
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
}
}
@@ -898,7 +899,7 @@ void TWorld::OnKeyDown(int cKey)
if (CouplNr < 0)
CouplNr = 0; // z [-1,1] zrobiæ [0,1]
int mask, set = 0; // Ra: [Shift]+[Ctrl]+[T] odpala mi jak¹œ idiotyczn¹ zmianê
// tapety pulpitu :/
// tapety pulpitu :/
if (GetAsyncKeyState(VK_SHIFT) < 0) // z [Shift] zapalanie
set = mask = 64; // bez [Ctrl] za³o¿yæ tabliczki
else if (GetAsyncKeyState(VK_CONTROL) < 0)
@@ -1166,7 +1167,7 @@ bool TWorld::Update()
double a = fmod(Global::fTimeAngleDeg, 360.0) / 180.0 * M_PI -
M_PI; // k¹t godzinny w radianach
//(a) jest traktowane jako czas miejscowy, nie uwzglêdniaj¹cy stref czasowych ani czasu
//letniego
// letniego
// aby wyznaczyæ strefê czasow¹, trzeba uwzglêdniæ po³udnik miejscowy
// aby uwzglêdniæ czas letni, trzeba sprawdziæ dzieñ roku
double L = Global::fLatitudeDeg / 180.0 * M_PI; // szerokoϾ geograficzna
@@ -1281,7 +1282,7 @@ bool TWorld::Update()
if (100.0 * LengthSquared3(d->GetPosition() - Camera.Pos) >
LengthSquared3(pDynamicNearest->GetPosition() - Camera.Pos))
d = pDynamicNearest; // jeœli najbli¿szy nie jest 10 razy bli¿ej ni¿
// poprzedni najbli¿szy, zostaje poprzedni
// poprzedni najbli¿szy, zostaje poprzedni
if (d)
pDynamicNearest = d; // zmiana na nowy, jeœli coœ znaleziony niepusty
if (pDynamicNearest)
@@ -1319,7 +1320,7 @@ bool TWorld::Update()
fTimeBuffer -= iter * fMaxDt; // reszta czasu na potem (do bufora)
if (n > 20)
n = 20; // Ra: je¿eli FPS jest zatrwa¿aj¹co niski, to fizyka nie mo¿e zaj¹æ ca³kowicie
// procesora
// procesora
#if 0
Ground.UpdatePhys(fMaxDt,n); //Ra: teraz czas kroku jest (wzglêdnie) sta³y
if (DebugModeFlag)
@@ -1404,7 +1405,7 @@ bool TWorld::Update()
}
else
{ // patrzenie w kierunku osi pojazdu, z uwzglêdnieniem kabiny - jakby z lusterka,
// ale bez odbicia
// ale bez odbicia
Camera.LookAt = Camera.Pos -
Train->GetDirection() *
Train->Dynamic()->MoverParameters->ActiveCab; //-1 albo 1
@@ -1427,7 +1428,7 @@ bool TWorld::Update()
atan(Train->pMechShake.x * Train->fMechRoll); // hustanie kamery na boki
Camera.Pitch -= atan(Train->vMechVelocity.z *
Train->fMechPitch); // hustanie kamery przod tyl //Ra: tu
// jest uciekanie kamery w górê!!!
// jest uciekanie kamery w górê!!!
}
// ABu011104: rzucanie pudlem
vector3 temp;
@@ -1834,7 +1835,7 @@ bool TWorld::Update()
{
OutText2 = Controlled->Mechanik->Relation();
if (!OutText2.IsEmpty()) // jeœli jest podana relacja, to dodajemy punkt nastêpnego
// zatrzymania
// zatrzymania
OutText2 =
Global::Bezogonkow(OutText2 + ": -> " + Controlled->Mechanik->NextStop(),
true); // dopisanie punktu zatrzymania
@@ -2430,13 +2431,12 @@ bool TWorld::Update()
glColor3f(0.0f, 1.0f, 0.0f); // zielone
glRasterPos2f(
-0.25f,
0.18f -
0.02f * (i - tmp->Mechanik->iStationStart)); // dopiero
// ustawienie
// pozycji
// ustala
// kolor,
// dziwne...
0.18f - 0.02f * (i - tmp->Mechanik->iStationStart)); // dopiero
// ustawienie
// pozycji
// ustala
// kolor,
// dziwne...
glPrint(Global::Bezogonkow(OutText1, true).c_str());
glColor3f(1.0f, 1.0f, 1.0f); // a reszta bia³ym
}
@@ -2699,7 +2699,7 @@ void TWorld::OnCommandGet(DaneRozkaz *pRozkaz)
if ((e->Type == tp_Multiple) || (e->Type == tp_Lights) ||
bool(e->evJoined)) // tylko jawne albo niejawne Multiple
Ground.AddToQuery(e, NULL); // drugi parametr to dynamic wywo³uj¹cy - tu
// brak
// brak
}
break;
case 3: // rozkaz dla AI
@@ -2767,7 +2767,7 @@ void TWorld::OnCommandGet(DaneRozkaz *pRozkaz)
}
else
{ // dla pustego wysy³amy ramki 6 z nazwami pojazdów AI (jeœli potrzebne wszystkie,
// to rozpoznaæ np. "*")
// to rozpoznaæ np. "*")
Ground.DynamicList();
}
}
@@ -2853,7 +2853,7 @@ void TWorld::CreateE3D(const AnsiString &dir, bool dyn)
{ // wypada³o by sprawdziæ, czy T3D ³adunku jest
load = loads.SubString(1, i - 1);
if (FileExists(dir + load + ".t3d")) // o ile jest plik ³adunku, bo
// inaczej nie ma to sensu
// inaczej nie ma to sensu
if (!FileExists(
dir + load +
".e3d")) // a nie ma jeszcze odpowiednika binarnego

View File

@@ -49,7 +49,10 @@ void inline vector3::SafeNormalize()
}
// From code in Graphics Gems; p. 766
inline scalar_t det2x2(scalar_t a, scalar_t b, scalar_t c, scalar_t d) { return a * d - b * c; }
inline scalar_t det2x2(scalar_t a, scalar_t b, scalar_t c, scalar_t d)
{
return a * d - b * c;
}
inline scalar_t det3x3(scalar_t a1, scalar_t a2, scalar_t a3, scalar_t b1, scalar_t b2, scalar_t b3,
scalar_t c1, scalar_t c2, scalar_t c3)
@@ -390,7 +393,8 @@ int main(int, char *[])
Testmatrix4x4();
matrixFailures = failures;
cout << endl << "****************************************" << endl;
cout << endl
<< "****************************************" << endl;
cout << "* *" << endl;
if (vectorFailures + matrixFailures == 0)
cout << "* No failures detected in Math3D *" << endl;

102
dumb3d.h
View File

@@ -27,15 +27,26 @@ namespace Math3D
typedef double scalar_t;
// inline pass-throughs to various basic math functions
// written in this style to allow for easy substitution with more efficient versions
inline scalar_t SINE_FUNCTION(scalar_t x) { return sin(x); }
inline scalar_t COSINE_FUNCTION(scalar_t x) { return cos(x); }
inline scalar_t SQRT_FUNCTION(scalar_t x) { return sqrt(x); }
inline scalar_t SINE_FUNCTION(scalar_t x)
{
return sin(x);
}
inline scalar_t COSINE_FUNCTION(scalar_t x)
{
return cos(x);
}
inline scalar_t SQRT_FUNCTION(scalar_t x)
{
return sqrt(x);
}
// 2 element vector
class vector2
{
public:
vector2(void) {}
vector2(void)
{
}
vector2(scalar_t a, scalar_t b)
{
x = a;
@@ -52,7 +63,9 @@ class vector2
class vector3
{
public:
vector3(void) {}
vector3(void)
{
}
vector3(scalar_t a, scalar_t b, scalar_t c)
{
x = a;
@@ -71,15 +84,24 @@ class vector3
void inline Normalize();
void inline SafeNormalize();
double inline Length();
void inline Zero() { x = y = z = 0.0; };
void inline Zero()
{
x = y = z = 0.0;
};
// [] is to read, () is to write (const correctness)
// const scalar_t& operator[] (int i) const { return e[i]; }
// scalar_t& operator() (int i) { return e[i]; }
// Provides access to the underlying array; useful for passing this class off to C APIs
const scalar_t *readArray(void) { return &x; }
scalar_t *getArray(void) { return &x; }
const scalar_t *readArray(void)
{
return &x;
}
scalar_t *getArray(void)
{
return &x;
}
// union
// {
@@ -107,7 +129,9 @@ class vector3
class matrix4x4
{
public:
matrix4x4(void) {}
matrix4x4(void)
{
}
// When defining matrices in C arrays, it is easiest to define them with
// the column increasing fastest. However, some APIs (OpenGL in particular) do this
@@ -130,12 +154,24 @@ class matrix4x4
// [] is to read, () is to write (const correctness)
// m[x][y] or m(x)[y] is the correct form
const scalar_t *operator[](int i) const { return &e[i << 2]; }
scalar_t *operator()(int i) { return &e[i << 2]; }
const scalar_t *operator[](int i) const
{
return &e[i << 2];
}
scalar_t *operator()(int i)
{
return &e[i << 2];
}
// Low-level access to the array.
const scalar_t *readArray(void) { return e; }
scalar_t *getArray(void) { return e; }
const scalar_t *readArray(void)
{
return e;
}
scalar_t *getArray(void)
{
return e;
}
// Construct various matrices; REPLACES CURRENT CONTENTS OF THE MATRIX!
// Written this way to work in-place and hence be somewhat more efficient
@@ -263,14 +299,20 @@ inline bool operator<(const vector3 &v1, const vector3 &v2)
return false;
}
inline vector3 operator-(const vector3 &v) { return vector3(-v.x, -v.y, -v.z); }
inline vector3 operator-(const vector3 &v)
{
return vector3(-v.x, -v.y, -v.z);
}
inline vector3 operator*(const vector3 &v, scalar_t k)
{
return vector3(k * v.x, k * v.y, k * v.z);
}
inline vector3 operator*(scalar_t k, const vector3 &v) { return v * k; }
inline vector3 operator*(scalar_t k, const vector3 &v)
{
return v * k;
}
inline vector3 &operator*=(vector3 &v, scalar_t k)
{
@@ -293,11 +335,23 @@ inline vector3 &operator/=(vector3 &v, scalar_t k)
return v;
}
inline scalar_t LengthSquared3(const vector3 &v) { return DotProduct(v, v); }
inline scalar_t LengthSquared4(const vector3 &v) { return DotProduct4(v, v); }
inline scalar_t LengthSquared3(const vector3 &v)
{
return DotProduct(v, v);
}
inline scalar_t LengthSquared4(const vector3 &v)
{
return DotProduct4(v, v);
}
inline scalar_t Length3(const vector3 &v) { return SQRT_FUNCTION(LengthSquared3(v)); }
inline scalar_t Length4(const vector3 &v) { return SQRT_FUNCTION(LengthSquared4(v)); }
inline scalar_t Length3(const vector3 &v)
{
return SQRT_FUNCTION(LengthSquared3(v));
}
inline scalar_t Length4(const vector3 &v)
{
return SQRT_FUNCTION(LengthSquared4(v));
}
inline vector3 Normalize(const vector3 &v)
{
@@ -314,7 +368,10 @@ inline vector3 SafeNormalize(const vector3 &v)
retVal = v / l;
return retVal;
}
inline vector3 Normalize4(const vector3 &v) { return v / Length4(v); }
inline vector3 Normalize4(const vector3 &v)
{
return v / Length4(v);
}
inline vector3 operator+(const vector3 &v1, const vector3 &v2)
{
@@ -372,7 +429,10 @@ void inline vector3::Normalize()
z *= il;
}
double inline vector3::Length() { return SQRT_FUNCTION(x * x + y * y + z * z); }
double inline vector3::Length()
{
return SQRT_FUNCTION(x * x + y * y + z * z);
}
inline bool operator==(const matrix4x4 &m1, const matrix4x4 &m2)
{

View File

@@ -11,7 +11,10 @@ http://mozilla.org/MPL/2.0/.
#include "Geometry.h"
inline double sqr(double a) { return (a * a); };
inline double sqr(double a)
{
return (a * a);
};
__fastcall TLine::TLine(){};
@@ -23,7 +26,10 @@ __fastcall TLine::TLine(vector3 NPoint, vector3 NVector)
__fastcall TLine::~TLine(){};
TPlane TLine::GetPlane() { return (TPlane(Point, Vector)); };
TPlane TLine::GetPlane()
{
return (TPlane(Point, Vector));
};
double TLine::GetDistance(vector3 Point1)
{
@@ -80,11 +86,17 @@ double TPlane::GetSide(vector3 Point)
// D3DMath_VectorMatrixMultiply(Vector,src,Transformations);
//};
bool TPlane::Defined() { return !(Vector == vector3(0, 0, 0)); };
bool TPlane::Defined()
{
return !(Vector == vector3(0, 0, 0));
};
//---------------------------------------------------------------------------
inline double Sum(vector3 &Vector) { return (Vector.x + Vector.y + Vector.z); };
inline double Sum(vector3 &Vector)
{
return (Vector.x + Vector.y + Vector.z);
};
bool CrossPoint(vector3 &RetPoint, TLine &Line, TPlane &Plane)
{
@@ -96,7 +108,10 @@ bool CrossPoint(vector3 &RetPoint, TLine &Line, TPlane &Plane)
return (true);
};
inline double GetLength(vector3 &Vector) { return (Vector.Length()); };
inline double GetLength(vector3 &Vector)
{
return (Vector.Length());
};
inline vector3 SetLength(vector3 &Vector, double Length)
{

View File

@@ -42,15 +42,27 @@ class cParser : public std::stringstream
getTokens();
*this >> output;
};
inline void ignoreToken() { readToken(); };
inline void ignoreToken()
{
readToken();
};
inline void ignoreTokens(int count)
{
for (int i = 0; i < count; i++)
readToken();
};
inline bool expectToken(std::string value) { return readToken() == value; };
bool eof() { return mStream->eof(); };
bool ok() { return !mStream->fail(); };
inline bool expectToken(std::string value)
{
return readToken() == value;
};
bool eof()
{
return mStream->eof();
};
bool ok()
{
return !mStream->fail();
};
bool getTokens(int Count = 1, bool ToLower = true, const char *Break = "\n\t ;");
int getProgress() const; // percentage of file processed.
// load traction?
@@ -64,11 +76,11 @@ class cParser : public std::stringstream
bool trimComments(std::string &String);
// members:
std::istream *mStream; // relevant kind of buffer is attached on creation.
std::string mPath; // path to open stream, for relative path lookups.
int mSize; // size of open stream, for progress report.
std::string mPath; // path to open stream, for relative path lookups.
int mSize; // size of open stream, for progress report.
typedef std::map<std::string, std::string> commentmap;
commentmap mComments;
cParser *mIncludeParser; // child class to handle include directives.
cParser *mIncludeParser; // child class to handle include directives.
std::vector<std::string> parameters; // parameter list for included file.
};

535
python/include/Python-ast.h Normal file
View File

@@ -0,0 +1,535 @@
/* File automatically generated by Parser/asdl_c.py. */
#include "asdl.h"
typedef struct _mod *mod_ty;
typedef struct _stmt *stmt_ty;
typedef struct _expr *expr_ty;
typedef enum _expr_context { Load=1, Store=2, Del=3, AugLoad=4, AugStore=5,
Param=6 } expr_context_ty;
typedef struct _slice *slice_ty;
typedef enum _boolop { And=1, Or=2 } boolop_ty;
typedef enum _operator { Add=1, Sub=2, Mult=3, Div=4, Mod=5, Pow=6, LShift=7,
RShift=8, BitOr=9, BitXor=10, BitAnd=11, FloorDiv=12 }
operator_ty;
typedef enum _unaryop { Invert=1, Not=2, UAdd=3, USub=4 } unaryop_ty;
typedef enum _cmpop { Eq=1, NotEq=2, Lt=3, LtE=4, Gt=5, GtE=6, Is=7, IsNot=8,
In=9, NotIn=10 } cmpop_ty;
typedef struct _comprehension *comprehension_ty;
typedef struct _excepthandler *excepthandler_ty;
typedef struct _arguments *arguments_ty;
typedef struct _keyword *keyword_ty;
typedef struct _alias *alias_ty;
enum _mod_kind {Module_kind=1, Interactive_kind=2, Expression_kind=3,
Suite_kind=4};
struct _mod {
enum _mod_kind kind;
union {
struct {
asdl_seq *body;
} Module;
struct {
asdl_seq *body;
} Interactive;
struct {
expr_ty body;
} Expression;
struct {
asdl_seq *body;
} Suite;
} v;
};
enum _stmt_kind {FunctionDef_kind=1, ClassDef_kind=2, Return_kind=3,
Delete_kind=4, Assign_kind=5, AugAssign_kind=6, Print_kind=7,
For_kind=8, While_kind=9, If_kind=10, With_kind=11,
Raise_kind=12, TryExcept_kind=13, TryFinally_kind=14,
Assert_kind=15, Import_kind=16, ImportFrom_kind=17,
Exec_kind=18, Global_kind=19, Expr_kind=20, Pass_kind=21,
Break_kind=22, Continue_kind=23};
struct _stmt {
enum _stmt_kind kind;
union {
struct {
identifier name;
arguments_ty args;
asdl_seq *body;
asdl_seq *decorator_list;
} FunctionDef;
struct {
identifier name;
asdl_seq *bases;
asdl_seq *body;
asdl_seq *decorator_list;
} ClassDef;
struct {
expr_ty value;
} Return;
struct {
asdl_seq *targets;
} Delete;
struct {
asdl_seq *targets;
expr_ty value;
} Assign;
struct {
expr_ty target;
operator_ty op;
expr_ty value;
} AugAssign;
struct {
expr_ty dest;
asdl_seq *values;
bool nl;
} Print;
struct {
expr_ty target;
expr_ty iter;
asdl_seq *body;
asdl_seq *orelse;
} For;
struct {
expr_ty test;
asdl_seq *body;
asdl_seq *orelse;
} While;
struct {
expr_ty test;
asdl_seq *body;
asdl_seq *orelse;
} If;
struct {
expr_ty context_expr;
expr_ty optional_vars;
asdl_seq *body;
} With;
struct {
expr_ty type;
expr_ty inst;
expr_ty tback;
} Raise;
struct {
asdl_seq *body;
asdl_seq *handlers;
asdl_seq *orelse;
} TryExcept;
struct {
asdl_seq *body;
asdl_seq *finalbody;
} TryFinally;
struct {
expr_ty test;
expr_ty msg;
} Assert;
struct {
asdl_seq *names;
} Import;
struct {
identifier module;
asdl_seq *names;
int level;
} ImportFrom;
struct {
expr_ty body;
expr_ty globals;
expr_ty locals;
} Exec;
struct {
asdl_seq *names;
} Global;
struct {
expr_ty value;
} Expr;
} v;
int lineno;
int col_offset;
};
enum _expr_kind {BoolOp_kind=1, BinOp_kind=2, UnaryOp_kind=3, Lambda_kind=4,
IfExp_kind=5, Dict_kind=6, Set_kind=7, ListComp_kind=8,
SetComp_kind=9, DictComp_kind=10, GeneratorExp_kind=11,
Yield_kind=12, Compare_kind=13, Call_kind=14, Repr_kind=15,
Num_kind=16, Str_kind=17, Attribute_kind=18,
Subscript_kind=19, Name_kind=20, List_kind=21, Tuple_kind=22};
struct _expr {
enum _expr_kind kind;
union {
struct {
boolop_ty op;
asdl_seq *values;
} BoolOp;
struct {
expr_ty left;
operator_ty op;
expr_ty right;
} BinOp;
struct {
unaryop_ty op;
expr_ty operand;
} UnaryOp;
struct {
arguments_ty args;
expr_ty body;
} Lambda;
struct {
expr_ty test;
expr_ty body;
expr_ty orelse;
} IfExp;
struct {
asdl_seq *keys;
asdl_seq *values;
} Dict;
struct {
asdl_seq *elts;
} Set;
struct {
expr_ty elt;
asdl_seq *generators;
} ListComp;
struct {
expr_ty elt;
asdl_seq *generators;
} SetComp;
struct {
expr_ty key;
expr_ty value;
asdl_seq *generators;
} DictComp;
struct {
expr_ty elt;
asdl_seq *generators;
} GeneratorExp;
struct {
expr_ty value;
} Yield;
struct {
expr_ty left;
asdl_int_seq *ops;
asdl_seq *comparators;
} Compare;
struct {
expr_ty func;
asdl_seq *args;
asdl_seq *keywords;
expr_ty starargs;
expr_ty kwargs;
} Call;
struct {
expr_ty value;
} Repr;
struct {
object n;
} Num;
struct {
string s;
} Str;
struct {
expr_ty value;
identifier attr;
expr_context_ty ctx;
} Attribute;
struct {
expr_ty value;
slice_ty slice;
expr_context_ty ctx;
} Subscript;
struct {
identifier id;
expr_context_ty ctx;
} Name;
struct {
asdl_seq *elts;
expr_context_ty ctx;
} List;
struct {
asdl_seq *elts;
expr_context_ty ctx;
} Tuple;
} v;
int lineno;
int col_offset;
};
enum _slice_kind {Ellipsis_kind=1, Slice_kind=2, ExtSlice_kind=3, Index_kind=4};
struct _slice {
enum _slice_kind kind;
union {
struct {
expr_ty lower;
expr_ty upper;
expr_ty step;
} Slice;
struct {
asdl_seq *dims;
} ExtSlice;
struct {
expr_ty value;
} Index;
} v;
};
struct _comprehension {
expr_ty target;
expr_ty iter;
asdl_seq *ifs;
};
enum _excepthandler_kind {ExceptHandler_kind=1};
struct _excepthandler {
enum _excepthandler_kind kind;
union {
struct {
expr_ty type;
expr_ty name;
asdl_seq *body;
} ExceptHandler;
} v;
int lineno;
int col_offset;
};
struct _arguments {
asdl_seq *args;
identifier vararg;
identifier kwarg;
asdl_seq *defaults;
};
struct _keyword {
identifier arg;
expr_ty value;
};
struct _alias {
identifier name;
identifier asname;
};
#define Module(a0, a1) _Py_Module(a0, a1)
mod_ty _Py_Module(asdl_seq * body, PyArena *arena);
#define Interactive(a0, a1) _Py_Interactive(a0, a1)
mod_ty _Py_Interactive(asdl_seq * body, PyArena *arena);
#define Expression(a0, a1) _Py_Expression(a0, a1)
mod_ty _Py_Expression(expr_ty body, PyArena *arena);
#define Suite(a0, a1) _Py_Suite(a0, a1)
mod_ty _Py_Suite(asdl_seq * body, PyArena *arena);
#define FunctionDef(a0, a1, a2, a3, a4, a5, a6) _Py_FunctionDef(a0, a1, a2, a3, a4, a5, a6)
stmt_ty _Py_FunctionDef(identifier name, arguments_ty args, asdl_seq * body,
asdl_seq * decorator_list, int lineno, int col_offset,
PyArena *arena);
#define ClassDef(a0, a1, a2, a3, a4, a5, a6) _Py_ClassDef(a0, a1, a2, a3, a4, a5, a6)
stmt_ty _Py_ClassDef(identifier name, asdl_seq * bases, asdl_seq * body,
asdl_seq * decorator_list, int lineno, int col_offset,
PyArena *arena);
#define Return(a0, a1, a2, a3) _Py_Return(a0, a1, a2, a3)
stmt_ty _Py_Return(expr_ty value, int lineno, int col_offset, PyArena *arena);
#define Delete(a0, a1, a2, a3) _Py_Delete(a0, a1, a2, a3)
stmt_ty _Py_Delete(asdl_seq * targets, int lineno, int col_offset, PyArena
*arena);
#define Assign(a0, a1, a2, a3, a4) _Py_Assign(a0, a1, a2, a3, a4)
stmt_ty _Py_Assign(asdl_seq * targets, expr_ty value, int lineno, int
col_offset, PyArena *arena);
#define AugAssign(a0, a1, a2, a3, a4, a5) _Py_AugAssign(a0, a1, a2, a3, a4, a5)
stmt_ty _Py_AugAssign(expr_ty target, operator_ty op, expr_ty value, int
lineno, int col_offset, PyArena *arena);
#define Print(a0, a1, a2, a3, a4, a5) _Py_Print(a0, a1, a2, a3, a4, a5)
stmt_ty _Py_Print(expr_ty dest, asdl_seq * values, bool nl, int lineno, int
col_offset, PyArena *arena);
#define For(a0, a1, a2, a3, a4, a5, a6) _Py_For(a0, a1, a2, a3, a4, a5, a6)
stmt_ty _Py_For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq *
orelse, int lineno, int col_offset, PyArena *arena);
#define While(a0, a1, a2, a3, a4, a5) _Py_While(a0, a1, a2, a3, a4, a5)
stmt_ty _Py_While(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno,
int col_offset, PyArena *arena);
#define If(a0, a1, a2, a3, a4, a5) _Py_If(a0, a1, a2, a3, a4, a5)
stmt_ty _Py_If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno,
int col_offset, PyArena *arena);
#define With(a0, a1, a2, a3, a4, a5) _Py_With(a0, a1, a2, a3, a4, a5)
stmt_ty _Py_With(expr_ty context_expr, expr_ty optional_vars, asdl_seq * body,
int lineno, int col_offset, PyArena *arena);
#define Raise(a0, a1, a2, a3, a4, a5) _Py_Raise(a0, a1, a2, a3, a4, a5)
stmt_ty _Py_Raise(expr_ty type, expr_ty inst, expr_ty tback, int lineno, int
col_offset, PyArena *arena);
#define TryExcept(a0, a1, a2, a3, a4, a5) _Py_TryExcept(a0, a1, a2, a3, a4, a5)
stmt_ty _Py_TryExcept(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse,
int lineno, int col_offset, PyArena *arena);
#define TryFinally(a0, a1, a2, a3, a4) _Py_TryFinally(a0, a1, a2, a3, a4)
stmt_ty _Py_TryFinally(asdl_seq * body, asdl_seq * finalbody, int lineno, int
col_offset, PyArena *arena);
#define Assert(a0, a1, a2, a3, a4) _Py_Assert(a0, a1, a2, a3, a4)
stmt_ty _Py_Assert(expr_ty test, expr_ty msg, int lineno, int col_offset,
PyArena *arena);
#define Import(a0, a1, a2, a3) _Py_Import(a0, a1, a2, a3)
stmt_ty _Py_Import(asdl_seq * names, int lineno, int col_offset, PyArena
*arena);
#define ImportFrom(a0, a1, a2, a3, a4, a5) _Py_ImportFrom(a0, a1, a2, a3, a4, a5)
stmt_ty _Py_ImportFrom(identifier module, asdl_seq * names, int level, int
lineno, int col_offset, PyArena *arena);
#define Exec(a0, a1, a2, a3, a4, a5) _Py_Exec(a0, a1, a2, a3, a4, a5)
stmt_ty _Py_Exec(expr_ty body, expr_ty globals, expr_ty locals, int lineno, int
col_offset, PyArena *arena);
#define Global(a0, a1, a2, a3) _Py_Global(a0, a1, a2, a3)
stmt_ty _Py_Global(asdl_seq * names, int lineno, int col_offset, PyArena
*arena);
#define Expr(a0, a1, a2, a3) _Py_Expr(a0, a1, a2, a3)
stmt_ty _Py_Expr(expr_ty value, int lineno, int col_offset, PyArena *arena);
#define Pass(a0, a1, a2) _Py_Pass(a0, a1, a2)
stmt_ty _Py_Pass(int lineno, int col_offset, PyArena *arena);
#define Break(a0, a1, a2) _Py_Break(a0, a1, a2)
stmt_ty _Py_Break(int lineno, int col_offset, PyArena *arena);
#define Continue(a0, a1, a2) _Py_Continue(a0, a1, a2)
stmt_ty _Py_Continue(int lineno, int col_offset, PyArena *arena);
#define BoolOp(a0, a1, a2, a3, a4) _Py_BoolOp(a0, a1, a2, a3, a4)
expr_ty _Py_BoolOp(boolop_ty op, asdl_seq * values, int lineno, int col_offset,
PyArena *arena);
#define BinOp(a0, a1, a2, a3, a4, a5) _Py_BinOp(a0, a1, a2, a3, a4, a5)
expr_ty _Py_BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int
col_offset, PyArena *arena);
#define UnaryOp(a0, a1, a2, a3, a4) _Py_UnaryOp(a0, a1, a2, a3, a4)
expr_ty _Py_UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset,
PyArena *arena);
#define Lambda(a0, a1, a2, a3, a4) _Py_Lambda(a0, a1, a2, a3, a4)
expr_ty _Py_Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset,
PyArena *arena);
#define IfExp(a0, a1, a2, a3, a4, a5) _Py_IfExp(a0, a1, a2, a3, a4, a5)
expr_ty _Py_IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int
col_offset, PyArena *arena);
#define Dict(a0, a1, a2, a3, a4) _Py_Dict(a0, a1, a2, a3, a4)
expr_ty _Py_Dict(asdl_seq * keys, asdl_seq * values, int lineno, int
col_offset, PyArena *arena);
#define Set(a0, a1, a2, a3) _Py_Set(a0, a1, a2, a3)
expr_ty _Py_Set(asdl_seq * elts, int lineno, int col_offset, PyArena *arena);
#define ListComp(a0, a1, a2, a3, a4) _Py_ListComp(a0, a1, a2, a3, a4)
expr_ty _Py_ListComp(expr_ty elt, asdl_seq * generators, int lineno, int
col_offset, PyArena *arena);
#define SetComp(a0, a1, a2, a3, a4) _Py_SetComp(a0, a1, a2, a3, a4)
expr_ty _Py_SetComp(expr_ty elt, asdl_seq * generators, int lineno, int
col_offset, PyArena *arena);
#define DictComp(a0, a1, a2, a3, a4, a5) _Py_DictComp(a0, a1, a2, a3, a4, a5)
expr_ty _Py_DictComp(expr_ty key, expr_ty value, asdl_seq * generators, int
lineno, int col_offset, PyArena *arena);
#define GeneratorExp(a0, a1, a2, a3, a4) _Py_GeneratorExp(a0, a1, a2, a3, a4)
expr_ty _Py_GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int
col_offset, PyArena *arena);
#define Yield(a0, a1, a2, a3) _Py_Yield(a0, a1, a2, a3)
expr_ty _Py_Yield(expr_ty value, int lineno, int col_offset, PyArena *arena);
#define Compare(a0, a1, a2, a3, a4, a5) _Py_Compare(a0, a1, a2, a3, a4, a5)
expr_ty _Py_Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators,
int lineno, int col_offset, PyArena *arena);
#define Call(a0, a1, a2, a3, a4, a5, a6, a7) _Py_Call(a0, a1, a2, a3, a4, a5, a6, a7)
expr_ty _Py_Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty
starargs, expr_ty kwargs, int lineno, int col_offset, PyArena
*arena);
#define Repr(a0, a1, a2, a3) _Py_Repr(a0, a1, a2, a3)
expr_ty _Py_Repr(expr_ty value, int lineno, int col_offset, PyArena *arena);
#define Num(a0, a1, a2, a3) _Py_Num(a0, a1, a2, a3)
expr_ty _Py_Num(object n, int lineno, int col_offset, PyArena *arena);
#define Str(a0, a1, a2, a3) _Py_Str(a0, a1, a2, a3)
expr_ty _Py_Str(string s, int lineno, int col_offset, PyArena *arena);
#define Attribute(a0, a1, a2, a3, a4, a5) _Py_Attribute(a0, a1, a2, a3, a4, a5)
expr_ty _Py_Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int
lineno, int col_offset, PyArena *arena);
#define Subscript(a0, a1, a2, a3, a4, a5) _Py_Subscript(a0, a1, a2, a3, a4, a5)
expr_ty _Py_Subscript(expr_ty value, slice_ty slice, expr_context_ty ctx, int
lineno, int col_offset, PyArena *arena);
#define Name(a0, a1, a2, a3, a4) _Py_Name(a0, a1, a2, a3, a4)
expr_ty _Py_Name(identifier id, expr_context_ty ctx, int lineno, int
col_offset, PyArena *arena);
#define List(a0, a1, a2, a3, a4) _Py_List(a0, a1, a2, a3, a4)
expr_ty _Py_List(asdl_seq * elts, expr_context_ty ctx, int lineno, int
col_offset, PyArena *arena);
#define Tuple(a0, a1, a2, a3, a4) _Py_Tuple(a0, a1, a2, a3, a4)
expr_ty _Py_Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno, int
col_offset, PyArena *arena);
#define Ellipsis(a0) _Py_Ellipsis(a0)
slice_ty _Py_Ellipsis(PyArena *arena);
#define Slice(a0, a1, a2, a3) _Py_Slice(a0, a1, a2, a3)
slice_ty _Py_Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena);
#define ExtSlice(a0, a1) _Py_ExtSlice(a0, a1)
slice_ty _Py_ExtSlice(asdl_seq * dims, PyArena *arena);
#define Index(a0, a1) _Py_Index(a0, a1)
slice_ty _Py_Index(expr_ty value, PyArena *arena);
#define comprehension(a0, a1, a2, a3) _Py_comprehension(a0, a1, a2, a3)
comprehension_ty _Py_comprehension(expr_ty target, expr_ty iter, asdl_seq *
ifs, PyArena *arena);
#define ExceptHandler(a0, a1, a2, a3, a4, a5) _Py_ExceptHandler(a0, a1, a2, a3, a4, a5)
excepthandler_ty _Py_ExceptHandler(expr_ty type, expr_ty name, asdl_seq * body,
int lineno, int col_offset, PyArena *arena);
#define arguments(a0, a1, a2, a3, a4) _Py_arguments(a0, a1, a2, a3, a4)
arguments_ty _Py_arguments(asdl_seq * args, identifier vararg, identifier
kwarg, asdl_seq * defaults, PyArena *arena);
#define keyword(a0, a1, a2) _Py_keyword(a0, a1, a2)
keyword_ty _Py_keyword(identifier arg, expr_ty value, PyArena *arena);
#define alias(a0, a1, a2) _Py_alias(a0, a1, a2)
alias_ty _Py_alias(identifier name, identifier asname, PyArena *arena);
PyObject* PyAST_mod2obj(mod_ty t);
mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode);
int PyAST_Check(PyObject* obj);

178
python/include/Python.h Normal file
View File

@@ -0,0 +1,178 @@
#ifndef Py_PYTHON_H
#define Py_PYTHON_H
/* Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" { */
/* Include nearly all Python header files */
#include "patchlevel.h"
#include "pyconfig.h"
#include "pymacconfig.h"
/* Cyclic gc is always enabled, starting with release 2.3a1. Supply the
* old symbol for the benefit of extension modules written before then
* that may be conditionalizing on it. The core doesn't use it anymore.
*/
#ifndef WITH_CYCLE_GC
#define WITH_CYCLE_GC 1
#endif
#include <limits.h>
#ifndef UCHAR_MAX
#error "Something's broken. UCHAR_MAX should be defined in limits.h."
#endif
#if UCHAR_MAX != 255
#error "Python's source code assumes C's unsigned char is an 8-bit type."
#endif
#if defined(__sgi) && defined(WITH_THREAD) && !defined(_SGI_MP_SOURCE)
#define _SGI_MP_SOURCE
#endif
#include <stdio.h>
#ifndef NULL
# error "Python.h requires that stdio.h define NULL."
#endif
#include <string.h>
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
/* For size_t? */
#ifdef HAVE_STDDEF_H
#include <stddef.h>
#endif
/* CAUTION: Build setups should ensure that NDEBUG is defined on the
* compiler command line when building Python in release mode; else
* assert() calls won't be removed.
*/
#include <assert.h>
#include "pyport.h"
/* pyconfig.h or pyport.h may or may not define DL_IMPORT */
#ifndef DL_IMPORT /* declarations for DLL import/export */
#define DL_IMPORT(RTYPE) RTYPE
#endif
#ifndef DL_EXPORT /* declarations for DLL import/export */
#define DL_EXPORT(RTYPE) RTYPE
#endif
/* Debug-mode build with pymalloc implies PYMALLOC_DEBUG.
* PYMALLOC_DEBUG is in error if pymalloc is not in use.
*/
#if defined(Py_DEBUG) && defined(WITH_PYMALLOC) && !defined(PYMALLOC_DEBUG)
#define PYMALLOC_DEBUG
#endif
#if defined(PYMALLOC_DEBUG) && !defined(WITH_PYMALLOC)
#error "PYMALLOC_DEBUG requires WITH_PYMALLOC"
#endif
#include "pymath.h"
#include "pymem.h"
#include "object.h"
#include "objimpl.h"
#include "pydebug.h"
#include "unicodeobject.h"
#include "intobject.h"
#include "boolobject.h"
#include "longobject.h"
#include "floatobject.h"
#ifndef WITHOUT_COMPLEX
#include "complexobject.h"
#endif
#include "rangeobject.h"
#include "stringobject.h"
#include "memoryobject.h"
#include "bufferobject.h"
#include "bytesobject.h"
#include "bytearrayobject.h"
#include "tupleobject.h"
#include "listobject.h"
#include "dictobject.h"
#include "enumobject.h"
#include "setobject.h"
#include "methodobject.h"
#include "moduleobject.h"
#include "funcobject.h"
#include "classobject.h"
#include "fileobject.h"
#include "cobject.h"
#include "pycapsule.h"
#include "traceback.h"
#include "sliceobject.h"
#include "cellobject.h"
#include "iterobject.h"
#include "genobject.h"
#include "descrobject.h"
#include "warnings.h"
#include "weakrefobject.h"
#include "codecs.h"
#include "pyerrors.h"
#include "pystate.h"
#include "pyarena.h"
#include "modsupport.h"
#include "pythonrun.h"
#include "ceval.h"
#include "sysmodule.h"
#include "intrcheck.h"
#include "import.h"
#include "abstract.h"
#include "compile.h"
#include "eval.h"
#include "pyctype.h"
#include "pystrtod.h"
#include "pystrcmp.h"
#include "dtoa.h"
/* _Py_Mangle is defined in compile.c */
PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name);
/* PyArg_GetInt is deprecated and should not be used, use PyArg_Parse(). */
#define PyArg_GetInt(v, a) PyArg_Parse((v), "i", (a))
/* PyArg_NoArgs should not be necessary.
Set ml_flags in the PyMethodDef to METH_NOARGS. */
#define PyArg_NoArgs(v) PyArg_Parse(v, "")
/* Argument must be a char or an int in [-128, 127] or [0, 255]. */
#define Py_CHARMASK(c) ((unsigned char)((c) & 0xff))
#include "pyfpe.h"
/* These definitions must match corresponding definitions in graminit.h.
There's code in compile.c that checks that they are the same. */
#define Py_single_input 256
#define Py_file_input 257
#define Py_eval_input 258
#ifdef HAVE_PTH
/* GNU pth user-space thread support */
#include <pth.h>
#endif
/* Define macros for inline documentation. */
#define PyDoc_VAR(name) static char name[]
#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str)
#ifdef WITH_DOC_STRINGS
#define PyDoc_STR(str) str
#else
#define PyDoc_STR(str) ""
#endif
#endif /* !Py_PYTHON_H */

1396
python/include/abstract.h Normal file

File diff suppressed because it is too large Load Diff

45
python/include/asdl.h Normal file
View File

@@ -0,0 +1,45 @@
#ifndef Py_ASDL_H
#define Py_ASDL_H
typedef PyObject * identifier;
typedef PyObject * string;
typedef PyObject * object;
#ifndef __cplusplus
typedef enum {false, true} bool;
#endif
/* It would be nice if the code generated by asdl_c.py was completely
independent of Python, but it is a goal the requires too much work
at this stage. So, for example, I'll represent identifiers as
interned Python strings.
*/
/* XXX A sequence should be typed so that its use can be typechecked. */
typedef struct {
int size;
void *elements[1];
} asdl_seq;
typedef struct {
int size;
int elements[1];
} asdl_int_seq;
asdl_seq *asdl_seq_new(int size, PyArena *arena);
asdl_int_seq *asdl_int_seq_new(int size, PyArena *arena);
#define asdl_seq_GET(S, I) (S)->elements[(I)]
#define asdl_seq_LEN(S) ((S) == NULL ? 0 : (S)->size)
#ifdef Py_DEBUG
#define asdl_seq_SET(S, I, V) { \
int _asdl_i = (I); \
assert((S) && _asdl_i < (S)->size); \
(S)->elements[_asdl_i] = (V); \
}
#else
#define asdl_seq_SET(S, I, V) (S)->elements[I] = (V)
#endif
#endif /* !Py_ASDL_H */

13
python/include/ast.h Normal file
View File

@@ -0,0 +1,13 @@
#ifndef Py_AST_H
#define Py_AST_H
#ifdef __cplusplus
extern "C" {
#endif
PyAPI_FUNC(mod_ty) PyAST_FromNode(const node *, PyCompilerFlags *flags,
const char *, PyArena *);
#ifdef __cplusplus
}
#endif
#endif /* !Py_AST_H */

32
python/include/bitset.h Normal file
View File

@@ -0,0 +1,32 @@
#ifndef Py_BITSET_H
#define Py_BITSET_H
#ifdef __cplusplus
extern "C" {
#endif
/* Bitset interface */
#define BYTE char
typedef BYTE *bitset;
bitset newbitset(int nbits);
void delbitset(bitset bs);
#define testbit(ss, ibit) (((ss)[BIT2BYTE(ibit)] & BIT2MASK(ibit)) != 0)
int addbit(bitset bs, int ibit); /* Returns 0 if already set */
int samebitset(bitset bs1, bitset bs2, int nbits);
void mergebitset(bitset bs1, bitset bs2, int nbits);
#define BITSPERBYTE (8*sizeof(BYTE))
#define NBYTES(nbits) (((nbits) + BITSPERBYTE - 1) / BITSPERBYTE)
#define BIT2BYTE(ibit) ((ibit) / BITSPERBYTE)
#define BIT2SHIFT(ibit) ((ibit) % BITSPERBYTE)
#define BIT2MASK(ibit) (1 << BIT2SHIFT(ibit))
#define BYTE2BIT(ibyte) ((ibyte) * BITSPERBYTE)
#ifdef __cplusplus
}
#endif
#endif /* !Py_BITSET_H */

View File

@@ -0,0 +1,36 @@
/* Boolean object interface */
#ifndef Py_BOOLOBJECT_H
#define Py_BOOLOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
typedef PyIntObject PyBoolObject;
PyAPI_DATA(PyTypeObject) PyBool_Type;
#define PyBool_Check(x) (Py_TYPE(x) == &PyBool_Type)
/* Py_False and Py_True are the only two bools in existence.
Don't forget to apply Py_INCREF() when returning either!!! */
/* Don't use these directly */
PyAPI_DATA(PyIntObject) _Py_ZeroStruct, _Py_TrueStruct;
/* Use these macros */
#define Py_False ((PyObject *) &_Py_ZeroStruct)
#define Py_True ((PyObject *) &_Py_TrueStruct)
/* Macros for returning Py_True or Py_False, respectively */
#define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True
#define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False
/* Function to return a bool from a C long */
PyAPI_FUNC(PyObject *) PyBool_FromLong(long);
#ifdef __cplusplus
}
#endif
#endif /* !Py_BOOLOBJECT_H */

View File

@@ -0,0 +1,33 @@
/* Buffer object interface */
/* Note: the object's structure is private */
#ifndef Py_BUFFEROBJECT_H
#define Py_BUFFEROBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
PyAPI_DATA(PyTypeObject) PyBuffer_Type;
#define PyBuffer_Check(op) (Py_TYPE(op) == &PyBuffer_Type)
#define Py_END_OF_BUFFER (-1)
PyAPI_FUNC(PyObject *) PyBuffer_FromObject(PyObject *base,
Py_ssize_t offset, Py_ssize_t size);
PyAPI_FUNC(PyObject *) PyBuffer_FromReadWriteObject(PyObject *base,
Py_ssize_t offset,
Py_ssize_t size);
PyAPI_FUNC(PyObject *) PyBuffer_FromMemory(void *ptr, Py_ssize_t size);
PyAPI_FUNC(PyObject *) PyBuffer_FromReadWriteMemory(void *ptr, Py_ssize_t size);
PyAPI_FUNC(PyObject *) PyBuffer_New(Py_ssize_t size);
#ifdef __cplusplus
}
#endif
#endif /* !Py_BUFFEROBJECT_H */

View File

@@ -0,0 +1,57 @@
/* ByteArray object interface */
#ifndef Py_BYTEARRAYOBJECT_H
#define Py_BYTEARRAYOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdarg.h>
/* Type PyByteArrayObject represents a mutable array of bytes.
* The Python API is that of a sequence;
* the bytes are mapped to ints in [0, 256).
* Bytes are not characters; they may be used to encode characters.
* The only way to go between bytes and str/unicode is via encoding
* and decoding.
* For the convenience of C programmers, the bytes type is considered
* to contain a char pointer, not an unsigned char pointer.
*/
/* Object layout */
typedef struct {
PyObject_VAR_HEAD
/* XXX(nnorwitz): should ob_exports be Py_ssize_t? */
int ob_exports; /* how many buffer exports */
Py_ssize_t ob_alloc; /* How many bytes allocated */
char *ob_bytes;
} PyByteArrayObject;
/* Type object */
PyAPI_DATA(PyTypeObject) PyByteArray_Type;
PyAPI_DATA(PyTypeObject) PyByteArrayIter_Type;
/* Type check macros */
#define PyByteArray_Check(self) PyObject_TypeCheck(self, &PyByteArray_Type)
#define PyByteArray_CheckExact(self) (Py_TYPE(self) == &PyByteArray_Type)
/* Direct API functions */
PyAPI_FUNC(PyObject *) PyByteArray_FromObject(PyObject *);
PyAPI_FUNC(PyObject *) PyByteArray_Concat(PyObject *, PyObject *);
PyAPI_FUNC(PyObject *) PyByteArray_FromStringAndSize(const char *, Py_ssize_t);
PyAPI_FUNC(Py_ssize_t) PyByteArray_Size(PyObject *);
PyAPI_FUNC(char *) PyByteArray_AsString(PyObject *);
PyAPI_FUNC(int) PyByteArray_Resize(PyObject *, Py_ssize_t);
/* Macros, trading safety for speed */
#define PyByteArray_AS_STRING(self) \
(assert(PyByteArray_Check(self)), \
Py_SIZE(self) ? ((PyByteArrayObject *)(self))->ob_bytes : _PyByteArray_empty_string)
#define PyByteArray_GET_SIZE(self) (assert(PyByteArray_Check(self)),Py_SIZE(self))
PyAPI_DATA(char) _PyByteArray_empty_string[];
#ifdef __cplusplus
}
#endif
#endif /* !Py_BYTEARRAYOBJECT_H */

View File

@@ -0,0 +1,75 @@
#ifndef Py_BYTES_CTYPE_H
#define Py_BYTES_CTYPE_H
/*
* The internal implementation behind PyString (bytes) and PyBytes (buffer)
* methods of the given names, they operate on ASCII byte strings.
*/
extern PyObject* _Py_bytes_isspace(const char *cptr, Py_ssize_t len);
extern PyObject* _Py_bytes_isalpha(const char *cptr, Py_ssize_t len);
extern PyObject* _Py_bytes_isalnum(const char *cptr, Py_ssize_t len);
extern PyObject* _Py_bytes_isdigit(const char *cptr, Py_ssize_t len);
extern PyObject* _Py_bytes_islower(const char *cptr, Py_ssize_t len);
extern PyObject* _Py_bytes_isupper(const char *cptr, Py_ssize_t len);
extern PyObject* _Py_bytes_istitle(const char *cptr, Py_ssize_t len);
/* These store their len sized answer in the given preallocated *result arg. */
extern void _Py_bytes_lower(char *result, const char *cptr, Py_ssize_t len);
extern void _Py_bytes_upper(char *result, const char *cptr, Py_ssize_t len);
extern void _Py_bytes_title(char *result, char *s, Py_ssize_t len);
extern void _Py_bytes_capitalize(char *result, char *s, Py_ssize_t len);
extern void _Py_bytes_swapcase(char *result, char *s, Py_ssize_t len);
/* Shared __doc__ strings. */
extern const char _Py_isspace__doc__[];
extern const char _Py_isalpha__doc__[];
extern const char _Py_isalnum__doc__[];
extern const char _Py_isdigit__doc__[];
extern const char _Py_islower__doc__[];
extern const char _Py_isupper__doc__[];
extern const char _Py_istitle__doc__[];
extern const char _Py_lower__doc__[];
extern const char _Py_upper__doc__[];
extern const char _Py_title__doc__[];
extern const char _Py_capitalize__doc__[];
extern const char _Py_swapcase__doc__[];
/* These are left in for backward compatibility and will be removed
in 2.8/3.2 */
#define ISLOWER(c) Py_ISLOWER(c)
#define ISUPPER(c) Py_ISUPPER(c)
#define ISALPHA(c) Py_ISALPHA(c)
#define ISDIGIT(c) Py_ISDIGIT(c)
#define ISXDIGIT(c) Py_ISXDIGIT(c)
#define ISALNUM(c) Py_ISALNUM(c)
#define ISSPACE(c) Py_ISSPACE(c)
#undef islower
#define islower(c) undefined_islower(c)
#undef isupper
#define isupper(c) undefined_isupper(c)
#undef isalpha
#define isalpha(c) undefined_isalpha(c)
#undef isdigit
#define isdigit(c) undefined_isdigit(c)
#undef isxdigit
#define isxdigit(c) undefined_isxdigit(c)
#undef isalnum
#define isalnum(c) undefined_isalnum(c)
#undef isspace
#define isspace(c) undefined_isspace(c)
/* These are left in for backward compatibility and will be removed
in 2.8/3.2 */
#define TOLOWER(c) Py_TOLOWER(c)
#define TOUPPER(c) Py_TOUPPER(c)
#undef tolower
#define tolower(c) undefined_tolower(c)
#undef toupper
#define toupper(c) undefined_toupper(c)
/* this is needed because some docs are shared from the .o, not static */
#define PyDoc_STRVAR_shared(name,str) const char name[] = PyDoc_STR(str)
#endif /* !Py_BYTES_CTYPE_H */

View File

@@ -0,0 +1,27 @@
#define PyBytesObject PyStringObject
#define PyBytes_Type PyString_Type
#define PyBytes_Check PyString_Check
#define PyBytes_CheckExact PyString_CheckExact
#define PyBytes_CHECK_INTERNED PyString_CHECK_INTERNED
#define PyBytes_AS_STRING PyString_AS_STRING
#define PyBytes_GET_SIZE PyString_GET_SIZE
#define Py_TPFLAGS_BYTES_SUBCLASS Py_TPFLAGS_STRING_SUBCLASS
#define PyBytes_FromStringAndSize PyString_FromStringAndSize
#define PyBytes_FromString PyString_FromString
#define PyBytes_FromFormatV PyString_FromFormatV
#define PyBytes_FromFormat PyString_FromFormat
#define PyBytes_Size PyString_Size
#define PyBytes_AsString PyString_AsString
#define PyBytes_Repr PyString_Repr
#define PyBytes_Concat PyString_Concat
#define PyBytes_ConcatAndDel PyString_ConcatAndDel
#define _PyBytes_Resize _PyString_Resize
#define _PyBytes_Eq _PyString_Eq
#define PyBytes_Format PyString_Format
#define _PyBytes_FormatLong _PyString_FormatLong
#define PyBytes_DecodeEscape PyString_DecodeEscape
#define _PyBytes_Join _PyString_Join
#define PyBytes_AsStringAndSize PyString_AsStringAndSize
#define _PyBytes_InsertThousandsGrouping _PyString_InsertThousandsGrouping

View File

@@ -0,0 +1,73 @@
#ifndef Py_CSTRINGIO_H
#define Py_CSTRINGIO_H
#ifdef __cplusplus
extern "C" {
#endif
/*
This header provides access to cStringIO objects from C.
Functions are provided for calling cStringIO objects and
macros are provided for testing whether you have cStringIO
objects.
Before calling any of the functions or macros, you must initialize
the routines with:
PycString_IMPORT
This would typically be done in your init function.
*/
#define PycStringIO_CAPSULE_NAME "cStringIO.cStringIO_CAPI"
#define PycString_IMPORT \
PycStringIO = ((struct PycStringIO_CAPI*)PyCapsule_Import(\
PycStringIO_CAPSULE_NAME, 0))
/* Basic functions to manipulate cStringIO objects from C */
static struct PycStringIO_CAPI {
/* Read a string from an input object. If the last argument
is -1, the remainder will be read.
*/
int(*cread)(PyObject *, char **, Py_ssize_t);
/* Read a line from an input object. Returns the length of the read
line as an int and a pointer inside the object buffer as char** (so
the caller doesn't have to provide its own buffer as destination).
*/
int(*creadline)(PyObject *, char **);
/* Write a string to an output object*/
int(*cwrite)(PyObject *, const char *, Py_ssize_t);
/* Get the output object as a Python string (returns new reference). */
PyObject *(*cgetvalue)(PyObject *);
/* Create a new output object */
PyObject *(*NewOutput)(int);
/* Create an input object from a Python string
(copies the Python string reference).
*/
PyObject *(*NewInput)(PyObject *);
/* The Python types for cStringIO input and output objects.
Note that you can do input on an output object.
*/
PyTypeObject *InputType, *OutputType;
} *PycStringIO;
/* These can be used to test if you have one */
#define PycStringIO_InputCheck(O) \
(Py_TYPE(O)==PycStringIO->InputType)
#define PycStringIO_OutputCheck(O) \
(Py_TYPE(O)==PycStringIO->OutputType)
#ifdef __cplusplus
}
#endif
#endif /* !Py_CSTRINGIO_H */

View File

@@ -0,0 +1,28 @@
/* Cell object interface */
#ifndef Py_CELLOBJECT_H
#define Py_CELLOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
PyObject_HEAD
PyObject *ob_ref; /* Content of the cell or NULL when empty */
} PyCellObject;
PyAPI_DATA(PyTypeObject) PyCell_Type;
#define PyCell_Check(op) (Py_TYPE(op) == &PyCell_Type)
PyAPI_FUNC(PyObject *) PyCell_New(PyObject *);
PyAPI_FUNC(PyObject *) PyCell_Get(PyObject *);
PyAPI_FUNC(int) PyCell_Set(PyObject *, PyObject *);
#define PyCell_GET(op) (((PyCellObject *)(op))->ob_ref)
#define PyCell_SET(op, v) (((PyCellObject *)(op))->ob_ref = v)
#ifdef __cplusplus
}
#endif
#endif /* !Py_TUPLEOBJECT_H */

153
python/include/ceval.h Normal file
View File

@@ -0,0 +1,153 @@
#ifndef Py_CEVAL_H
#define Py_CEVAL_H
#ifdef __cplusplus
extern "C" {
#endif
/* Interface to random parts in ceval.c */
PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords(
PyObject *, PyObject *, PyObject *);
/* Inline this */
#define PyEval_CallObject(func,arg) \
PyEval_CallObjectWithKeywords(func, arg, (PyObject *)NULL)
PyAPI_FUNC(PyObject *) PyEval_CallFunction(PyObject *obj,
const char *format, ...);
PyAPI_FUNC(PyObject *) PyEval_CallMethod(PyObject *obj,
const char *methodname,
const char *format, ...);
PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *);
PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);
struct _frame; /* Avoid including frameobject.h */
PyAPI_FUNC(PyObject *) PyEval_GetBuiltins(void);
PyAPI_FUNC(PyObject *) PyEval_GetGlobals(void);
PyAPI_FUNC(PyObject *) PyEval_GetLocals(void);
PyAPI_FUNC(struct _frame *) PyEval_GetFrame(void);
PyAPI_FUNC(int) PyEval_GetRestricted(void);
/* Look at the current frame's (if any) code's co_flags, and turn on
the corresponding compiler flags in cf->cf_flags. Return 1 if any
flag was set, else return 0. */
PyAPI_FUNC(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf);
PyAPI_FUNC(int) Py_FlushLine(void);
PyAPI_FUNC(int) Py_AddPendingCall(int (*func)(void *), void *arg);
PyAPI_FUNC(int) Py_MakePendingCalls(void);
/* Protection against deeply nested recursive calls */
PyAPI_FUNC(void) Py_SetRecursionLimit(int);
PyAPI_FUNC(int) Py_GetRecursionLimit(void);
#define Py_EnterRecursiveCall(where) \
(_Py_MakeRecCheck(PyThreadState_GET()->recursion_depth) && \
_Py_CheckRecursiveCall(where))
#define Py_LeaveRecursiveCall() \
(--PyThreadState_GET()->recursion_depth)
PyAPI_FUNC(int) _Py_CheckRecursiveCall(char *where);
PyAPI_DATA(int) _Py_CheckRecursionLimit;
#ifdef USE_STACKCHECK
# define _Py_MakeRecCheck(x) (++(x) > --_Py_CheckRecursionLimit)
#else
# define _Py_MakeRecCheck(x) (++(x) > _Py_CheckRecursionLimit)
#endif
PyAPI_FUNC(const char *) PyEval_GetFuncName(PyObject *);
PyAPI_FUNC(const char *) PyEval_GetFuncDesc(PyObject *);
PyAPI_FUNC(PyObject *) PyEval_GetCallStats(PyObject *);
PyAPI_FUNC(PyObject *) PyEval_EvalFrame(struct _frame *);
PyAPI_FUNC(PyObject *) PyEval_EvalFrameEx(struct _frame *f, int exc);
/* this used to be handled on a per-thread basis - now just two globals */
PyAPI_DATA(volatile int) _Py_Ticker;
PyAPI_DATA(int) _Py_CheckInterval;
/* Interface for threads.
A module that plans to do a blocking system call (or something else
that lasts a long time and doesn't touch Python data) can allow other
threads to run as follows:
...preparations here...
Py_BEGIN_ALLOW_THREADS
...blocking system call here...
Py_END_ALLOW_THREADS
...interpret result here...
The Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS pair expands to a
{}-surrounded block.
To leave the block in the middle (e.g., with return), you must insert
a line containing Py_BLOCK_THREADS before the return, e.g.
if (...premature_exit...) {
Py_BLOCK_THREADS
PyErr_SetFromErrno(PyExc_IOError);
return NULL;
}
An alternative is:
Py_BLOCK_THREADS
if (...premature_exit...) {
PyErr_SetFromErrno(PyExc_IOError);
return NULL;
}
Py_UNBLOCK_THREADS
For convenience, that the value of 'errno' is restored across
Py_END_ALLOW_THREADS and Py_BLOCK_THREADS.
WARNING: NEVER NEST CALLS TO Py_BEGIN_ALLOW_THREADS AND
Py_END_ALLOW_THREADS!!!
The function PyEval_InitThreads() should be called only from
initthread() in "threadmodule.c".
Note that not yet all candidates have been converted to use this
mechanism!
*/
PyAPI_FUNC(PyThreadState *) PyEval_SaveThread(void);
PyAPI_FUNC(void) PyEval_RestoreThread(PyThreadState *);
#ifdef WITH_THREAD
PyAPI_FUNC(int) PyEval_ThreadsInitialized(void);
PyAPI_FUNC(void) PyEval_InitThreads(void);
PyAPI_FUNC(void) PyEval_AcquireLock(void);
PyAPI_FUNC(void) PyEval_ReleaseLock(void);
PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate);
PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate);
PyAPI_FUNC(void) PyEval_ReInitThreads(void);
#define Py_BEGIN_ALLOW_THREADS { \
PyThreadState *_save; \
_save = PyEval_SaveThread();
#define Py_BLOCK_THREADS PyEval_RestoreThread(_save);
#define Py_UNBLOCK_THREADS _save = PyEval_SaveThread();
#define Py_END_ALLOW_THREADS PyEval_RestoreThread(_save); \
}
#else /* !WITH_THREAD */
#define Py_BEGIN_ALLOW_THREADS {
#define Py_BLOCK_THREADS
#define Py_UNBLOCK_THREADS
#define Py_END_ALLOW_THREADS }
#endif /* !WITH_THREAD */
PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *);
#ifdef __cplusplus
}
#endif
#endif /* !Py_CEVAL_H */

View File

@@ -0,0 +1,83 @@
/* Class object interface */
/* Revealing some structures (not for general use) */
#ifndef Py_CLASSOBJECT_H
#define Py_CLASSOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
PyObject_HEAD
PyObject *cl_bases; /* A tuple of class objects */
PyObject *cl_dict; /* A dictionary */
PyObject *cl_name; /* A string */
/* The following three are functions or NULL */
PyObject *cl_getattr;
PyObject *cl_setattr;
PyObject *cl_delattr;
PyObject *cl_weakreflist; /* List of weak references */
} PyClassObject;
typedef struct {
PyObject_HEAD
PyClassObject *in_class; /* The class object */
PyObject *in_dict; /* A dictionary */
PyObject *in_weakreflist; /* List of weak references */
} PyInstanceObject;
typedef struct {
PyObject_HEAD
PyObject *im_func; /* The callable object implementing the method */
PyObject *im_self; /* The instance it is bound to, or NULL */
PyObject *im_class; /* The class that asked for the method */
PyObject *im_weakreflist; /* List of weak references */
} PyMethodObject;
PyAPI_DATA(PyTypeObject) PyClass_Type, PyInstance_Type, PyMethod_Type;
#define PyClass_Check(op) ((op)->ob_type == &PyClass_Type)
#define PyInstance_Check(op) ((op)->ob_type == &PyInstance_Type)
#define PyMethod_Check(op) ((op)->ob_type == &PyMethod_Type)
PyAPI_FUNC(PyObject *) PyClass_New(PyObject *, PyObject *, PyObject *);
PyAPI_FUNC(PyObject *) PyInstance_New(PyObject *, PyObject *,
PyObject *);
PyAPI_FUNC(PyObject *) PyInstance_NewRaw(PyObject *, PyObject *);
PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *, PyObject *);
PyAPI_FUNC(PyObject *) PyMethod_Function(PyObject *);
PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *);
PyAPI_FUNC(PyObject *) PyMethod_Class(PyObject *);
/* Look up attribute with name (a string) on instance object pinst, using
* only the instance and base class dicts. If a descriptor is found in
* a class dict, the descriptor is returned without calling it.
* Returns NULL if nothing found, else a borrowed reference to the
* value associated with name in the dict in which name was found.
* The point of this routine is that it never calls arbitrary Python
* code, so is always "safe": all it does is dict lookups. The function
* can't fail, never sets an exception, and NULL is not an error (it just
* means "not found").
*/
PyAPI_FUNC(PyObject *) _PyInstance_Lookup(PyObject *pinst, PyObject *name);
/* Macros for direct access to these values. Type checks are *not*
done, so use with care. */
#define PyMethod_GET_FUNCTION(meth) \
(((PyMethodObject *)meth) -> im_func)
#define PyMethod_GET_SELF(meth) \
(((PyMethodObject *)meth) -> im_self)
#define PyMethod_GET_CLASS(meth) \
(((PyMethodObject *)meth) -> im_class)
PyAPI_FUNC(int) PyClass_IsSubclass(PyObject *, PyObject *);
PyAPI_FUNC(int) PyMethod_ClearFreeList(void);
#ifdef __cplusplus
}
#endif
#endif /* !Py_CLASSOBJECT_H */

89
python/include/cobject.h Normal file
View File

@@ -0,0 +1,89 @@
/*
CObjects are marked Pending Deprecation as of Python 2.7.
The full schedule for 2.x is as follows:
- CObjects are marked Pending Deprecation in Python 2.7.
- CObjects will be marked Deprecated in Python 2.8
(if there is one).
- CObjects will be removed in Python 2.9 (if there is one).
Additionally, for the Python 3.x series:
- CObjects were marked Deprecated in Python 3.1.
- CObjects will be removed in Python 3.2.
You should switch all use of CObjects to capsules. Capsules
have a safer and more consistent API. For more information,
see Include/pycapsule.h, or read the "Capsules" topic in
the "Python/C API Reference Manual".
Python 2.7 no longer uses CObjects itself; all objects which
were formerly CObjects are now capsules. Note that this change
does not by itself break binary compatibility with extensions
built for previous versions of Python--PyCObject_AsVoidPtr()
has been changed to also understand capsules.
*/
/* original file header comment follows: */
/* C objects to be exported from one extension module to another.
C objects are used for communication between extension modules.
They provide a way for an extension module to export a C interface
to other extension modules, so that extension modules can use the
Python import mechanism to link to one another.
*/
#ifndef Py_COBJECT_H
#define Py_COBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
PyAPI_DATA(PyTypeObject) PyCObject_Type;
#define PyCObject_Check(op) (Py_TYPE(op) == &PyCObject_Type)
/* Create a PyCObject from a pointer to a C object and an optional
destructor function. If the second argument is non-null, then it
will be called with the first argument if and when the PyCObject is
destroyed.
*/
PyAPI_FUNC(PyObject *) PyCObject_FromVoidPtr(
void *cobj, void (*destruct)(void*));
/* Create a PyCObject from a pointer to a C object, a description object,
and an optional destructor function. If the third argument is non-null,
then it will be called with the first and second arguments if and when
the PyCObject is destroyed.
*/
PyAPI_FUNC(PyObject *) PyCObject_FromVoidPtrAndDesc(
void *cobj, void *desc, void (*destruct)(void*,void*));
/* Retrieve a pointer to a C object from a PyCObject. */
PyAPI_FUNC(void *) PyCObject_AsVoidPtr(PyObject *);
/* Retrieve a pointer to a description object from a PyCObject. */
PyAPI_FUNC(void *) PyCObject_GetDesc(PyObject *);
/* Import a pointer to a C object from a module using a PyCObject. */
PyAPI_FUNC(void *) PyCObject_Import(char *module_name, char *cobject_name);
/* Modify a C object. Fails (==0) if object has a destructor. */
PyAPI_FUNC(int) PyCObject_SetVoidPtr(PyObject *self, void *cobj);
typedef struct {
PyObject_HEAD
void *cobject;
void *desc;
void (*destructor)(void *);
} PyCObject;
#ifdef __cplusplus
}
#endif
#endif /* !Py_COBJECT_H */

107
python/include/code.h Normal file
View File

@@ -0,0 +1,107 @@
/* Definitions for bytecode */
#ifndef Py_CODE_H
#define Py_CODE_H
#ifdef __cplusplus
extern "C" {
#endif
/* Bytecode object */
typedef struct {
PyObject_HEAD
int co_argcount; /* #arguments, except *args */
int co_nlocals; /* #local variables */
int co_stacksize; /* #entries needed for evaluation stack */
int co_flags; /* CO_..., see below */
PyObject *co_code; /* instruction opcodes */
PyObject *co_consts; /* list (constants used) */
PyObject *co_names; /* list of strings (names used) */
PyObject *co_varnames; /* tuple of strings (local variable names) */
PyObject *co_freevars; /* tuple of strings (free variable names) */
PyObject *co_cellvars; /* tuple of strings (cell variable names) */
/* The rest doesn't count for hash/cmp */
PyObject *co_filename; /* string (where it was loaded from) */
PyObject *co_name; /* string (name, for reference) */
int co_firstlineno; /* first source line number */
PyObject *co_lnotab; /* string (encoding addr<->lineno mapping) See
Objects/lnotab_notes.txt for details. */
void *co_zombieframe; /* for optimization only (see frameobject.c) */
PyObject *co_weakreflist; /* to support weakrefs to code objects */
} PyCodeObject;
/* Masks for co_flags above */
#define CO_OPTIMIZED 0x0001
#define CO_NEWLOCALS 0x0002
#define CO_VARARGS 0x0004
#define CO_VARKEYWORDS 0x0008
#define CO_NESTED 0x0010
#define CO_GENERATOR 0x0020
/* The CO_NOFREE flag is set if there are no free or cell variables.
This information is redundant, but it allows a single flag test
to determine whether there is any extra work to be done when the
call frame it setup.
*/
#define CO_NOFREE 0x0040
#if 0
/* This is no longer used. Stopped defining in 2.5, do not re-use. */
#define CO_GENERATOR_ALLOWED 0x1000
#endif
#define CO_FUTURE_DIVISION 0x2000
#define CO_FUTURE_ABSOLUTE_IMPORT 0x4000 /* do absolute imports by default */
#define CO_FUTURE_WITH_STATEMENT 0x8000
#define CO_FUTURE_PRINT_FUNCTION 0x10000
#define CO_FUTURE_UNICODE_LITERALS 0x20000
/* This should be defined if a future statement modifies the syntax.
For example, when a keyword is added.
*/
#if 1
#define PY_PARSER_REQUIRES_FUTURE_KEYWORD
#endif
#define CO_MAXBLOCKS 20 /* Max static block nesting within a function */
PyAPI_DATA(PyTypeObject) PyCode_Type;
#define PyCode_Check(op) (Py_TYPE(op) == &PyCode_Type)
#define PyCode_GetNumFree(op) (PyTuple_GET_SIZE((op)->co_freevars))
/* Public interface */
PyAPI_FUNC(PyCodeObject *) PyCode_New(
int, int, int, int, PyObject *, PyObject *, PyObject *, PyObject *,
PyObject *, PyObject *, PyObject *, PyObject *, int, PyObject *);
/* same as struct above */
/* Creates a new empty code object with the specified source location. */
PyAPI_FUNC(PyCodeObject *)
PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno);
/* Return the line number associated with the specified bytecode index
in this code object. If you just need the line number of a frame,
use PyFrame_GetLineNumber() instead. */
PyAPI_FUNC(int) PyCode_Addr2Line(PyCodeObject *, int);
/* for internal use only */
#define _PyCode_GETCODEPTR(co, pp) \
((*Py_TYPE((co)->co_code)->tp_as_buffer->bf_getreadbuffer) \
((co)->co_code, 0, (void **)(pp)))
typedef struct _addr_pair {
int ap_lower;
int ap_upper;
} PyAddrPair;
/* Update *bounds to describe the first and one-past-the-last instructions in the
same line as lasti. Return the number of that line.
*/
PyAPI_FUNC(int) _PyCode_CheckLineNumber(PyCodeObject* co,
int lasti, PyAddrPair *bounds);
PyAPI_FUNC(PyObject*) PyCode_Optimize(PyObject *code, PyObject* consts,
PyObject *names, PyObject *lineno_obj);
#ifdef __cplusplus
}
#endif
#endif /* !Py_CODE_H */

167
python/include/codecs.h Normal file
View File

@@ -0,0 +1,167 @@
#ifndef Py_CODECREGISTRY_H
#define Py_CODECREGISTRY_H
#ifdef __cplusplus
extern "C" {
#endif
/* ------------------------------------------------------------------------
Python Codec Registry and support functions
Written by Marc-Andre Lemburg (mal@lemburg.com).
Copyright (c) Corporation for National Research Initiatives.
------------------------------------------------------------------------ */
/* Register a new codec search function.
As side effect, this tries to load the encodings package, if not
yet done, to make sure that it is always first in the list of
search functions.
The search_function's refcount is incremented by this function. */
PyAPI_FUNC(int) PyCodec_Register(
PyObject *search_function
);
/* Codec register lookup API.
Looks up the given encoding and returns a CodecInfo object with
function attributes which implement the different aspects of
processing the encoding.
The encoding string is looked up converted to all lower-case
characters. This makes encodings looked up through this mechanism
effectively case-insensitive.
If no codec is found, a KeyError is set and NULL returned.
As side effect, this tries to load the encodings package, if not
yet done. This is part of the lazy load strategy for the encodings
package.
*/
PyAPI_FUNC(PyObject *) _PyCodec_Lookup(
const char *encoding
);
/* Generic codec based encoding API.
object is passed through the encoder function found for the given
encoding using the error handling method defined by errors. errors
may be NULL to use the default method defined for the codec.
Raises a LookupError in case no encoder can be found.
*/
PyAPI_FUNC(PyObject *) PyCodec_Encode(
PyObject *object,
const char *encoding,
const char *errors
);
/* Generic codec based decoding API.
object is passed through the decoder function found for the given
encoding using the error handling method defined by errors. errors
may be NULL to use the default method defined for the codec.
Raises a LookupError in case no encoder can be found.
*/
PyAPI_FUNC(PyObject *) PyCodec_Decode(
PyObject *object,
const char *encoding,
const char *errors
);
/* --- Codec Lookup APIs --------------------------------------------------
All APIs return a codec object with incremented refcount and are
based on _PyCodec_Lookup(). The same comments w/r to the encoding
name also apply to these APIs.
*/
/* Get an encoder function for the given encoding. */
PyAPI_FUNC(PyObject *) PyCodec_Encoder(
const char *encoding
);
/* Get a decoder function for the given encoding. */
PyAPI_FUNC(PyObject *) PyCodec_Decoder(
const char *encoding
);
/* Get a IncrementalEncoder object for the given encoding. */
PyAPI_FUNC(PyObject *) PyCodec_IncrementalEncoder(
const char *encoding,
const char *errors
);
/* Get a IncrementalDecoder object function for the given encoding. */
PyAPI_FUNC(PyObject *) PyCodec_IncrementalDecoder(
const char *encoding,
const char *errors
);
/* Get a StreamReader factory function for the given encoding. */
PyAPI_FUNC(PyObject *) PyCodec_StreamReader(
const char *encoding,
PyObject *stream,
const char *errors
);
/* Get a StreamWriter factory function for the given encoding. */
PyAPI_FUNC(PyObject *) PyCodec_StreamWriter(
const char *encoding,
PyObject *stream,
const char *errors
);
/* Unicode encoding error handling callback registry API */
/* Register the error handling callback function error under the given
name. This function will be called by the codec when it encounters
unencodable characters/undecodable bytes and doesn't know the
callback name, when name is specified as the error parameter
in the call to the encode/decode function.
Return 0 on success, -1 on error */
PyAPI_FUNC(int) PyCodec_RegisterError(const char *name, PyObject *error);
/* Lookup the error handling callback function registered under the given
name. As a special case NULL can be passed, in which case
the error handling callback for "strict" will be returned. */
PyAPI_FUNC(PyObject *) PyCodec_LookupError(const char *name);
/* raise exc as an exception */
PyAPI_FUNC(PyObject *) PyCodec_StrictErrors(PyObject *exc);
/* ignore the unicode error, skipping the faulty input */
PyAPI_FUNC(PyObject *) PyCodec_IgnoreErrors(PyObject *exc);
/* replace the unicode encode error with ? or U+FFFD */
PyAPI_FUNC(PyObject *) PyCodec_ReplaceErrors(PyObject *exc);
/* replace the unicode encode error with XML character references */
PyAPI_FUNC(PyObject *) PyCodec_XMLCharRefReplaceErrors(PyObject *exc);
/* replace the unicode encode error with backslash escapes (\x, \u and \U) */
PyAPI_FUNC(PyObject *) PyCodec_BackslashReplaceErrors(PyObject *exc);
#ifdef __cplusplus
}
#endif
#endif /* !Py_CODECREGISTRY_H */

40
python/include/compile.h Normal file
View File

@@ -0,0 +1,40 @@
#ifndef Py_COMPILE_H
#define Py_COMPILE_H
#include "code.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Public interface */
struct _node; /* Declare the existence of this type */
PyAPI_FUNC(PyCodeObject *) PyNode_Compile(struct _node *, const char *);
/* Future feature support */
typedef struct {
int ff_features; /* flags set by future statements */
int ff_lineno; /* line number of last future statement */
} PyFutureFeatures;
#define FUTURE_NESTED_SCOPES "nested_scopes"
#define FUTURE_GENERATORS "generators"
#define FUTURE_DIVISION "division"
#define FUTURE_ABSOLUTE_IMPORT "absolute_import"
#define FUTURE_WITH_STATEMENT "with_statement"
#define FUTURE_PRINT_FUNCTION "print_function"
#define FUTURE_UNICODE_LITERALS "unicode_literals"
struct _mod; /* Declare the existence of this type */
PyAPI_FUNC(PyCodeObject *) PyAST_Compile(struct _mod *, const char *,
PyCompilerFlags *, PyArena *);
PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromAST(struct _mod *, const char *);
#ifdef __cplusplus
}
#endif
#endif /* !Py_COMPILE_H */

View File

@@ -0,0 +1,66 @@
/* Complex number structure */
#ifndef Py_COMPLEXOBJECT_H
#define Py_COMPLEXOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
double real;
double imag;
} Py_complex;
/* Operations on complex numbers from complexmodule.c */
#define c_sum _Py_c_sum
#define c_diff _Py_c_diff
#define c_neg _Py_c_neg
#define c_prod _Py_c_prod
#define c_quot _Py_c_quot
#define c_pow _Py_c_pow
#define c_abs _Py_c_abs
PyAPI_FUNC(Py_complex) c_sum(Py_complex, Py_complex);
PyAPI_FUNC(Py_complex) c_diff(Py_complex, Py_complex);
PyAPI_FUNC(Py_complex) c_neg(Py_complex);
PyAPI_FUNC(Py_complex) c_prod(Py_complex, Py_complex);
PyAPI_FUNC(Py_complex) c_quot(Py_complex, Py_complex);
PyAPI_FUNC(Py_complex) c_pow(Py_complex, Py_complex);
PyAPI_FUNC(double) c_abs(Py_complex);
/* Complex object interface */
/*
PyComplexObject represents a complex number with double-precision
real and imaginary parts.
*/
typedef struct {
PyObject_HEAD
Py_complex cval;
} PyComplexObject;
PyAPI_DATA(PyTypeObject) PyComplex_Type;
#define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type)
#define PyComplex_CheckExact(op) (Py_TYPE(op) == &PyComplex_Type)
PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex);
PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag);
PyAPI_FUNC(double) PyComplex_RealAsDouble(PyObject *op);
PyAPI_FUNC(double) PyComplex_ImagAsDouble(PyObject *op);
PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op);
/* Format the object based on the format_spec, as defined in PEP 3101
(Advanced String Formatting). */
PyAPI_FUNC(PyObject *) _PyComplex_FormatAdvanced(PyObject *obj,
char *format_spec,
Py_ssize_t format_spec_len);
#ifdef __cplusplus
}
#endif
#endif /* !Py_COMPLEXOBJECT_H */

239
python/include/datetime.h Normal file
View File

@@ -0,0 +1,239 @@
/* datetime.h
*/
#ifndef DATETIME_H
#define DATETIME_H
#ifdef __cplusplus
extern "C" {
#endif
/* Fields are packed into successive bytes, each viewed as unsigned and
* big-endian, unless otherwise noted:
*
* byte offset
* 0 year 2 bytes, 1-9999
* 2 month 1 byte, 1-12
* 3 day 1 byte, 1-31
* 4 hour 1 byte, 0-23
* 5 minute 1 byte, 0-59
* 6 second 1 byte, 0-59
* 7 usecond 3 bytes, 0-999999
* 10
*/
/* # of bytes for year, month, and day. */
#define _PyDateTime_DATE_DATASIZE 4
/* # of bytes for hour, minute, second, and usecond. */
#define _PyDateTime_TIME_DATASIZE 6
/* # of bytes for year, month, day, hour, minute, second, and usecond. */
#define _PyDateTime_DATETIME_DATASIZE 10
typedef struct
{
PyObject_HEAD
long hashcode; /* -1 when unknown */
int days; /* -MAX_DELTA_DAYS <= days <= MAX_DELTA_DAYS */
int seconds; /* 0 <= seconds < 24*3600 is invariant */
int microseconds; /* 0 <= microseconds < 1000000 is invariant */
} PyDateTime_Delta;
typedef struct
{
PyObject_HEAD /* a pure abstract base clase */
} PyDateTime_TZInfo;
/* The datetime and time types have hashcodes, and an optional tzinfo member,
* present if and only if hastzinfo is true.
*/
#define _PyTZINFO_HEAD \
PyObject_HEAD \
long hashcode; \
char hastzinfo; /* boolean flag */
/* No _PyDateTime_BaseTZInfo is allocated; it's just to have something
* convenient to cast to, when getting at the hastzinfo member of objects
* starting with _PyTZINFO_HEAD.
*/
typedef struct
{
_PyTZINFO_HEAD
} _PyDateTime_BaseTZInfo;
/* All time objects are of PyDateTime_TimeType, but that can be allocated
* in two ways, with or without a tzinfo member. Without is the same as
* tzinfo == None, but consumes less memory. _PyDateTime_BaseTime is an
* internal struct used to allocate the right amount of space for the
* "without" case.
*/
#define _PyDateTime_TIMEHEAD \
_PyTZINFO_HEAD \
unsigned char data[_PyDateTime_TIME_DATASIZE];
typedef struct
{
_PyDateTime_TIMEHEAD
} _PyDateTime_BaseTime; /* hastzinfo false */
typedef struct
{
_PyDateTime_TIMEHEAD
PyObject *tzinfo;
} PyDateTime_Time; /* hastzinfo true */
/* All datetime objects are of PyDateTime_DateTimeType, but that can be
* allocated in two ways too, just like for time objects above. In addition,
* the plain date type is a base class for datetime, so it must also have
* a hastzinfo member (although it's unused there).
*/
typedef struct
{
_PyTZINFO_HEAD
unsigned char data[_PyDateTime_DATE_DATASIZE];
} PyDateTime_Date;
#define _PyDateTime_DATETIMEHEAD \
_PyTZINFO_HEAD \
unsigned char data[_PyDateTime_DATETIME_DATASIZE];
typedef struct
{
_PyDateTime_DATETIMEHEAD
} _PyDateTime_BaseDateTime; /* hastzinfo false */
typedef struct
{
_PyDateTime_DATETIMEHEAD
PyObject *tzinfo;
} PyDateTime_DateTime; /* hastzinfo true */
/* Apply for date and datetime instances. */
#define PyDateTime_GET_YEAR(o) ((((PyDateTime_Date*)o)->data[0] << 8) | \
((PyDateTime_Date*)o)->data[1])
#define PyDateTime_GET_MONTH(o) (((PyDateTime_Date*)o)->data[2])
#define PyDateTime_GET_DAY(o) (((PyDateTime_Date*)o)->data[3])
#define PyDateTime_DATE_GET_HOUR(o) (((PyDateTime_DateTime*)o)->data[4])
#define PyDateTime_DATE_GET_MINUTE(o) (((PyDateTime_DateTime*)o)->data[5])
#define PyDateTime_DATE_GET_SECOND(o) (((PyDateTime_DateTime*)o)->data[6])
#define PyDateTime_DATE_GET_MICROSECOND(o) \
((((PyDateTime_DateTime*)o)->data[7] << 16) | \
(((PyDateTime_DateTime*)o)->data[8] << 8) | \
((PyDateTime_DateTime*)o)->data[9])
/* Apply for time instances. */
#define PyDateTime_TIME_GET_HOUR(o) (((PyDateTime_Time*)o)->data[0])
#define PyDateTime_TIME_GET_MINUTE(o) (((PyDateTime_Time*)o)->data[1])
#define PyDateTime_TIME_GET_SECOND(o) (((PyDateTime_Time*)o)->data[2])
#define PyDateTime_TIME_GET_MICROSECOND(o) \
((((PyDateTime_Time*)o)->data[3] << 16) | \
(((PyDateTime_Time*)o)->data[4] << 8) | \
((PyDateTime_Time*)o)->data[5])
/* Define structure for C API. */
typedef struct {
/* type objects */
PyTypeObject *DateType;
PyTypeObject *DateTimeType;
PyTypeObject *TimeType;
PyTypeObject *DeltaType;
PyTypeObject *TZInfoType;
/* constructors */
PyObject *(*Date_FromDate)(int, int, int, PyTypeObject*);
PyObject *(*DateTime_FromDateAndTime)(int, int, int, int, int, int, int,
PyObject*, PyTypeObject*);
PyObject *(*Time_FromTime)(int, int, int, int, PyObject*, PyTypeObject*);
PyObject *(*Delta_FromDelta)(int, int, int, int, PyTypeObject*);
/* constructors for the DB API */
PyObject *(*DateTime_FromTimestamp)(PyObject*, PyObject*, PyObject*);
PyObject *(*Date_FromTimestamp)(PyObject*, PyObject*);
} PyDateTime_CAPI;
#define PyDateTime_CAPSULE_NAME "datetime.datetime_CAPI"
/* "magic" constant used to partially protect against developer mistakes. */
#define DATETIME_API_MAGIC 0x414548d5
#ifdef Py_BUILD_CORE
/* Macros for type checking when building the Python core. */
#define PyDate_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateType)
#define PyDate_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DateType)
#define PyDateTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateTimeType)
#define PyDateTime_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DateTimeType)
#define PyTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_TimeType)
#define PyTime_CheckExact(op) (Py_TYPE(op) == &PyDateTime_TimeType)
#define PyDelta_Check(op) PyObject_TypeCheck(op, &PyDateTime_DeltaType)
#define PyDelta_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DeltaType)
#define PyTZInfo_Check(op) PyObject_TypeCheck(op, &PyDateTime_TZInfoType)
#define PyTZInfo_CheckExact(op) (Py_TYPE(op) == &PyDateTime_TZInfoType)
#else
/* Define global variable for the C API and a macro for setting it. */
static PyDateTime_CAPI *PyDateTimeAPI = NULL;
#define PyDateTime_IMPORT \
PyDateTimeAPI = (PyDateTime_CAPI *)PyCapsule_Import(PyDateTime_CAPSULE_NAME, 0)
/* Macros for type checking when not building the Python core. */
#define PyDate_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateType)
#define PyDate_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DateType)
#define PyDateTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateTimeType)
#define PyDateTime_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DateTimeType)
#define PyTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TimeType)
#define PyTime_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->TimeType)
#define PyDelta_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DeltaType)
#define PyDelta_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DeltaType)
#define PyTZInfo_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TZInfoType)
#define PyTZInfo_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->TZInfoType)
/* Macros for accessing constructors in a simplified fashion. */
#define PyDate_FromDate(year, month, day) \
PyDateTimeAPI->Date_FromDate(year, month, day, PyDateTimeAPI->DateType)
#define PyDateTime_FromDateAndTime(year, month, day, hour, min, sec, usec) \
PyDateTimeAPI->DateTime_FromDateAndTime(year, month, day, hour, \
min, sec, usec, Py_None, PyDateTimeAPI->DateTimeType)
#define PyTime_FromTime(hour, minute, second, usecond) \
PyDateTimeAPI->Time_FromTime(hour, minute, second, usecond, \
Py_None, PyDateTimeAPI->TimeType)
#define PyDelta_FromDSU(days, seconds, useconds) \
PyDateTimeAPI->Delta_FromDelta(days, seconds, useconds, 1, \
PyDateTimeAPI->DeltaType)
/* Macros supporting the DB API. */
#define PyDateTime_FromTimestamp(args) \
PyDateTimeAPI->DateTime_FromTimestamp( \
(PyObject*) (PyDateTimeAPI->DateTimeType), args, NULL)
#define PyDate_FromTimestamp(args) \
PyDateTimeAPI->Date_FromTimestamp( \
(PyObject*) (PyDateTimeAPI->DateType), args)
#endif /* Py_BUILD_CORE */
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,94 @@
/* Descriptors */
#ifndef Py_DESCROBJECT_H
#define Py_DESCROBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
typedef PyObject *(*getter)(PyObject *, void *);
typedef int (*setter)(PyObject *, PyObject *, void *);
typedef struct PyGetSetDef {
char *name;
getter get;
setter set;
char *doc;
void *closure;
} PyGetSetDef;
typedef PyObject *(*wrapperfunc)(PyObject *self, PyObject *args,
void *wrapped);
typedef PyObject *(*wrapperfunc_kwds)(PyObject *self, PyObject *args,
void *wrapped, PyObject *kwds);
struct wrapperbase {
char *name;
int offset;
void *function;
wrapperfunc wrapper;
char *doc;
int flags;
PyObject *name_strobj;
};
/* Flags for above struct */
#define PyWrapperFlag_KEYWORDS 1 /* wrapper function takes keyword args */
/* Various kinds of descriptor objects */
#define PyDescr_COMMON \
PyObject_HEAD \
PyTypeObject *d_type; \
PyObject *d_name
typedef struct {
PyDescr_COMMON;
} PyDescrObject;
typedef struct {
PyDescr_COMMON;
PyMethodDef *d_method;
} PyMethodDescrObject;
typedef struct {
PyDescr_COMMON;
struct PyMemberDef *d_member;
} PyMemberDescrObject;
typedef struct {
PyDescr_COMMON;
PyGetSetDef *d_getset;
} PyGetSetDescrObject;
typedef struct {
PyDescr_COMMON;
struct wrapperbase *d_base;
void *d_wrapped; /* This can be any function pointer */
} PyWrapperDescrObject;
PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type;
PyAPI_DATA(PyTypeObject) PyDictProxy_Type;
PyAPI_DATA(PyTypeObject) PyGetSetDescr_Type;
PyAPI_DATA(PyTypeObject) PyMemberDescr_Type;
PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *);
PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *);
PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *,
struct PyMemberDef *);
PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *,
struct PyGetSetDef *);
PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *,
struct wrapperbase *, void *);
#define PyDescr_IsData(d) (Py_TYPE(d)->tp_descr_set != NULL)
PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *);
PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *);
PyAPI_DATA(PyTypeObject) PyProperty_Type;
#ifdef __cplusplus
}
#endif
#endif /* !Py_DESCROBJECT_H */

156
python/include/dictobject.h Normal file
View File

@@ -0,0 +1,156 @@
#ifndef Py_DICTOBJECT_H
#define Py_DICTOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
/* Dictionary object type -- mapping from hashable object to object */
/* The distribution includes a separate file, Objects/dictnotes.txt,
describing explorations into dictionary design and optimization.
It covers typical dictionary use patterns, the parameters for
tuning dictionaries, and several ideas for possible optimizations.
*/
/*
There are three kinds of slots in the table:
1. Unused. me_key == me_value == NULL
Does not hold an active (key, value) pair now and never did. Unused can
transition to Active upon key insertion. This is the only case in which
me_key is NULL, and is each slot's initial state.
2. Active. me_key != NULL and me_key != dummy and me_value != NULL
Holds an active (key, value) pair. Active can transition to Dummy upon
key deletion. This is the only case in which me_value != NULL.
3. Dummy. me_key == dummy and me_value == NULL
Previously held an active (key, value) pair, but that was deleted and an
active pair has not yet overwritten the slot. Dummy can transition to
Active upon key insertion. Dummy slots cannot be made Unused again
(cannot have me_key set to NULL), else the probe sequence in case of
collision would have no way to know they were once active.
Note: .popitem() abuses the me_hash field of an Unused or Dummy slot to
hold a search finger. The me_hash field of Unused or Dummy slots has no
meaning otherwise.
*/
/* PyDict_MINSIZE is the minimum size of a dictionary. This many slots are
* allocated directly in the dict object (in the ma_smalltable member).
* It must be a power of 2, and at least 4. 8 allows dicts with no more
* than 5 active entries to live in ma_smalltable (and so avoid an
* additional malloc); instrumentation suggested this suffices for the
* majority of dicts (consisting mostly of usually-small instance dicts and
* usually-small dicts created to pass keyword arguments).
*/
#define PyDict_MINSIZE 8
typedef struct {
/* Cached hash code of me_key. Note that hash codes are C longs.
* We have to use Py_ssize_t instead because dict_popitem() abuses
* me_hash to hold a search finger.
*/
Py_ssize_t me_hash;
PyObject *me_key;
PyObject *me_value;
} PyDictEntry;
/*
To ensure the lookup algorithm terminates, there must be at least one Unused
slot (NULL key) in the table.
The value ma_fill is the number of non-NULL keys (sum of Active and Dummy);
ma_used is the number of non-NULL, non-dummy keys (== the number of non-NULL
values == the number of Active items).
To avoid slowing down lookups on a near-full table, we resize the table when
it's two-thirds full.
*/
typedef struct _dictobject PyDictObject;
struct _dictobject {
PyObject_HEAD
Py_ssize_t ma_fill; /* # Active + # Dummy */
Py_ssize_t ma_used; /* # Active */
/* The table contains ma_mask + 1 slots, and that's a power of 2.
* We store the mask instead of the size because the mask is more
* frequently needed.
*/
Py_ssize_t ma_mask;
/* ma_table points to ma_smalltable for small tables, else to
* additional malloc'ed memory. ma_table is never NULL! This rule
* saves repeated runtime null-tests in the workhorse getitem and
* setitem calls.
*/
PyDictEntry *ma_table;
PyDictEntry *(*ma_lookup)(PyDictObject *mp, PyObject *key, long hash);
PyDictEntry ma_smalltable[PyDict_MINSIZE];
};
PyAPI_DATA(PyTypeObject) PyDict_Type;
PyAPI_DATA(PyTypeObject) PyDictIterKey_Type;
PyAPI_DATA(PyTypeObject) PyDictIterValue_Type;
PyAPI_DATA(PyTypeObject) PyDictIterItem_Type;
PyAPI_DATA(PyTypeObject) PyDictKeys_Type;
PyAPI_DATA(PyTypeObject) PyDictItems_Type;
PyAPI_DATA(PyTypeObject) PyDictValues_Type;
#define PyDict_Check(op) \
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_DICT_SUBCLASS)
#define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
#define PyDictKeys_Check(op) (Py_TYPE(op) == &PyDictKeys_Type)
#define PyDictItems_Check(op) (Py_TYPE(op) == &PyDictItems_Type)
#define PyDictValues_Check(op) (Py_TYPE(op) == &PyDictValues_Type)
/* This excludes Values, since they are not sets. */
# define PyDictViewSet_Check(op) \
(PyDictKeys_Check(op) || PyDictItems_Check(op))
PyAPI_FUNC(PyObject *) PyDict_New(void);
PyAPI_FUNC(PyObject *) PyDict_GetItem(PyObject *mp, PyObject *key);
PyAPI_FUNC(int) PyDict_SetItem(PyObject *mp, PyObject *key, PyObject *item);
PyAPI_FUNC(int) PyDict_DelItem(PyObject *mp, PyObject *key);
PyAPI_FUNC(void) PyDict_Clear(PyObject *mp);
PyAPI_FUNC(int) PyDict_Next(
PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value);
PyAPI_FUNC(int) _PyDict_Next(
PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, long *hash);
PyAPI_FUNC(PyObject *) PyDict_Keys(PyObject *mp);
PyAPI_FUNC(PyObject *) PyDict_Values(PyObject *mp);
PyAPI_FUNC(PyObject *) PyDict_Items(PyObject *mp);
PyAPI_FUNC(Py_ssize_t) PyDict_Size(PyObject *mp);
PyAPI_FUNC(PyObject *) PyDict_Copy(PyObject *mp);
PyAPI_FUNC(int) PyDict_Contains(PyObject *mp, PyObject *key);
PyAPI_FUNC(int) _PyDict_Contains(PyObject *mp, PyObject *key, long hash);
PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused);
PyAPI_FUNC(void) _PyDict_MaybeUntrack(PyObject *mp);
/* PyDict_Update(mp, other) is equivalent to PyDict_Merge(mp, other, 1). */
PyAPI_FUNC(int) PyDict_Update(PyObject *mp, PyObject *other);
/* PyDict_Merge updates/merges from a mapping object (an object that
supports PyMapping_Keys() and PyObject_GetItem()). If override is true,
the last occurrence of a key wins, else the first. The Python
dict.update(other) is equivalent to PyDict_Merge(dict, other, 1).
*/
PyAPI_FUNC(int) PyDict_Merge(PyObject *mp,
PyObject *other,
int override);
/* PyDict_MergeFromSeq2 updates/merges from an iterable object producing
iterable objects of length 2. If override is true, the last occurrence
of a key wins, else the first. The Python dict constructor dict(seq2)
is equivalent to dict={}; PyDict_MergeFromSeq(dict, seq2, 1).
*/
PyAPI_FUNC(int) PyDict_MergeFromSeq2(PyObject *d,
PyObject *seq2,
int override);
PyAPI_FUNC(PyObject *) PyDict_GetItemString(PyObject *dp, const char *key);
PyAPI_FUNC(int) PyDict_SetItemString(PyObject *dp, const char *key, PyObject *item);
PyAPI_FUNC(int) PyDict_DelItemString(PyObject *dp, const char *key);
#ifdef __cplusplus
}
#endif
#endif /* !Py_DICTOBJECT_H */

15
python/include/dtoa.h Normal file
View File

@@ -0,0 +1,15 @@
#ifndef PY_NO_SHORT_FLOAT_REPR
#ifdef __cplusplus
extern "C" {
#endif
PyAPI_FUNC(double) _Py_dg_strtod(const char *str, char **ptr);
PyAPI_FUNC(char *) _Py_dg_dtoa(double d, int mode, int ndigits,
int *decpt, int *sign, char **rve);
PyAPI_FUNC(void) _Py_dg_freedtoa(char *s);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,17 @@
#ifndef Py_ENUMOBJECT_H
#define Py_ENUMOBJECT_H
/* Enumerate Object */
#ifdef __cplusplus
extern "C" {
#endif
PyAPI_DATA(PyTypeObject) PyEnum_Type;
PyAPI_DATA(PyTypeObject) PyReversed_Type;
#ifdef __cplusplus
}
#endif
#endif /* !Py_ENUMOBJECT_H */

36
python/include/errcode.h Normal file
View File

@@ -0,0 +1,36 @@
#ifndef Py_ERRCODE_H
#define Py_ERRCODE_H
#ifdef __cplusplus
extern "C" {
#endif
/* Error codes passed around between file input, tokenizer, parser and
interpreter. This is necessary so we can turn them into Python
exceptions at a higher level. Note that some errors have a
slightly different meaning when passed from the tokenizer to the
parser than when passed from the parser to the interpreter; e.g.
the parser only returns E_EOF when it hits EOF immediately, and it
never returns E_OK. */
#define E_OK 10 /* No error */
#define E_EOF 11 /* End Of File */
#define E_INTR 12 /* Interrupted */
#define E_TOKEN 13 /* Bad token */
#define E_SYNTAX 14 /* Syntax error */
#define E_NOMEM 15 /* Ran out of memory */
#define E_DONE 16 /* Parsing complete */
#define E_ERROR 17 /* Execution error */
#define E_TABSPACE 18 /* Inconsistent mixing of tabs and spaces */
#define E_OVERFLOW 19 /* Node had too many children */
#define E_TOODEEP 20 /* Too many indentation levels */
#define E_DEDENT 21 /* No matching outer block for dedent */
#define E_DECODE 22 /* Error in decoding into Unicode */
#define E_EOFS 23 /* EOF in triple-quoted string */
#define E_EOLS 24 /* EOL in single-quoted string */
#define E_LINECONT 25 /* Unexpected characters after a line continuation */
#ifdef __cplusplus
}
#endif
#endif /* !Py_ERRCODE_H */

25
python/include/eval.h Normal file
View File

@@ -0,0 +1,25 @@
/* Interface to execute compiled code */
#ifndef Py_EVAL_H
#define Py_EVAL_H
#ifdef __cplusplus
extern "C" {
#endif
PyAPI_FUNC(PyObject *) PyEval_EvalCode(PyCodeObject *, PyObject *, PyObject *);
PyAPI_FUNC(PyObject *) PyEval_EvalCodeEx(PyCodeObject *co,
PyObject *globals,
PyObject *locals,
PyObject **args, int argc,
PyObject **kwds, int kwdc,
PyObject **defs, int defc,
PyObject *closure);
PyAPI_FUNC(PyObject *) _PyEval_CallTracing(PyObject *func, PyObject *args);
#ifdef __cplusplus
}
#endif
#endif /* !Py_EVAL_H */

Some files were not shown because too many files have changed in this diff Show More