mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-21 00:09:19 +02:00
minor diagnostics enhancements and null pointer safeguards
This commit is contained in:
20
DynObj.cpp
20
DynObj.cpp
@@ -539,11 +539,10 @@ TDynamicObject::toggle_lights() {
|
||||
SectionLightsActive = false;
|
||||
}
|
||||
else {
|
||||
std::string compartmentname;
|
||||
// set lights with probability depending on the compartment type. TODO: expose this in .mmd file
|
||||
for( auto §ionlight : SectionLightLevels ) {
|
||||
|
||||
compartmentname = sectionlight.compartment->pName;
|
||||
std::string const &compartmentname = sectionlight.compartment->pName;
|
||||
if( ( compartmentname.find( "corridor" ) != std::string::npos )
|
||||
|| ( compartmentname.find( "korytarz" ) != std::string::npos ) ) {
|
||||
// corridors are lit 100% of time
|
||||
@@ -584,8 +583,9 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist)
|
||||
pAnimations[i].yUpdate(pAnimations +
|
||||
i); // aktualizacja animacji (położenia submodeli
|
||||
*/
|
||||
if( ObjSqrDist < 2500 ) // gdy bliżej niż 50m
|
||||
{
|
||||
if( ( mdModel != nullptr )
|
||||
&& ( ObjSqrDist < 2500 ) ) {
|
||||
// gdy bliżej niż 50m
|
||||
// ABu290105: rzucanie pudlem
|
||||
// te animacje wymagają bananów w modelach!
|
||||
mdModel->GetSMRoot()->SetTranslate(modelShake);
|
||||
@@ -4033,12 +4033,17 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
||||
bool Stop_InternalData = false;
|
||||
pants = NULL; // wskaźnik pierwszego obiektu animującego dla pantografów
|
||||
cParser parser( TypeName + ".mmd", cParser::buffer_FILE, BaseDir );
|
||||
if( false == parser.ok() ) {
|
||||
ErrorLog( "Failed to load appearance data for vehicle " + MoverParameters->Name );
|
||||
return;
|
||||
}
|
||||
std::string token;
|
||||
do {
|
||||
token = "";
|
||||
parser.getTokens(); parser >> token;
|
||||
|
||||
if( token == "models:") {
|
||||
if( ( token == "models:" )
|
||||
|| ( token == "models:" ) ) { // crude way to handle utf8 bom potentially appearing before the first token
|
||||
// modele i podmodele
|
||||
m_materialdata.multi_textures = 0; // czy jest wiele tekstur wymiennych?
|
||||
parser.getTokens();
|
||||
@@ -5024,13 +5029,12 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
||||
}
|
||||
|
||||
if (mdModel)
|
||||
mdModel->Init(); // obrócenie modelu oraz optymalizacja, również zapisanie
|
||||
// binarnego
|
||||
mdModel->Init(); // obrócenie modelu oraz optymalizacja, również zapisanie binarnego
|
||||
if (mdLoad)
|
||||
mdLoad->Init();
|
||||
if (mdLowPolyInt)
|
||||
mdLowPolyInt->Init();
|
||||
// sHorn2.CopyIfEmpty(sHorn1); ///żeby jednak trąbił też drugim
|
||||
|
||||
Global::asCurrentTexturePath = szTexturePath; // kiedyś uproszczone wnętrze mieszało tekstury nieba
|
||||
}
|
||||
|
||||
|
||||
@@ -446,7 +446,7 @@ int TSubModel::Load( cParser &parser, TModel3d *Model, /*int Pos,*/ bool dynamic
|
||||
--facecount; // o jeden trójkąt mniej
|
||||
iNumVerts -= 3; // czyli o 3 wierzchołki
|
||||
i -= 3; // wczytanie kolejnego w to miejsce
|
||||
WriteLog("Degenerated triangle ignored in: \"" + pName + "\", vertice " + std::to_string(i));
|
||||
WriteLog("Degenerated triangle ignored in: \"" + pName + "\", vertices " + std::to_string(i) + "-" + std::to_string(i+2));
|
||||
}
|
||||
if (i > 0) {
|
||||
// jeśli pierwszy trójkąt będzie zdegenerowany, to zostanie usunięty i nie ma co sprawdzać
|
||||
|
||||
@@ -50,8 +50,13 @@ cParser::cParser( std::string const &Stream, buffertype const Type, std::string
|
||||
// calculate stream size
|
||||
if (mStream)
|
||||
{
|
||||
mSize = mStream->rdbuf()->pubseekoff(0, std::ios_base::end);
|
||||
mStream->rdbuf()->pubseekoff(0, std::ios_base::beg);
|
||||
if( true == mStream->fail() ) {
|
||||
ErrorLog( "Failed to open file \"" + Path + "\"" );
|
||||
}
|
||||
else {
|
||||
mSize = mStream->rdbuf()->pubseekoff( 0, std::ios_base::end );
|
||||
mStream->rdbuf()->pubseekoff( 0, std::ios_base::beg );
|
||||
}
|
||||
}
|
||||
else
|
||||
mSize = 0;
|
||||
|
||||
@@ -656,7 +656,8 @@ opengl_renderer::Render( TDynamicObject *Dynamic ) {
|
||||
}
|
||||
}
|
||||
|
||||
Render( Dynamic->mdModel, Dynamic->Material(), squaredistance );
|
||||
if( Dynamic->mdModel )
|
||||
Render( Dynamic->mdModel, Dynamic->Material(), squaredistance );
|
||||
|
||||
if( Dynamic->mdLoad ) // renderowanie nieprzezroczystego ładunku
|
||||
Render( Dynamic->mdLoad, Dynamic->Material(), squaredistance );
|
||||
@@ -1101,7 +1102,8 @@ opengl_renderer::Render_Alpha( TDynamicObject *Dynamic ) {
|
||||
}
|
||||
}
|
||||
|
||||
Render_Alpha( Dynamic->mdModel, Dynamic->Material(), squaredistance );
|
||||
if( Dynamic->mdModel )
|
||||
Render_Alpha( Dynamic->mdModel, Dynamic->Material(), squaredistance );
|
||||
|
||||
if( Dynamic->mdLoad ) // renderowanie nieprzezroczystego ładunku
|
||||
Render_Alpha( Dynamic->mdLoad, Dynamic->Material(), squaredistance );
|
||||
|
||||
Reference in New Issue
Block a user