2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 23:07:42 +00:00

CVisorFlare: Pass flares by value and use std::move

Same behavior, but allows calling code to move into the parameter and
avoid copies entirely.
This commit is contained in:
Lioncash
2020-03-26 00:28:31 -04:00
parent 477c5770c6
commit 2164854e87
5 changed files with 26 additions and 22 deletions

View File

@@ -2339,25 +2339,30 @@ CEntity* ScriptLoader::LoadFishCloudModifier(CStateManager& mgr, CInputStream& i
}
CEntity* ScriptLoader::LoadVisorFlare(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) {
if (!EnsurePropertyCount(propCount, 14, "VisorFlare"))
if (!EnsurePropertyCount(propCount, 14, "VisorFlare")) {
return nullptr;
}
const std::string name = mgr.HashInstanceName(in);
const zeus::CVector3f pos = zeus::CVector3f::ReadBig(in);
const bool b1 = in.readBool();
const auto w1 = CVisorFlare::EBlendMode(in.readUint32Big());
const bool b2 = in.readBool();
const float f1 = in.readFloatBig();
const float f2 = in.readFloatBig();
const float f3 = in.readFloatBig();
const u32 w2 = in.readUint32Big();
std::string name = mgr.HashInstanceName(in);
zeus::CVector3f pos = zeus::CVector3f::ReadBig(in);
bool b1 = in.readBool();
CVisorFlare::EBlendMode w1 = CVisorFlare::EBlendMode(in.readUint32Big());
bool b2 = in.readBool();
float f1 = in.readFloatBig();
float f2 = in.readFloatBig();
float f3 = in.readFloatBig();
u32 w2 = in.readUint32Big();
std::vector<CVisorFlare::CFlareDef> flares;
flares.reserve(5);
for (int i = 0; i < 5; ++i)
if (auto flare = CVisorFlare::LoadFlareDef(in))
for (size_t i = 0; i < flares.capacity(); ++i) {
if (auto flare = CVisorFlare::LoadFlareDef(in)) {
flares.push_back(*flare);
}
}
return new CScriptVisorFlare(mgr.AllocateUniqueId(), name, info, b1, pos, w1, b2, f1, f2, f3, 2, w2, flares);
return new CScriptVisorFlare(mgr.AllocateUniqueId(), name, info, b1, pos, w1, b2, f1, f2, f3, 2, w2,
std::move(flares));
}
CEntity* ScriptLoader::LoadWorldTeleporter(CStateManager& mgr, CInputStream& in, int propCount,