Add Global Project

Fix Particle Crashes
This commit is contained in:
Phillip Stephens 2016-04-02 01:42:00 -07:00
parent 32b4815ab5
commit dc978a4c79
7 changed files with 28 additions and 5 deletions

View File

@ -7,5 +7,6 @@ namespace DataSpec
logvisor::Module LogDNACommon("urde::DNACommon");
SpecBase* g_curSpec = nullptr;
PAKRouterBase* g_PakRouter = nullptr;
hecl::Database::Project* UniqueIDBridge::s_Project = nullptr;
}

View File

@ -83,24 +83,34 @@ class UniqueIDBridge
{
friend class UniqueID32;
friend class UniqueID64;
static hecl::Database::Project* s_Project;
public:
template <class IDType>
static hecl::ProjectPath TranslatePakIdToPath(const IDType& id)
{
if (!g_PakRouter)
LogDNACommon.report(logvisor::Fatal,
"UniqueIDBridge::setPakRouter must be called before translatePakIdToPath");
"g_Project must be set to non-null before calling UniqueIDBridge::TranslatePakIdToPath");
return g_PakRouter->getWorking(id);
}
static hecl::ProjectPath MakePathFromString(const std::string& str)
{
return hecl::ProjectPath(g_PakRouter->getProject(), str);
if (!s_Project)
LogDNACommon.report(logvisor::Fatal,
"UniqueIDBridge::setGlobalProject must be called before MakePathFromString");
return hecl::ProjectPath(*s_Project, str);
}
template <class IDType>
static void TransformOldHashToNewHash(IDType& id)
{
id = TranslatePakIdToPath(id);
}
static void setGlobalProject(hecl::Database::Project& project)
{
s_Project = &project;
}
};
/** PAK 32-bit Unique ID */

View File

@ -35,7 +35,10 @@ static const hecl::SystemChar* MomErr[] =
constexpr uint32_t MomErrCount = std::extent<decltype(MomErr)>::value;
SpecBase::SpecBase(const hecl::Database::DataSpecEntry* specEntry, hecl::Database::Project& project, bool pc)
: hecl::Database::IDataSpec(specEntry), m_project(project), m_pc(pc),
m_masterShader(project.getProjectWorkingPath(), ".hecl/RetroMasterShader.blend") {}
m_masterShader(project.getProjectWorkingPath(), ".hecl/RetroMasterShader.blend")
{
DataSpec::UniqueIDBridge::setGlobalProject(m_project);
}
bool SpecBase::canExtract(const ExtractPassInfo& info, std::vector<ExtractReport>& reps)
{

View File

@ -25,6 +25,7 @@ void ViewManager::BuildTestPART(urde::IObjectStore& objStore)
//m_partGenDesc = objStore.GetObj({hecl::FOURCC('PART'), 0x972A5CD2});
m_partGenDesc = objStore.GetObj("BusterSparks");
m_partGenDesc.Lock();
m_partGen.reset(new urde::CElementGen(m_partGenDesc,
urde::CElementGen::EModelOrientationType::Normal,
urde::CElementGen::EOptionalSystemFlags::None));

View File

@ -278,6 +278,11 @@ CElementGen::CElementGen(const TToken<CGenDescription>& gen,
{
CGenDescription* desc = x1c_genDesc.GetObj();
if (desc->x54_x40_TEXR)
desc->x54_x40_TEXR->GetValueTexture(0).GetObj();
if (desc->x58_x44_TIND)
desc->x58_x44_TIND->GetValueTexture(0).GetObj();
CIntElement* seedElem = desc->x1c_x10_SEED.get();
if (seedElem)
{

View File

@ -1118,7 +1118,7 @@ bool CParticleDataFactory::CreateGPSM(CGenDescription* fillDesc, CInputStream& i
}
/* Now for our custom additions, if available */
if (!in.atEnd())
if (!in.atEnd() && (in.position() + 4) < in.length())
{
clsId = GetClassID(in);
if (clsId == 0xFFFFFFFF)

View File

@ -30,7 +30,10 @@ struct CUVEConstant : public CUVElement
TLockedToken<CTexture> x4_tex;
public:
CUVEConstant(TToken<CTexture>&& tex)
: x4_tex(std::move(tex)) {}
: x4_tex(std::move(tex))
{
}
TLockedToken<CTexture> GetValueTexture(int frame) const
{
return TLockedToken<CTexture>(x4_tex);