2020-01-15 07:07:48 -05:00
|
|
|
#include "Runtime/RetroTypes.hpp"
|
2022-02-19 05:04:45 -08:00
|
|
|
#include "Runtime/Streams/IOStreams.hpp"
|
2020-01-15 07:07:48 -05:00
|
|
|
#include "Runtime/GameGlobalObjects.hpp"
|
|
|
|
|
#include "Runtime/IMain.hpp"
|
2025-04-03 21:07:07 -06:00
|
|
|
#include "Runtime/Logging.hpp"
|
2017-08-12 22:26:14 -07:00
|
|
|
|
2021-04-10 01:42:06 -07:00
|
|
|
namespace metaforce {
|
2022-02-17 23:37:54 -08:00
|
|
|
SObjectTag::SObjectTag(CInputStream& in) {
|
2022-02-19 05:04:45 -08:00
|
|
|
in.ReadBytes(reinterpret_cast<u8*>(&type), 4);
|
2022-02-17 23:37:54 -08:00
|
|
|
id = in.Get<CAssetId>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SObjectTag::ReadMLVL(CInputStream& in) {
|
|
|
|
|
id = in.Get<CAssetId>();
|
2022-02-19 05:04:45 -08:00
|
|
|
in.ReadBytes(reinterpret_cast<u8*>(&type), 4);
|
2022-02-17 23:37:54 -08:00
|
|
|
}
|
|
|
|
|
|
2018-12-07 19:30:43 -10:00
|
|
|
CAssetId::CAssetId(CInputStream& in) {
|
2022-02-17 23:37:54 -08:00
|
|
|
if (g_Main != nullptr) {
|
|
|
|
|
if (g_Main->GetExpectedIdSize() == sizeof(u32)) {
|
2022-02-19 05:04:45 -08:00
|
|
|
Assign(u32(in.ReadLong()));
|
2022-02-17 23:37:54 -08:00
|
|
|
} else if (g_Main->GetExpectedIdSize() == sizeof(u64)) {
|
|
|
|
|
Assign(in.ReadLongLong());
|
|
|
|
|
} else {
|
2025-04-03 21:07:07 -06:00
|
|
|
spdlog::fatal("Unsupported id length {}", g_Main->GetExpectedIdSize());
|
2022-02-17 23:37:54 -08:00
|
|
|
}
|
|
|
|
|
} else {
|
2025-04-03 21:07:07 -06:00
|
|
|
spdlog::fatal("Input constructor called before runtime Main entered!");
|
2022-02-17 23:37:54 -08:00
|
|
|
}
|
2017-08-12 22:26:14 -07:00
|
|
|
}
|
|
|
|
|
|
2022-02-19 05:04:45 -08:00
|
|
|
void CAssetId::PutTo(COutputStream& out) const {
|
2022-02-17 23:37:54 -08: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 {
|
2025-04-03 21:07:07 -06:00
|
|
|
spdlog::fatal("Unsupported id length {}", g_Main->GetExpectedIdSize());
|
2022-02-17 23:37:54 -08:00
|
|
|
}
|
|
|
|
|
} else {
|
2025-04-03 21:07:07 -06:00
|
|
|
spdlog::fatal("PutTo called before runtime Main entered!");
|
2022-02-17 23:37:54 -08:00
|
|
|
}
|
2017-08-12 22:26:14 -07:00
|
|
|
}
|
|
|
|
|
|
2021-04-10 01:42:06 -07:00
|
|
|
} // namespace metaforce
|