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();
Global::pWorld = &World; // Ra: wskaźnik potrzebny do usuwania pojazdów
if (!World.Init(window))
{
ErrorLog( "Failed to init TWorld" );
try {
if( false == World.Init( window ) ) {
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;
}
@@ -406,15 +412,23 @@ int main(int argc, char *argv[])
} // po zrobieniu E3D odpalamy normalnie scenerię, by ją zobaczyć
Console::On(); // włączenie konsoli
while (!glfwWindowShouldClose(window)
&& World.Update()
&& GfxRenderer.Render())
{
glfwPollEvents();
if( true == Global::InputGamepad ) {
input::Gamepad.poll();
try {
while( ( false == glfwWindowShouldClose( window ) )
&& ( true == World.Update() )
&& ( true == GfxRenderer.Render() ) ) {
glfwPollEvents();
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)
}

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->iCategoryFlag = what; // taki sam typ plus informacja, że dodatkowy
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ć
TSubRect *r = Global::pGround->GetSubRect(tmp->pCenter.x, tmp->pCenter.z);
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 &dir, bool dyn)
void TWorld::CreateE3D(std::string const &Path, bool Dynamic)
{ // rekurencyjna generowanie plików E3D
/* TODO: remove Borland file access stuff
TTrack *trk;
double at;
TSearchRec sr;
if (FindFirst(dir + "*.*", faDirectory | faArchive, sr) == 0)
{
do
{
if (sr.Name[1] != '.')
if ((sr.Attr & faDirectory)) // jeśli katalog, to rekurencja
CreateE3D(dir + sr.Name + "\\", dyn);
else if (dyn)
{
if (sr.Name.LowerCase().SubString(sr.Name.Length() - 3, 4) == ".mmd")
{
// konwersja pojazdów będzie ułomna, bo nie poustawiają się animacje na
// submodelach określonych w MMD
// TModelsManager::GetModel(AnsiString(dir+sr.Name).c_str(),true);
if (last != dir)
{ // utworzenie toru dla danego pojazdu
last = dir;
trk = TTrack::Create400m(1, shift);
shift += 10.0; // następny tor będzie deczko dalej, aby nie zabić FPS
at = 400.0;
// if (shift>1000) break; //bezpiecznik
std::string last; // zmienne używane w rekurencji
TTrack *trk{ nullptr };
double at{ 0.0 };
double shift{ 0.0 };
#ifdef _WINDOWS
std::string searchpattern( "*.*" );
::WIN32_FIND_DATA filedata;
::HANDLE search = ::FindFirstFile( ( Path + searchpattern ).c_str(), &filedata );
if( search == INVALID_HANDLE_VALUE ) { return; } // if nothing to do, bail out
do {
std::string filename = filedata.cFileName;
if( filedata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) {
// launch recursive search for sub-directories...
if( filename == "." ) { continue; }
if( filename == ".." ) { continue; }
CreateE3D( Path + filename + "\\", Dynamic );
}
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();
// Global::asCurrentTexturePath=dir; //pojazdy mają tekstury we własnych
// katalogach
at -= tmp->DynamicObject->Init(
"", string((dir.SubString(9, dir.Length() - 9)).c_str()), "none",
string(sr.Name.SubString(1, sr.Name.Length() - 4).c_str()), trk, at, "nobody", 0.0,
"none", 0.0, "", false, "");
// po wczytaniu CHK zrobić pętlę po ładunkach, aby każdy z nich skonwertować
AnsiString loads, load;
loads = AnsiString(tmp->DynamicObject->MoverParameters->LoadAccepted.c_str()); // typy ładunków
if (!loads.IsEmpty())
{
loads += ","; // przecinek na końcu
int i = loads.Pos(",");
while (i > 1)
{ // 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
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
loadname = "";
loadparser.getTokens( 1, true, "," ); loadparser >> loadname;
}
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 );
}
}
else if (sr.Name.LowerCase().SubString(sr.Name.Length() - 3, 4) == ".t3d")
{ // z modelami jest prościej
Global::asCurrentTexturePath = dir.c_str();
TModelsManager::GetModel(AnsiString(dir + sr.Name).c_str(), false);
}
} while (FindNext(sr) == 0);
FindClose(sr);
}
*/
// z powrotem defaultowa sciezka do tekstur
Global::asCurrentTexturePath = ( szTexturePath );
}
else if( filetype == ".t3d" ) {
// z modelami jest prościej
Global::asCurrentTexturePath = Path;
TModelsManager::GetModel( Path + filename, false );
}
}
} while( ::FindNextFile( search, &filedata ) );
// all done, clean up
::FindClose( search );
#endif
};
//---------------------------------------------------------------------------
void TWorld::CabChange(TDynamicObject *old, TDynamicObject *now)
{ // ewentualna zmiana kabiny użytkownikowi

View File

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

View File

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

View File

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

View File

@@ -33,7 +33,7 @@ class CWaveSoundRead
{
public:
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_ckInRiff; // Use in opening a WAVE file