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

build 170524. re-enabled support for -e3d command line option

This commit is contained in:
tmj-fstate
2017-05-23 23:57:29 +02:00
parent 9f07e2b504
commit 03e231fbc1
7 changed files with 138 additions and 104 deletions

View File

@@ -383,9 +383,15 @@ int main(int argc, char *argv[])
input::Gamepad.init(); input::Gamepad.init();
Global::pWorld = &World; // Ra: wskaźnik potrzebny do usuwania pojazdów Global::pWorld = &World; // Ra: wskaźnik potrzebny do usuwania pojazdów
if (!World.Init(window)) try {
{ if( false == World.Init( window ) ) {
ErrorLog( "Failed to init TWorld" ); ErrorLog( "Failed to init TWorld" );
return -1;
}
}
catch( std::bad_alloc const &Error ) {
ErrorLog( "Critical error, memory allocation failure: " + std::string( Error.what() ) );
return -1; return -1;
} }
@@ -406,15 +412,23 @@ int main(int argc, char *argv[])
} // po zrobieniu E3D odpalamy normalnie scenerię, by ją zobaczyć } // po zrobieniu E3D odpalamy normalnie scenerię, by ją zobaczyć
Console::On(); // włączenie konsoli Console::On(); // włączenie konsoli
while (!glfwWindowShouldClose(window)
&& World.Update() try {
&& GfxRenderer.Render()) while( ( false == glfwWindowShouldClose( window ) )
{ && ( true == World.Update() )
glfwPollEvents(); && ( true == GfxRenderer.Render() ) ) {
if( true == Global::InputGamepad ) { glfwPollEvents();
input::Gamepad.poll(); if( true == Global::InputGamepad ) {
input::Gamepad.poll();
}
} }
} }
catch( std::bad_alloc const &Error ) {
ErrorLog( "Critical error, memory allocation failure: " + std::string( Error.what() ) );
return -1;
}
Console::Off(); // wyłączenie konsoli (komunikacji zwrotnej) Console::Off(); // wyłączenie konsoli (komunikacji zwrotnej)
} }

View File

@@ -198,7 +198,7 @@ TTrack * TTrack::Create400m(int what, double dx)
trk->bVisible = false; // nie potrzeba pokazywać, zresztą i tak nie ma tekstur trk->bVisible = false; // nie potrzeba pokazywać, zresztą i tak nie ma tekstur
trk->iCategoryFlag = what; // taki sam typ plus informacja, że dodatkowy trk->iCategoryFlag = what; // taki sam typ plus informacja, że dodatkowy
trk->Init(); // utworzenie segmentu trk->Init(); // utworzenie segmentu
trk->Segment->Init(vector3(-dx, 0, 0), vector3(-dx, 0, 400), 0, 0, 0); // prosty trk->Segment->Init(vector3(-dx, 0, 0), vector3(-dx, 0, 400), 10.0, 0, 0); // prosty
tmp->pCenter = vector3(-dx, 0, 200); //środek, aby się mogło wyświetlić tmp->pCenter = vector3(-dx, 0, 200); //środek, aby się mogło wyświetlić
TSubRect *r = Global::pGround->GetSubRect(tmp->pCenter.x, tmp->pCenter.z); TSubRect *r = Global::pGround->GetSubRect(tmp->pCenter.x, tmp->pCenter.z);
r->NodeAdd(tmp); // dodanie toru do segmentu r->NodeAdd(tmp); // dodanie toru do segmentu

196
World.cpp
View File

@@ -2384,103 +2384,119 @@ void TWorld::ModifyTGA(const std::string &dir)
} }
*/ */
}; };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
std::string last; // zmienne używane w rekurencji
double shift = 0; void TWorld::CreateE3D(std::string const &Path, bool Dynamic)
void TWorld::CreateE3D(std::string const &dir, bool dyn)
{ // rekurencyjna generowanie plików E3D { // rekurencyjna generowanie plików E3D
/* TODO: remove Borland file access stuff std::string last; // zmienne używane w rekurencji
TTrack *trk; TTrack *trk{ nullptr };
double at; double at{ 0.0 };
TSearchRec sr; double shift{ 0.0 };
if (FindFirst(dir + "*.*", faDirectory | faArchive, sr) == 0)
{ #ifdef _WINDOWS
do
{ std::string searchpattern( "*.*" );
if (sr.Name[1] != '.')
if ((sr.Attr & faDirectory)) // jeśli katalog, to rekurencja ::WIN32_FIND_DATA filedata;
CreateE3D(dir + sr.Name + "\\", dyn); ::HANDLE search = ::FindFirstFile( ( Path + searchpattern ).c_str(), &filedata );
else if (dyn)
{ if( search == INVALID_HANDLE_VALUE ) { return; } // if nothing to do, bail out
if (sr.Name.LowerCase().SubString(sr.Name.Length() - 3, 4) == ".mmd")
{ do {
// konwersja pojazdów będzie ułomna, bo nie poustawiają się animacje na
// submodelach określonych w MMD std::string filename = filedata.cFileName;
// TModelsManager::GetModel(AnsiString(dir+sr.Name).c_str(),true);
if (last != dir) if( filedata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) {
{ // utworzenie toru dla danego pojazdu // launch recursive search for sub-directories...
last = dir; if( filename == "." ) { continue; }
trk = TTrack::Create400m(1, shift); if( filename == ".." ) { continue; }
shift += 10.0; // następny tor będzie deczko dalej, aby nie zabić FPS CreateE3D( Path + filename + "\\", Dynamic );
at = 400.0; }
// if (shift>1000) break; //bezpiecznik else {
// process the file
if( filename.size() < 4 ) { continue; }
std::string const filetype = ToLower( filename.substr( filename.size() - 4, 4 ) );
if( filetype == ".mmd" ) {
if( false == Dynamic ) { continue; }
// konwersja pojazdów będzie ułomna, bo nie poustawiają się animacje na submodelach określonych w MMD
if( last != Path ) { // utworzenie toru dla danego pojazdu
last = Path;
trk = TTrack::Create400m( 1, shift );
shift += 10.0; // następny tor będzie deczko dalej, aby nie zabić FPS
at = 400.0;
}
TGroundNode *tmp = new TGroundNode();
tmp->DynamicObject = new TDynamicObject();
at -= tmp->DynamicObject->Init(
"",
Path.substr( 8, Path.size() - 9 ), // skip leading "dynamic/" and trailing slash
"none",
filename.substr( 0, filename.size() - 4 ),
trk,
at,
"nobody", 0.0, "none", 0.0, "", false, "" );
// po wczytaniu CHK zrobić pętlę po ładunkach, aby każdy z nich skonwertować
cParser loadparser( tmp->DynamicObject->MoverParameters->LoadAccepted ); // typy ładunków
std::string loadname;
loadparser.getTokens( 1, true, "," ); loadparser >> loadname;
while( loadname != "" ) {
if( ( true == FileExists( Path + loadname + ".t3d" ) )
&& ( false == FileExists( Path + loadname + ".e3d" ) ) ) {
// a nie ma jeszcze odpowiednika binarnego
at -= tmp->DynamicObject->Init(
"",
Path.substr( 8, Path.size() - 9 ), // skip leading "dynamic/" and trailing slash
"none",
filename.substr( 0, filename.size() - 4 ),
trk,
at,
"nobody", 0.0, "none", 1.0, loadname, false, "" );
} }
TGroundNode *tmp = new TGroundNode();
tmp->DynamicObject = new TDynamicObject(); loadname = "";
// Global::asCurrentTexturePath=dir; //pojazdy mają tekstury we własnych loadparser.getTokens( 1, true, "," ); loadparser >> loadname;
// katalogach }
at -= tmp->DynamicObject->Init(
"", string((dir.SubString(9, dir.Length() - 9)).c_str()), "none", if( tmp->DynamicObject->iCabs ) { // jeśli ma jakąkolwiek kabinę
string(sr.Name.SubString(1, sr.Name.Length() - 4).c_str()), trk, at, "nobody", 0.0, delete Train;
"none", 0.0, "", false, ""); Train = new TTrain();
// po wczytaniu CHK zrobić pętlę po ładunkach, aby każdy z nich skonwertować if( tmp->DynamicObject->iCabs & 1 ) {
AnsiString loads, load; tmp->DynamicObject->MoverParameters->ActiveCab = 1;
loads = AnsiString(tmp->DynamicObject->MoverParameters->LoadAccepted.c_str()); // typy ładunków Train->Init( tmp->DynamicObject, true );
if (!loads.IsEmpty()) }
{ if( tmp->DynamicObject->iCabs & 4 ) {
loads += ","; // przecinek na końcu tmp->DynamicObject->MoverParameters->ActiveCab = -1;
int i = loads.Pos(","); Train->Init( tmp->DynamicObject, true );
while (i > 1) }
{ // wypadało by sprawdzić, czy T3D ładunku jest if( tmp->DynamicObject->iCabs & 2 ) {
load = loads.SubString(1, i - 1); tmp->DynamicObject->MoverParameters->ActiveCab = 0;
if (FileExists(dir + load + ".t3d")) // o ile jest plik ładunku, bo Train->Init( tmp->DynamicObject, true );
// inaczej nie ma to sensu
if (!FileExists(
dir + load +
".e3d")) // a nie ma jeszcze odpowiednika binarnego
at -= tmp->DynamicObject->Init(
"", dir.SubString(9, dir.Length() - 9).c_str(), "none",
sr.Name.SubString(1, sr.Name.Length() - 4).c_str(), trk, at,
"nobody", 0.0, "none", 1.0, load.c_str(), false, "");
loads.Delete(1, i); // usunięcie z następującym przecinkiem
i = loads.Pos(",");
}
}
if (tmp->DynamicObject->iCabs)
{ // jeśli ma jakąkolwiek kabinę
delete Train;
Train = new TTrain();
if (tmp->DynamicObject->iCabs & 1)
{
tmp->DynamicObject->MoverParameters->ActiveCab = 1;
Train->Init(tmp->DynamicObject, true);
}
if (tmp->DynamicObject->iCabs & 4)
{
tmp->DynamicObject->MoverParameters->ActiveCab = -1;
Train->Init(tmp->DynamicObject, true);
}
if (tmp->DynamicObject->iCabs & 2)
{
tmp->DynamicObject->MoverParameters->ActiveCab = 0;
Train->Init(tmp->DynamicObject, true);
}
}
Global::asCurrentTexturePath =
(szTexturePath); // z powrotem defaultowa sciezka do tekstur
} }
} }
else if (sr.Name.LowerCase().SubString(sr.Name.Length() - 3, 4) == ".t3d") // z powrotem defaultowa sciezka do tekstur
{ // z modelami jest prościej Global::asCurrentTexturePath = ( szTexturePath );
Global::asCurrentTexturePath = dir.c_str(); }
TModelsManager::GetModel(AnsiString(dir + sr.Name).c_str(), false); else if( filetype == ".t3d" ) {
} // z modelami jest prościej
} while (FindNext(sr) == 0); Global::asCurrentTexturePath = Path;
FindClose(sr); TModelsManager::GetModel( Path + filename, false );
} }
*/ }
} while( ::FindNextFile( search, &filedata ) );
// all done, clean up
::FindClose( search );
#endif
}; };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void TWorld::CabChange(TDynamicObject *old, TDynamicObject *now) void TWorld::CabChange(TDynamicObject *old, TDynamicObject *now)
{ // ewentualna zmiana kabiny użytkownikowi { // ewentualna zmiana kabiny użytkownikowi

View File

@@ -3,6 +3,8 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerWorkingDirectory>..\..\..\development\maszyna</LocalDebuggerWorkingDirectory> <LocalDebuggerWorkingDirectory>..\..\..\development\maszyna</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommandArguments>
</LocalDebuggerCommandArguments>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerWorkingDirectory>..\..\Projects\maszyna</LocalDebuggerWorkingDirectory> <LocalDebuggerWorkingDirectory>..\..\Projects\maszyna</LocalDebuggerWorkingDirectory>

View File

@@ -1,5 +1,5 @@
#pragma once #pragma once
#define VERSION_MAJOR 17 #define VERSION_MAJOR 17
#define VERSION_MINOR 522 #define VERSION_MINOR 524
#define VERSION_REVISION 0 #define VERSION_REVISION 0

View File

@@ -257,6 +257,8 @@ HRESULT CWaveSoundRead::Read(UINT nSizeToRead, BYTE *pbData, UINT *pnSizeRead)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
HRESULT CWaveSoundRead::Close() HRESULT CWaveSoundRead::Close()
{ {
mmioClose(m_hmmioIn, 0); if( m_hmmioIn != NULL ) {
mmioClose( m_hmmioIn, 0 );
}
return S_OK; return S_OK;
} }

View File

@@ -33,7 +33,7 @@ class CWaveSoundRead
{ {
public: public:
WAVEFORMATEX *m_pwfx; // Pointer to WAVEFORMATEX structure WAVEFORMATEX *m_pwfx; // Pointer to WAVEFORMATEX structure
HMMIO m_hmmioIn; // MM I/O handle for the WAVE HMMIO m_hmmioIn{ NULL }; // MM I/O handle for the WAVE
MMCKINFO m_ckIn; // Multimedia RIFF chunk MMCKINFO m_ckIn; // Multimedia RIFF chunk
MMCKINFO m_ckInRiff; // Use in opening a WAVE file MMCKINFO m_ckInRiff; // Use in opening a WAVE file