From 1dc90f78d32ee42b7d48a9cfd882759c53fcce76 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Tue, 7 Apr 2020 15:41:26 -0400 Subject: [PATCH] CScriptPlatform: Fix AddRider assign to copy --- Runtime/World/CScriptPlatform.cpp | 21 +++++++++++---------- Runtime/World/CScriptPlatform.hpp | 4 ++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Runtime/World/CScriptPlatform.cpp b/Runtime/World/CScriptPlatform.cpp index bfdf77335..c08b7c89a 100644 --- a/Runtime/World/CScriptPlatform.cpp +++ b/Runtime/World/CScriptPlatform.cpp @@ -24,19 +24,19 @@ static CMaterialList MakePlatformMaterialList() { return ret; } -CScriptPlatform::CScriptPlatform( - TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf, CModelData&& mData, - const CActorParameters& actParms, const zeus::CAABox& aabb, float speed, bool detectCollision, float xrayAlpha, - bool active, const CHealthInfo& hInfo, const CDamageVulnerability& dVuln, - const std::optional>& dcln, bool rainSplashes, - u32 maxRainSplashes, u32 rainGenRate) +CScriptPlatform::CScriptPlatform(TUniqueId uid, std::string_view name, const CEntityInfo& info, + const zeus::CTransform& xf, CModelData&& mData, const CActorParameters& actParms, + const zeus::CAABox& aabb, float speed, bool detectCollision, float xrayAlpha, + bool active, const CHealthInfo& hInfo, const CDamageVulnerability& dVuln, + std::optional> dcln, + bool rainSplashes, u32 maxRainSplashes, u32 rainGenRate) : CPhysicsActor(uid, active, name, info, xf, std::move(mData), MakePlatformMaterialList(), aabb, SMoverData(15000.f), actParms, 0.3f, 0.1f) , x25c_currentSpeed(speed) , x28c_initialHealth(hInfo) , x294_health(hInfo) , x29c_damageVuln(dVuln) -, x304_treeGroupContainer(dcln) { +, x304_treeGroupContainer(std::move(dcln)) { x348_xrayAlpha = xrayAlpha; x34c_maxRainSplashes = maxRainSplashes; x350_rainGenRate = rainGenRate; @@ -374,7 +374,8 @@ void CScriptPlatform::BuildSlaveList(CStateManager& mgr) { void CScriptPlatform::AddRider(std::vector& riders, TUniqueId riderId, const CPhysicsActor* ridee, CStateManager& mgr) { - auto search = std::find_if(riders.begin(), riders.end(), [riderId](const SRiders& r) { return r.x0_uid == riderId; }); + const auto& search = + std::find_if(riders.begin(), riders.end(), [riderId](const SRiders& r) { return r.x0_uid == riderId; }); if (search == riders.end()) { zeus::CTransform xf; if (TCastToPtr act = mgr.ObjectById(riderId)) { @@ -388,8 +389,8 @@ void CScriptPlatform::AddRider(std::vector& riders, TUniqueId riderId, } void CScriptPlatform::AddSlave(TUniqueId id, CStateManager& mgr) { - auto search = std::find_if(x338_slavesDynamic.begin(), x338_slavesDynamic.end(), - [id](const SRiders& r) { return r.x0_uid == id; }); + const auto& search = std::find_if(x338_slavesDynamic.begin(), x338_slavesDynamic.end(), + [id](const SRiders& r) { return r.x0_uid == id; }); if (search == x338_slavesDynamic.end()) { if (TCastToPtr act = mgr.ObjectById(id)) { act->AddMaterial(EMaterialTypes::PlatformSlave, mgr); diff --git a/Runtime/World/CScriptPlatform.hpp b/Runtime/World/CScriptPlatform.hpp index caaf4a352..ffa6806c8 100644 --- a/Runtime/World/CScriptPlatform.hpp +++ b/Runtime/World/CScriptPlatform.hpp @@ -31,7 +31,7 @@ struct SRiders { }; class CScriptPlatform : public CPhysicsActor { - u32 x254_; + // u32 x254_; TUniqueId x258_currentWaypoint = kInvalidUniqueId; TUniqueId x25a_targetWaypoint = kInvalidUniqueId; float x25c_currentSpeed; @@ -83,7 +83,7 @@ public: CModelData&& mData, const CActorParameters& actParms, const zeus::CAABox& aabb, float speed, bool detectCollision, float xrayAlpha, bool active, const CHealthInfo& hInfo, const CDamageVulnerability& dVuln, - const std::optional>& dcln, bool rainSplashes, + std::optional> dcln, bool rainSplashes, u32 maxRainSplashes, u32 rainGenRate); void Accept(IVisitor& visitor) override;