metaforce/Runtime/RetroTypes.cpp

35 lines
1.1 KiB
C++
Raw Normal View History

#include "Runtime/RetroTypes.hpp"
#include "Runtime/GameGlobalObjects.hpp"
#include "Runtime/IMain.hpp"
#include <logvisor/logvisor.hpp>
2017-08-13 05:26:14 +00:00
2018-12-08 05:30:43 +00:00
namespace urde {
2017-08-13 05:26:14 +00:00
logvisor::Module Log("urde::RetroTypes::CAssetId");
2018-12-08 05:30:43 +00:00
CAssetId::CAssetId(CInputStream& in) {
if (g_Main) {
if (g_Main->GetExpectedIdSize() == sizeof(u32))
Assign(in.readUint32Big());
else if (g_Main->GetExpectedIdSize() == sizeof(u64))
Assign(in.readUint64Big());
2017-08-13 05:26:14 +00:00
else
2019-07-20 04:27:21 +00:00
Log.report(logvisor::Fatal, fmt("Unsupported id length {}"), g_Main->GetExpectedIdSize());
2018-12-08 05:30:43 +00:00
} else
2019-07-20 04:27:21 +00:00
Log.report(logvisor::Fatal, fmt("Input constructor called before runtime Main entered!"));
2017-08-13 05:26:14 +00:00
}
2018-12-08 05:30:43 +00:00
void CAssetId::PutTo(COutputStream& out) {
if (g_Main) {
if (g_Main->GetExpectedIdSize() == sizeof(u32))
out.writeUint32Big(u32(id));
else if (g_Main->GetExpectedIdSize() == sizeof(u64))
out.writeUint64Big(id);
2017-08-13 05:26:14 +00:00
else
2019-07-20 04:27:21 +00:00
Log.report(logvisor::Fatal, fmt("Unsupported id length {}"), g_Main->GetExpectedIdSize());
2018-12-08 05:30:43 +00:00
} else
2019-07-20 04:27:21 +00:00
Log.report(logvisor::Fatal, fmt("PutTo called before runtime Main entered!"));
2017-08-13 05:26:14 +00:00
}
2018-12-08 05:30:43 +00:00
} // namespace urde