mirror of https://github.com/AxioDL/metaforce.git
AssetNameMap fixes
This commit is contained in:
parent
5f02951f72
commit
dea26b1b32
|
@ -18,33 +18,38 @@ struct SAsset
|
||||||
std::string directory;
|
std::string directory;
|
||||||
hecl::FourCC type;
|
hecl::FourCC type;
|
||||||
SAsset() = default;
|
SAsset() = default;
|
||||||
SAsset(athena::io::IStreamReader& in)
|
SAsset(const hecl::FourCC& typeIn, athena::io::IStreamReader& in)
|
||||||
|
: type(typeIn)
|
||||||
{
|
{
|
||||||
uint32_t nameLen = in.readUint32Big();
|
uint32_t nameLen = in.readUint32Big();
|
||||||
name = in.readString(nameLen);
|
name = in.readString(nameLen);
|
||||||
uint32_t dirLen = in.readUint32Big();
|
uint32_t dirLen = in.readUint32Big();
|
||||||
directory = in.readString(dirLen);
|
directory = in.readString(dirLen);
|
||||||
type = in.readUint32Big();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::unordered_map<uint64_t, SAsset> g_AssetNameMap;
|
static std::unordered_map<uint64_t, SAsset> g_AssetNameMap;
|
||||||
static bool g_AssetNameMapInit = false;
|
static bool g_AssetNameMapInit = false;
|
||||||
|
|
||||||
void LoadAssetMap(athena::io::MemoryReader ar)
|
void LoadAssetMap(athena::io::MemoryReader& ar)
|
||||||
{
|
{
|
||||||
if (!ar.hasError())
|
if (!ar.hasError())
|
||||||
{
|
{
|
||||||
hecl::FourCC magic = ar.readUint32Big();
|
hecl::FourCC magic;
|
||||||
|
if (ar.length() >= 4)
|
||||||
|
ar.readBytesToBuf(&magic, 4);
|
||||||
if (magic != FOURCC('AIDM'))
|
if (magic != FOURCC('AIDM'))
|
||||||
Log.report(logvisor::Error, _S("Unable to load asset map; Assets will not have proper filenames for most files."));
|
Log.report(logvisor::Warning, _S("Unable to load asset map; Assets will not have proper filenames for most files."));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uint32_t assetCount = ar.readUint32Big();
|
uint32_t assetCount = ar.readUint32Big();
|
||||||
|
g_AssetNameMap.reserve(assetCount);
|
||||||
for (uint32_t i = 0 ; i<assetCount ; ++i)
|
for (uint32_t i = 0 ; i<assetCount ; ++i)
|
||||||
{
|
{
|
||||||
|
hecl::FourCC type;
|
||||||
|
ar.readBytesToBuf(&type, 4);
|
||||||
uint64_t id = ar.readUint64Big();
|
uint64_t id = ar.readUint64Big();
|
||||||
g_AssetNameMap[id] = SAsset(ar);
|
g_AssetNameMap[id] = SAsset(type, ar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,6 +60,8 @@ void InitAssetNameMap()
|
||||||
if (g_AssetNameMapInit)
|
if (g_AssetNameMapInit)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Log.report(logvisor::Info, "Initializing asset name database...");
|
||||||
|
|
||||||
/* First load the 32bit map for MP1/2 */
|
/* First load the 32bit map for MP1/2 */
|
||||||
{
|
{
|
||||||
athena::io::MemoryReader ar(ASSET_NAME_MP32, ASSET_NAME_MP32_SZ);
|
athena::io::MemoryReader ar(ASSET_NAME_MP32, ASSET_NAME_MP32_SZ);
|
||||||
|
|
2
hecl
2
hecl
|
@ -1 +1 @@
|
||||||
Subproject commit 5bf2c842cea46714f56e9d9ead06ef0977cd3345
|
Subproject commit 204ddd5adf94822abafb25eb0771ddf2a2fa2f65
|
Loading…
Reference in New Issue