2016-03-26 00:51:59 +00:00
|
|
|
#include "ProjectResourceFactoryMP1.hpp"
|
|
|
|
#include "Runtime/IOStreams.hpp"
|
|
|
|
|
2016-09-10 04:50:00 +00:00
|
|
|
#include "Runtime/CGameHintInfo.hpp"
|
2016-03-26 00:51:59 +00:00
|
|
|
#include "Runtime/Particle/CParticleDataFactory.hpp"
|
|
|
|
#include "Runtime/Particle/CGenDescription.hpp"
|
|
|
|
#include "Runtime/Particle/CElectricDescription.hpp"
|
|
|
|
#include "Runtime/Particle/CSwooshDescription.hpp"
|
2017-02-13 21:29:00 +00:00
|
|
|
#include "Runtime/Particle/CParticleElectricDataFactory.hpp"
|
|
|
|
#include "Runtime/Particle/CParticleSwooshDataFactory.hpp"
|
|
|
|
#include "Runtime/Particle/CWeaponDescription.hpp"
|
|
|
|
#include "Runtime/Particle/CProjectileWeaponDataFactory.hpp"
|
|
|
|
#include "Runtime/Particle/CDecalDataFactory.hpp"
|
2016-03-26 00:51:59 +00:00
|
|
|
#include "Runtime/GuiSys/CGuiFrame.hpp"
|
|
|
|
#include "Runtime/GuiSys/CRasterFont.hpp"
|
2016-08-17 05:40:25 +00:00
|
|
|
#include "Runtime/GuiSys/CStringTable.hpp"
|
2016-03-26 00:51:59 +00:00
|
|
|
#include "Runtime/Graphics/CModel.hpp"
|
|
|
|
#include "Runtime/Graphics/CTexture.hpp"
|
2016-04-09 23:19:17 +00:00
|
|
|
#include "Runtime/Character/CCharLayoutInfo.hpp"
|
2016-04-12 22:28:08 +00:00
|
|
|
#include "Runtime/Character/CSkinRules.hpp"
|
2016-04-10 21:22:59 +00:00
|
|
|
#include "Runtime/Character/CAnimCharacterSet.hpp"
|
2016-04-12 06:15:32 +00:00
|
|
|
#include "Runtime/Character/CAllFormatsAnimSource.hpp"
|
|
|
|
#include "Runtime/Character/CAnimPOIData.hpp"
|
2016-04-20 21:44:18 +00:00
|
|
|
#include "Runtime/Collision/CCollidableOBBTreeGroup.hpp"
|
2017-02-13 21:29:00 +00:00
|
|
|
#include "Runtime/Collision/CCollisionResponseData.hpp"
|
2016-10-08 20:32:36 +00:00
|
|
|
#include "Runtime/CSaveWorld.hpp"
|
|
|
|
#include "Runtime/AutoMapper/CMapWorld.hpp"
|
2017-03-24 05:30:16 +00:00
|
|
|
#include "Runtime/AutoMapper/CMapArea.hpp"
|
|
|
|
#include "Runtime/AutoMapper/CMapUniverse.hpp"
|
2017-01-31 11:21:45 +00:00
|
|
|
#include "Runtime/CScannableObjectInfo.hpp"
|
2016-07-24 22:51:15 +00:00
|
|
|
#include "Audio/CAudioGroupSet.hpp"
|
2017-01-20 03:53:32 +00:00
|
|
|
#include "Audio/CSfxManager.hpp"
|
2017-02-27 05:25:14 +00:00
|
|
|
#include "Audio/CMidiManager.hpp"
|
2016-04-12 11:37:07 +00:00
|
|
|
#include "Runtime/CDependencyGroup.hpp"
|
2016-03-26 00:51:59 +00:00
|
|
|
#include "DataSpec/DNACommon/TXTR.hpp"
|
2017-01-31 05:01:40 +00:00
|
|
|
#include "CSimplePool.hpp"
|
|
|
|
#include "GameGlobalObjects.hpp"
|
2016-03-26 00:51:59 +00:00
|
|
|
|
|
|
|
namespace DataSpec
|
|
|
|
{
|
|
|
|
extern hecl::Database::DataSpecEntry SpecEntMP1;
|
|
|
|
extern hecl::Database::DataSpecEntry SpecEntMP1PC;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
|
|
|
|
2017-01-31 05:01:40 +00:00
|
|
|
class MP1OriginalIDs
|
|
|
|
{
|
2017-08-13 05:26:14 +00:00
|
|
|
std::vector<std::pair<CAssetId, CAssetId>> m_origToNew;
|
|
|
|
std::vector<std::pair<CAssetId, CAssetId>> m_newToOrig;
|
2017-01-31 05:01:40 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
MP1OriginalIDs(CInputStream& in)
|
|
|
|
{
|
|
|
|
u32 count = in.readUint32Big();
|
|
|
|
m_origToNew.reserve(count);
|
|
|
|
for (u32 i=0 ; i<count ; ++i)
|
|
|
|
{
|
2017-08-13 05:26:14 +00:00
|
|
|
CAssetId a = in.readUint32Big();
|
|
|
|
CAssetId b = in.readUint32Big();
|
2017-01-31 05:01:40 +00:00
|
|
|
m_origToNew.push_back(std::make_pair(a, b));
|
|
|
|
}
|
|
|
|
m_newToOrig.reserve(count);
|
|
|
|
for (u32 i=0 ; i<count ; ++i)
|
|
|
|
{
|
2017-08-13 05:26:14 +00:00
|
|
|
CAssetId a = in.readUint32Big();
|
|
|
|
CAssetId b = in.readUint32Big();
|
2017-01-31 05:01:40 +00:00
|
|
|
m_newToOrig.push_back(std::make_pair(a, b));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-13 05:26:14 +00:00
|
|
|
CAssetId TranslateOriginalToNew(CAssetId id) const
|
2017-01-31 05:01:40 +00:00
|
|
|
{
|
2017-07-11 07:17:03 +00:00
|
|
|
auto search = rstl::binary_find(m_origToNew.cbegin(), m_origToNew.cend(), id,
|
|
|
|
[](const auto& id) { return id.first; });
|
|
|
|
if (search == m_origToNew.cend())
|
2017-01-31 05:01:40 +00:00
|
|
|
return -1;
|
|
|
|
return search->second;
|
|
|
|
}
|
|
|
|
|
2017-08-13 05:26:14 +00:00
|
|
|
CAssetId TranslateNewToOriginal(CAssetId id) const
|
2017-01-31 05:01:40 +00:00
|
|
|
{
|
2017-07-11 07:17:03 +00:00
|
|
|
auto search = rstl::binary_find(m_newToOrig.cbegin(), m_newToOrig.cend(), id,
|
|
|
|
[](const auto& id) { return id.first; });
|
|
|
|
if (search == m_newToOrig.cend())
|
2017-01-31 05:01:40 +00:00
|
|
|
return -1;
|
|
|
|
return search->second;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
CFactoryFnReturn FMP1OriginalIDsFactory(const SObjectTag& tag, CInputStream& in,
|
|
|
|
const CVParamTransfer& param,
|
|
|
|
CObjectReference* selfRef)
|
|
|
|
{
|
|
|
|
return TToken<MP1OriginalIDs>::GetIObjObjectFor(std::make_unique<MP1OriginalIDs>(in));
|
|
|
|
}
|
|
|
|
|
2016-03-27 20:43:04 +00:00
|
|
|
ProjectResourceFactoryMP1::ProjectResourceFactoryMP1(hecl::ClientProcess& clientProc)
|
|
|
|
: ProjectResourceFactoryBase(clientProc)
|
2016-03-26 00:51:59 +00:00
|
|
|
{
|
2016-04-01 01:00:37 +00:00
|
|
|
m_factoryMgr.AddFactory(FOURCC('TXTR'), FMemFactoryFunc(FTextureFactory));
|
2016-03-31 02:44:43 +00:00
|
|
|
m_factoryMgr.AddFactory(FOURCC('PART'), FFactoryFunc(FParticleFactory));
|
|
|
|
m_factoryMgr.AddFactory(FOURCC('FRME'), FFactoryFunc(RGuiFrameFactoryInGame));
|
|
|
|
m_factoryMgr.AddFactory(FOURCC('FONT'), FFactoryFunc(FRasterFontFactory));
|
|
|
|
m_factoryMgr.AddFactory(FOURCC('CMDL'), FMemFactoryFunc(FModelFactory));
|
2016-04-09 23:19:17 +00:00
|
|
|
m_factoryMgr.AddFactory(FOURCC('CINF'), FFactoryFunc(FCharLayoutInfo));
|
2016-04-12 22:28:08 +00:00
|
|
|
m_factoryMgr.AddFactory(FOURCC('CSKR'), FFactoryFunc(FSkinRulesFactory));
|
2016-04-10 21:22:59 +00:00
|
|
|
m_factoryMgr.AddFactory(FOURCC('ANCS'), FFactoryFunc(FAnimCharacterSet));
|
2016-04-12 06:15:32 +00:00
|
|
|
m_factoryMgr.AddFactory(FOURCC('ANIM'), FFactoryFunc(AnimSourceFactory));
|
|
|
|
m_factoryMgr.AddFactory(FOURCC('EVNT'), FFactoryFunc(AnimPOIDataFactory));
|
2016-04-20 21:44:18 +00:00
|
|
|
m_factoryMgr.AddFactory(FOURCC('DCLN'), FFactoryFunc(FCollidableOBBTreeGroupFactory));
|
2016-04-12 11:37:07 +00:00
|
|
|
m_factoryMgr.AddFactory(FOURCC('DGRP'), FFactoryFunc(FDependencyGroupFactory));
|
2016-07-24 22:51:15 +00:00
|
|
|
m_factoryMgr.AddFactory(FOURCC('AGSC'), FMemFactoryFunc(FAudioGroupSetDataFactory));
|
2017-02-27 05:25:14 +00:00
|
|
|
m_factoryMgr.AddFactory(FOURCC('CSNG'), FFactoryFunc(FMidiDataFactory));
|
2017-01-20 03:53:32 +00:00
|
|
|
m_factoryMgr.AddFactory(FOURCC('ATBL'), FFactoryFunc(FAudioTranslationTableFactory));
|
2016-08-17 05:40:25 +00:00
|
|
|
m_factoryMgr.AddFactory(FOURCC('STRG'), FFactoryFunc(FStringTableFactory));
|
2016-09-10 04:50:00 +00:00
|
|
|
m_factoryMgr.AddFactory(FOURCC('HINT'), FFactoryFunc(FHintFactory));
|
2016-10-08 20:32:36 +00:00
|
|
|
m_factoryMgr.AddFactory(FOURCC('SAVW'), FFactoryFunc(FSaveWorldFactory));
|
|
|
|
m_factoryMgr.AddFactory(FOURCC('MAPW'), FFactoryFunc(FMapWorldFactory));
|
2017-01-31 05:01:40 +00:00
|
|
|
m_factoryMgr.AddFactory(FOURCC('OIDS'), FFactoryFunc(FMP1OriginalIDsFactory));
|
2017-01-31 11:21:45 +00:00
|
|
|
m_factoryMgr.AddFactory(FOURCC('SCAN'), FFactoryFunc(FScannableObjectInfoFactory));
|
2017-02-13 21:29:00 +00:00
|
|
|
m_factoryMgr.AddFactory(FOURCC('CRSC'), FFactoryFunc(FCollisionResponseDataFactory));
|
|
|
|
m_factoryMgr.AddFactory(FOURCC('SWHC'), FFactoryFunc(FParticleSwooshDataFactory));
|
|
|
|
m_factoryMgr.AddFactory(FOURCC('ELSC'), FFactoryFunc(FParticleElectricDataFactory));
|
|
|
|
m_factoryMgr.AddFactory(FOURCC('WPSC'), FFactoryFunc(FProjectileWeaponDataFactory));
|
|
|
|
m_factoryMgr.AddFactory(FOURCC('DPSC'), FFactoryFunc(FDecalDataFactory));
|
2017-03-24 05:30:16 +00:00
|
|
|
m_factoryMgr.AddFactory(FOURCC('MAPA'), FFactoryFunc(FMapAreaFactory));
|
|
|
|
m_factoryMgr.AddFactory(FOURCC('MAPU'), FFactoryFunc(FMapUniverseFactory));
|
2016-03-26 00:51:59 +00:00
|
|
|
}
|
|
|
|
|
2017-01-31 05:01:40 +00:00
|
|
|
void ProjectResourceFactoryMP1::IndexMP1Resources(hecl::Database::Project& proj, CSimplePool& sp)
|
2016-03-26 00:51:59 +00:00
|
|
|
{
|
|
|
|
BeginBackgroundIndex(proj, DataSpec::SpecEntMP1, DataSpec::SpecEntMP1PC);
|
2017-01-31 05:01:40 +00:00
|
|
|
m_origIds = sp.GetObj("MP1OriginalIDs");
|
|
|
|
}
|
|
|
|
|
2017-02-12 23:56:03 +00:00
|
|
|
void ProjectResourceFactoryMP1::GetTagListForFile(const char* pakName, std::vector<SObjectTag>& out) const
|
|
|
|
{
|
|
|
|
std::string pathPrefix("MP1/");
|
|
|
|
pathPrefix += pakName;
|
|
|
|
pathPrefix += '/';
|
|
|
|
|
|
|
|
std::unique_lock<std::mutex> lk(
|
|
|
|
const_cast<ProjectResourceFactoryMP1&>(*this).m_backgroundIndexMutex);
|
|
|
|
for (const auto& tag : m_tagToPath)
|
|
|
|
if (!tag.second.getRelativePathUTF8().compare(0, pathPrefix.size(), pathPrefix))
|
|
|
|
out.push_back(tag.first);
|
|
|
|
}
|
|
|
|
|
2017-01-31 05:01:40 +00:00
|
|
|
void ProjectResourceFactoryMP1::Shutdown()
|
|
|
|
{
|
|
|
|
m_origIds = TLockedToken<MP1OriginalIDs>();
|
|
|
|
ProjectResourceFactoryBase::Shutdown();
|
|
|
|
}
|
|
|
|
|
2017-08-13 05:26:14 +00:00
|
|
|
CAssetId ProjectResourceFactoryMP1::TranslateOriginalToNew(CAssetId id) const
|
2017-01-31 05:01:40 +00:00
|
|
|
{
|
|
|
|
return m_origIds->TranslateOriginalToNew(id);
|
|
|
|
}
|
|
|
|
|
2017-08-13 05:26:14 +00:00
|
|
|
CAssetId ProjectResourceFactoryMP1::TranslateNewToOriginal(CAssetId id) const
|
2017-01-31 05:01:40 +00:00
|
|
|
{
|
|
|
|
return m_origIds->TranslateNewToOriginal(id);
|
2016-03-26 00:51:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|