2020-01-15 12:07:48 +00:00
|
|
|
#include "Runtime/RetroTypes.hpp"
|
2022-02-18 07:37:54 +00:00
|
|
|
#include "Runtime/IOStreams.hpp"
|
2020-01-15 12:07:48 +00:00
|
|
|
#include "Runtime/GameGlobalObjects.hpp"
|
|
|
|
#include "Runtime/IMain.hpp"
|
|
|
|
|
|
|
|
#include <logvisor/logvisor.hpp>
|
2017-08-13 05:26:14 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
|
|
|
logvisor::Module Log("metaforce::RetroTypes::CAssetId");
|
2017-08-13 05:26:14 +00:00
|
|
|
|
2022-02-18 07:37:54 +00:00
|
|
|
SObjectTag::SObjectTag(CInputStream& in) {
|
|
|
|
in.ReadBytes(reinterpret_cast<char*>(&type), 4);
|
|
|
|
id = in.Get<CAssetId>();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SObjectTag::ReadMLVL(CInputStream& in) {
|
|
|
|
id = in.Get<CAssetId>();
|
|
|
|
in.ReadBytes(reinterpret_cast<char*>(&type), 4);
|
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CAssetId::CAssetId(CInputStream& in) {
|
2022-02-18 07:37:54 +00:00
|
|
|
if (g_Main != nullptr) {
|
|
|
|
if (g_Main->GetExpectedIdSize() == sizeof(u32)) {
|
|
|
|
Assign(in.ReadLong());
|
|
|
|
} else if (g_Main->GetExpectedIdSize() == sizeof(u64)) {
|
|
|
|
Assign(in.ReadLongLong());
|
|
|
|
} else {
|
2020-04-11 22:51:39 +00:00
|
|
|
Log.report(logvisor::Fatal, FMT_STRING("Unsupported id length {}"), g_Main->GetExpectedIdSize());
|
2022-02-18 07:37:54 +00:00
|
|
|
}
|
|
|
|
} else {
|
2020-04-11 22:51:39 +00:00
|
|
|
Log.report(logvisor::Fatal, FMT_STRING("Input constructor called before runtime Main entered!"));
|
2022-02-18 07:37:54 +00:00
|
|
|
}
|
2017-08-13 05:26:14 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CAssetId::PutTo(COutputStream& out) {
|
2022-02-18 07:37:54 +00:00
|
|
|
if (g_Main != nullptr) {
|
|
|
|
if (g_Main->GetExpectedIdSize() == sizeof(u32)) {
|
|
|
|
out.Put(u32(id));
|
|
|
|
} else if (g_Main->GetExpectedIdSize() == sizeof(u64)) {
|
|
|
|
out.Put(id);
|
|
|
|
} else {
|
2020-04-11 22:51:39 +00:00
|
|
|
Log.report(logvisor::Fatal, FMT_STRING("Unsupported id length {}"), g_Main->GetExpectedIdSize());
|
2022-02-18 07:37:54 +00:00
|
|
|
}
|
|
|
|
} else {
|
2020-04-11 22:51:39 +00:00
|
|
|
Log.report(logvisor::Fatal, FMT_STRING("PutTo called before runtime Main entered!"));
|
2022-02-18 07:37:54 +00:00
|
|
|
}
|
2017-08-13 05:26:14 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|