metaforce/Runtime/RetroTypes.cpp

32 lines
1.0 KiB
C++
Raw Normal View History

2017-08-13 05:26:14 +00:00
#include "RetroTypes.hpp"
#include "GameGlobalObjects.hpp"
#include "IMain.hpp"
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
2018-12-08 05:30:43 +00:00
Log.report(logvisor::Fatal, "Unsupported id length %i", g_Main->GetExpectedIdSize());
} else
Log.report(logvisor::Fatal, "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
2018-12-08 05:30:43 +00:00
Log.report(logvisor::Fatal, "Unsupported id length %i", g_Main->GetExpectedIdSize());
} else
Log.report(logvisor::Fatal, "PutTo called before runtime Main entered!");
2017-08-13 05:26:14 +00:00
}
2018-12-08 05:30:43 +00:00
} // namespace urde