From eb4b3404aa00220d659e532151dab13d642c17a3 Mon Sep 17 00:00:00 2001 From: Svxy Date: Wed, 31 May 2023 17:31:32 -0400 Subject: Released --- tools/DSGmaker/DSGList.cpp | 389 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 389 insertions(+) create mode 100644 tools/DSGmaker/DSGList.cpp (limited to 'tools/DSGmaker/DSGList.cpp') diff --git a/tools/DSGmaker/DSGList.cpp b/tools/DSGmaker/DSGList.cpp new file mode 100644 index 0000000..700497f --- /dev/null +++ b/tools/DSGmaker/DSGList.cpp @@ -0,0 +1,389 @@ +#include +#include +#include <..\..\..\tools\dsgmaker\DSGList.hpp> +#include +#include <..\constants\srrchunks.h> + + +const int MAX_DSG = 100; + +DSGList::DSGList () +{ + mbNoInstanceChunks = false; + mindex =0; + mp_list = new tlDataChunk* [MAX_DSG]; + mp_list[0]=NULL; +} + +DSGList::~DSGList () +{ + delete [] mp_list; +} + +//input DynaDSG name and it should return a pointer to the dsg or null if failure +tlDataChunk* DSGList::GetDSG(const char * name) +{ + + //search the array for the name. + for(unsigned int i=0;iGetName()); + //if we find it return pointer otherwise it will return null by default + if (strcmp ( mp_list[i]->GetName(),name)==0) + { + return( mp_list[i] ); + } + } + return NULL; + +} + +// add a dynaphyschunk to the list +int DSGList::AddDSG (tlDataChunk* p_dsg) +{ + if(mindex < MAX_DSG -1) + { + mp_list[mindex++]=p_dsg; + return 0; + } + else + { + printf(" ERROR: ====> DSGList if FULL! Unable to add entery! \n"); + return 1; + } + +} + + +//returns the number of enteries in list. +unsigned int DSGList::GetIndexCount() +{ + return mindex; +} + +//input index and it should return a pointer to the dsg or null if failure +tlDataChunk* DSGList::GetDSGByIndex(unsigned int i) +{ + + //search the array for the name. + if ( i >=0 && i Sorting DSG! \n"); + } + else + { + p_dsg->SortSubChunks(); + } + } + +} + +//checks the DSG chunks for missing Chunks that will cause the game loaders to crash. +unsigned int DSGList::VerifyChunks(void) +{ + tlDataChunk* p_datachunk=NULL; + bool badart = false; + + printf("\nVerifying Chunks arent missing components....\n"); + + for (unsigned int i=0; iID()) + { + case SRR2::ChunkID::DYNA_PHYS_DSG: + { + tlDataChunk* p_subchunk=NULL; + int subcount=p_datachunk->SubChunkCount(); + + if (subcount<5) + { + bool meshchunk =false; + bool physicschunk=false; + bool collisionchunk= false; + bool otc = false; + bool instancechunk = false; + + + for( int j=0;jGetSubChunk(j); + + switch(p_subchunk->ID()) + { + case Pure3D::Mesh::MESH: + { + meshchunk = true; + break; + } + case Simulation::Physics::OBJECT: + { + physicschunk = true; + break; + } + case SRR2::ChunkID::OBJECT_ATTRIBUTES: + { + otc = true; + break; + } + case Simulation::Collision::OBJECT: + { + collisionchunk = true ; + break; + } + case SRR2::ChunkID::INSTANCES: + { + instancechunk= true; + break; + } + default: + { + printf(" Unexpected ChunkType %d \n",p_subchunk->ID() ); + break; + } + }//end of switch for sub chunk check + }//end of for loop to subchunk iteration + + if (meshchunk != true) + { + badart =true; + DSGList::PrintErrors(); + printf (" ERROR:=====> %-30s DynaDSGChunk is missing MeshChunk\n",p_datachunk->GetName()); + } + + if (physicschunk != true) + { + badart =true; + DSGList::PrintErrors(); + printf (" ERROR:=====> %-30s DynaDSGChunk is missing PhysicsChunk\n",p_datachunk->GetName()); + } + + if(otc != true) + { + badart =true; + DSGList::PrintErrors(); + printf (" ERROR:=====> %-30s DynaDSGChunk is missing Object Attribute Chunk\n",p_datachunk->GetName()); + + } + + if(collisionchunk != true) + { + badart =true; + DSGList::PrintErrors(); + printf (" ERROR:=====> %-30s DynaDSGChunk is missing BoundingVolume\n",p_datachunk->GetName()); + + } + + if( instancechunk != true) + { + if (mbNoInstanceChunks == true) + { + + } + else + { + badart =true; + DSGList::PrintErrors(); + printf (" ERROR:=====> %-30s DynaPhysDSGChunk is missing Instanced Chunk\n",p_datachunk->GetName()); + } + } + }//end if + break; + }//end case + case SRR2::ChunkID::INSTA_STATIC_PHYS_DSG: + { + tlDataChunk* p_subchunk=NULL; + int subcount=p_datachunk->SubChunkCount(); + + if (subcount<4) + { + bool meshchunk =false; + bool collisionchunk= false; + bool otc = false; + bool instancechunk = false; + + for( int j=0;jGetSubChunk(j); + + switch(p_subchunk->ID()) + { + case Pure3D::Mesh::MESH: + { + meshchunk = true; + break; + } + case SRR2::ChunkID::OBJECT_ATTRIBUTES: + { + otc = true; + break; + } + case Simulation::Collision::OBJECT: + { + collisionchunk = true ; + break; + } + case SRR2::ChunkID::INSTANCES: + { + instancechunk= true; + break; + } + default: + { + printf(" Unexpected ChunkType %d \n",p_subchunk->ID() ); + break; + } + }//end of switch for sub chunk check + }//end of for loop to subchunk iteration + + if (meshchunk != true) + { + badart =true; + DSGList::PrintErrors(); + printf (" ERROR:=====> %-30s InstaStaticPhysDSGChunk is missing MeshChunk\n",p_datachunk->GetName()); + } + + if(otc != true) + { + badart =true; + DSGList::PrintErrors(); + printf (" ERROR:=====> %-30s InstaStaticPhysDSGChunk is missing Object Attribute Chunk\n",p_datachunk->GetName()); + + } + + if(collisionchunk != true) + { + badart =true; + DSGList::PrintErrors(); + printf (" ERROR:=====> %-30s InstaStaticPhysDSGChunk is missing Bounding Volume\n",p_datachunk->GetName()); + + } + + if( instancechunk != true) + { + if (mbNoInstanceChunks == true) + { + + } + else + { + badart =true; + DSGList::PrintErrors(); + printf (" ERROR:=====> %-30s InstaStaticPhysDSGChunk is missing Instanced Chunk\n",p_datachunk->GetName()); + } + } + }//end if + break; + }//end of InstaStatPhyscase + + case SRR2::ChunkID::INSTA_ENTITY_DSG: + { + tlDataChunk* p_subchunk=NULL; + int subcount=p_datachunk->SubChunkCount(); + + if (subcount<2) + { + bool meshchunk =false; + bool instancechunk = false; + + + for( int j=0;jGetSubChunk(j); + + switch(p_subchunk->ID()) + { + case Pure3D::Mesh::MESH: + { + meshchunk = true; + break; + } + case SRR2::ChunkID::INSTANCES: + { + instancechunk= true; + break; + } + default: + { + printf(" Unexpected ChunkType %d \n",p_subchunk->ID() ); + break; + } + }//end of switch for sub chunk check + }//end of for loop to subchunk iteration + + if (meshchunk != true) + { + badart =true; + DSGList::PrintErrors(); + printf (" ERROR:=====> %-30s InstaEntityDSGChunk is missing MeshChunk\n",p_datachunk->GetName()); + } + + if( instancechunk != true) + { + if (mbNoInstanceChunks == true) + { + + } + else + { + badart =true; + DSGList::PrintErrors(); + printf (" ERROR:=====> %-30s InstaStaticPhysDSGChunk is missing Instanced Chunk\n",p_datachunk->GetName()); + } + } + }//end if + break; + }//end case + + }//end switch + + }//end for +if (badart == true) +{ + return 1; +} + +return 0; + +}//end of VerifyChunks method + + +// formatted IO Header for errors. +void DSGList::PrintErrors(void) +{ + printf("\n"); + printf("===============================================================================================\n"); + printf("\n"); +} + + + + + + + + + + -- cgit v1.2.3