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

@ -11,11 +11,10 @@ namespace urde {
CScriptVisorFlare::CScriptVisorFlare(TUniqueId uid, std::string_view name, const CEntityInfo& info, bool active,
const zeus::CVector3f& pos, CVisorFlare::EBlendMode blendMode, bool b1, float f1,
float f2, float f3, u32 w1, u32 w2,
const std::vector<CVisorFlare::CFlareDef>& flares)
float f2, float f3, u32 w1, u32 w2, std::vector<CVisorFlare::CFlareDef> flares)
: CActor(uid, active, name, info, zeus::CTransform::Translate(pos), CModelData::CModelDataNull(),
CMaterialList(EMaterialTypes::NoStepLogic), CActorParameters::None(), kInvalidUniqueId)
, xe8_flare(blendMode, b1, f1, f2, f3, w1, w2, flares) {
, xe8_flare(blendMode, b1, f1, f2, f3, w1, w2, std::move(flares)) {
xe6_27_thermalVisorFlags = 2;
}

View File

@ -12,9 +12,9 @@ class CScriptVisorFlare : public CActor {
bool x11c_notInRenderLast = true;
public:
CScriptVisorFlare(TUniqueId, std::string_view name, const CEntityInfo& info, bool, const zeus::CVector3f&,
CVisorFlare::EBlendMode blendMode, bool, float, float, float, u32, u32,
const std::vector<CVisorFlare::CFlareDef>& flares);
CScriptVisorFlare(TUniqueId uid, std::string_view name, const CEntityInfo& info, bool active,
const zeus::CVector3f& pos, CVisorFlare::EBlendMode blendMode, bool, float, float, float, u32, u32,
std::vector<CVisorFlare::CFlareDef> flares);
void Accept(IVisitor& visitor) override;
void Think(float, CStateManager& stateMgr) override;

View File

@ -27,9 +27,9 @@ std::optional<CVisorFlare::CFlareDef> CVisorFlare::LoadFlareDef(CInputStream& in
}
CVisorFlare::CVisorFlare(EBlendMode blendMode, bool b1, float f1, float f2, float f3, u32 w1, u32 w2,
const std::vector<CFlareDef>& flares)
std::vector<CFlareDef> flares)
: x0_blendMode(blendMode)
, x4_flareDefs(flares)
, x4_flareDefs(std::move(flares))
, x14_b1(b1)
, x18_f1(std::max(f1, FLT_EPSILON))
, x1c_f2(f2)

View File

@ -49,7 +49,7 @@ private:
u32 x30_w2;
public:
CVisorFlare(EBlendMode blendMode, bool, float, float, float, u32, u32, const std::vector<CFlareDef>& flares);
CVisorFlare(EBlendMode blendMode, bool, float, float, float, u32, u32, std::vector<CFlareDef> flares);
void Update(float dt, const zeus::CVector3f& pos, const CActor* act, CStateManager& mgr);
void Render(const zeus::CVector3f& pos, const CStateManager& mgr) const;
static std::optional<CFlareDef> LoadFlareDef(CInputStream& in);

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,