CScriptCameraHint: Brace statements where applicable

Makes code consistent.
This commit is contained in:
Lioncash 2020-05-07 07:51:48 -04:00
parent a8fd2a1992
commit d6ad152a97
1 changed files with 30 additions and 15 deletions

View File

@ -29,20 +29,26 @@ void CScriptCameraHint::InitializeInArea(CStateManager& mgr) {
x164_delegatedCamera = kInvalidUniqueId;
for (CEntity* ent : mgr.GetAllObjectList()) {
for (const SConnection& conn : ent->GetConnectionList()) {
if (mgr.GetIdForScript(conn.x8_objId) != GetUniqueId())
if (mgr.GetIdForScript(conn.x8_objId) != GetUniqueId()) {
continue;
if (conn.x4_msg != EScriptObjectMessage::Increment && conn.x4_msg != EScriptObjectMessage::Decrement)
}
if (conn.x4_msg != EScriptObjectMessage::Increment && conn.x4_msg != EScriptObjectMessage::Decrement) {
continue;
}
for (auto it = ent->GetConnectionList().begin(); it != ent->GetConnectionList().end(); ++it) {
const SConnection& conn2 = *it;
if (conn2.x4_msg != EScriptObjectMessage::Increment && conn2.x4_msg != EScriptObjectMessage::Decrement)
if (conn2.x4_msg != EScriptObjectMessage::Increment && conn2.x4_msg != EScriptObjectMessage::Decrement) {
continue;
TUniqueId id = mgr.GetIdForScript(conn2.x8_objId);
if (TCastToPtr<CPathCamera>(mgr.ObjectById(id)) || TCastToPtr<CScriptSpindleCamera>(mgr.ObjectById((id)))) {
}
const TUniqueId id = mgr.GetIdForScript(conn2.x8_objId);
const auto* const obj = mgr.ObjectById(id);
if (TCastToConstPtr<CPathCamera>(obj) || TCastToConstPtr<CScriptSpindleCamera>(obj)) {
it = ent->GetConnectionList().erase(it);
if (x164_delegatedCamera != id)
if (x164_delegatedCamera != id) {
x164_delegatedCamera = id;
}
break;
}
}
@ -52,17 +58,25 @@ void CScriptCameraHint::InitializeInArea(CStateManager& mgr) {
}
void CScriptCameraHint::AddHelper(TUniqueId id) {
auto search = std::find_if(x150_helpers.begin(), x150_helpers.end(), [id](TUniqueId tid) { return tid == id; });
if (search == x150_helpers.end())
x150_helpers.push_back(id);
const auto search =
std::find_if(x150_helpers.cbegin(), x150_helpers.cend(), [id](TUniqueId tid) { return tid == id; });
if (search != x150_helpers.end()) {
return;
}
x150_helpers.push_back(id);
}
void CScriptCameraHint::RemoveHelper(TUniqueId id) {
auto search = std::find_if(x150_helpers.begin(), x150_helpers.end(), [id](TUniqueId tid) { return tid == id; });
if (search != x150_helpers.end())
const auto search =
std::find_if(x150_helpers.cbegin(), x150_helpers.cend(), [id](TUniqueId tid) { return tid == id; });
if (search != x150_helpers.cend()) {
x150_helpers.erase(search);
else
} else {
x150_helpers.pop_front();
}
}
void CScriptCameraHint::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) {
@ -96,13 +110,14 @@ void CScriptCameraHint::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId send
if (msg == EScriptObjectMessage::Follow) {
if (!GetActive()) {
if (TCastToConstPtr<CActor> act = mgr.GetObjectById(sender)) {
if (const TCastToConstPtr<CActor> act = mgr.GetObjectById(sender)) {
zeus::CVector3f followerToThisFlat = x168_origXf.origin - act->GetTranslation();
followerToThisFlat.z() = 0.f;
if (followerToThisFlat.canBeNormalized())
if (followerToThisFlat.canBeNormalized()) {
followerToThisFlat.normalize();
else
} else {
followerToThisFlat = act->GetTransform().basis[1];
}
zeus::CVector3f target = act->GetTranslation() + followerToThisFlat;
target.z() = x168_origXf.origin.z() + followerToThisFlat.z();
SetTransform(zeus::lookAt(act->GetTranslation(), target));