CScriptActorRotate: Brace statements where applicable

Makes code consistent.
This commit is contained in:
Lioncash 2020-05-07 08:10:24 -04:00
parent e8dc27bfaa
commit 63fda8f1c7
1 changed files with 34 additions and 23 deletions

View File

@ -25,8 +25,9 @@ void CScriptActorRotate::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid
} }
if (msg == EScriptObjectMessage::Action || msg == EScriptObjectMessage::Next || if (msg == EScriptObjectMessage::Action || msg == EScriptObjectMessage::Next ||
(msg == EScriptObjectMessage::Registered && x58_27_updateOnCreation)) (msg == EScriptObjectMessage::Registered && x58_27_updateOnCreation)) {
UpdateActors(msg == EScriptObjectMessage::Next, mgr); UpdateActors(msg == EScriptObjectMessage::Next, mgr);
}
CEntity::AcceptScriptMsg(msg, uid, mgr); CEntity::AcceptScriptMsg(msg, uid, mgr);
} }
@ -39,31 +40,34 @@ void CScriptActorRotate::Think(float dt, CStateManager& mgr) {
x44_currentTime = x40_maxTime; x44_currentTime = x40_maxTime;
} }
float timeOffset = x44_currentTime / x40_maxTime; const float timeOffset = x44_currentTime / x40_maxTime;
for (const auto& actorPair : x48_actors) { for (const auto& actorPair : x48_actors) {
if (TCastToPtr<CActor> act = mgr.ObjectById(actorPair.first)) { if (const TCastToPtr<CActor> act = mgr.ObjectById(actorPair.first)) {
zeus::CTransform xf = zeus::CTransform::RotateZ(zeus::degToRad(timeOffset * x34_rotation.z())) * const zeus::CTransform xf = zeus::CTransform::RotateZ(zeus::degToRad(timeOffset * x34_rotation.z())) *
zeus::CTransform::RotateY(zeus::degToRad(timeOffset * x34_rotation.y())) * zeus::CTransform::RotateY(zeus::degToRad(timeOffset * x34_rotation.y())) *
zeus::CTransform::RotateX(zeus::degToRad(timeOffset * x34_rotation.x())); zeus::CTransform::RotateX(zeus::degToRad(timeOffset * x34_rotation.x()));
zeus::CTransform localRot = actorPair.second * xf; zeus::CTransform localRot = actorPair.second * xf;
localRot.origin = act->GetTranslation(); localRot.origin = act->GetTranslation();
act->SetTransform(localRot); act->SetTransform(localRot);
if (TCastToPtr<CScriptPlatform> plat = mgr.ObjectById(actorPair.first)) if (const TCastToPtr<CScriptPlatform> plat = mgr.ObjectById(actorPair.first)) {
UpdatePlatformRiders(*plat.GetPtr(), xf, mgr); UpdatePlatformRiders(*plat.GetPtr(), xf, mgr);
} }
} }
}
if (x58_24_updateRotation) { if (x58_24_updateRotation) {
if (!x58_25_skipSpiderBallWaypoints) if (!x58_25_skipSpiderBallWaypoints) {
UpdateSpiderBallWaypoints(mgr); UpdateSpiderBallWaypoints(mgr);
}
if (x58_26_updateActors) if (x58_26_updateActors) {
UpdateActors(false, mgr); UpdateActors(false, mgr);
} }
} }
} }
}
void CScriptActorRotate::UpdatePlatformRiders(CScriptPlatform& plat, const zeus::CTransform& xf, CStateManager& mgr) { void CScriptActorRotate::UpdatePlatformRiders(CScriptPlatform& plat, const zeus::CTransform& xf, CStateManager& mgr) {
UpdatePlatformRiders(plat.GetStaticSlaves(), plat, xf, mgr); UpdatePlatformRiders(plat.GetStaticSlaves(), plat, xf, mgr);
@ -73,7 +77,7 @@ void CScriptActorRotate::UpdatePlatformRiders(CScriptPlatform& plat, const zeus:
void CScriptActorRotate::UpdatePlatformRiders(std::vector<SRiders>& riders, CScriptPlatform& plat, void CScriptActorRotate::UpdatePlatformRiders(std::vector<SRiders>& riders, CScriptPlatform& plat,
const zeus::CTransform& xf, CStateManager& mgr) { const zeus::CTransform& xf, CStateManager& mgr) {
for (SRiders& rider : riders) { for (SRiders& rider : riders) {
if (TCastToPtr<CActor> act = mgr.ObjectById(rider.x0_uid)) { if (const TCastToPtr<CActor> act = mgr.ObjectById(rider.x0_uid)) {
zeus::CTransform& riderXf = rider.x8_transform; zeus::CTransform& riderXf = rider.x8_transform;
act->SetTransform(rider.x8_transform); act->SetTransform(rider.x8_transform);
act->SetTranslation(act->GetTranslation() + plat.GetTranslation()); act->SetTranslation(act->GetTranslation() + plat.GetTranslation());
@ -81,27 +85,33 @@ void CScriptActorRotate::UpdatePlatformRiders(std::vector<SRiders>& riders, CScr
if (x58_24_updateRotation) { if (x58_24_updateRotation) {
riderXf = {act->GetTransform().basis, act->GetTranslation() - plat.GetTranslation()}; riderXf = {act->GetTransform().basis, act->GetTranslation() - plat.GetTranslation()};
if (TCastToPtr<CScriptSpiderBallWaypoint> wp = act.GetPtr()) if (TCastToConstPtr<CScriptSpiderBallWaypoint>(act.GetPtr())) {
x58_25_skipSpiderBallWaypoints = true; x58_25_skipSpiderBallWaypoints = true;
} }
}
if (TCastToPtr<CScriptPlatform> plat2 = mgr.ObjectById(rider.x0_uid)) if (const TCastToPtr<CScriptPlatform> plat2 = mgr.ObjectById(rider.x0_uid)) {
UpdatePlatformRiders(*plat2.GetPtr(), xf, mgr); UpdatePlatformRiders(*plat2.GetPtr(), xf, mgr);
} }
} }
} }
}
void CScriptActorRotate::UpdateActors(bool next, CStateManager& mgr) { void CScriptActorRotate::UpdateActors(bool next, CStateManager& mgr) {
if (x58_24_updateRotation) if (x58_24_updateRotation) {
return; return;
}
x48_actors.clear(); x48_actors.clear();
for (const SConnection& conn : x20_conns) { for (const SConnection& conn : x20_conns) {
if (conn.x0_state == EScriptObjectState::Play && conn.x4_msg == EScriptObjectMessage::Play) { if (conn.x0_state != EScriptObjectState::Play || conn.x4_msg != EScriptObjectMessage::Play) {
continue;
}
auto search = mgr.GetIdListForScript(conn.x8_objId); auto search = mgr.GetIdListForScript(conn.x8_objId);
for (auto it = search.first; it != search.second; ++it) { for (auto it = search.first; it != search.second; ++it) {
if (TCastToPtr<CActor> act = mgr.ObjectById(it->second)) if (const TCastToConstPtr<CActor> act = mgr.ObjectById(it->second)) {
x48_actors[it->second] = act->GetTransform().getRotation(); x48_actors[it->second] = act->GetTransform().getRotation();
} }
} }
@ -118,13 +128,14 @@ void CScriptActorRotate::UpdateActors(bool next, CStateManager& mgr) {
void CScriptActorRotate::UpdateSpiderBallWaypoints(CStateManager& mgr) { void CScriptActorRotate::UpdateSpiderBallWaypoints(CStateManager& mgr) {
rstl::reserved_vector<TUniqueId, 1024> waypointIds; rstl::reserved_vector<TUniqueId, 1024> waypointIds;
CObjectList& objectList = mgr.GetAllObjectList(); CObjectList& objectList = mgr.GetAllObjectList();
for (CEntity* ent : objectList) { for (const CEntity* ent : objectList) {
if (TCastToPtr<CScriptSpiderBallWaypoint> wp = ent) if (const TCastToConstPtr<CScriptSpiderBallWaypoint> wp = ent) {
waypointIds.push_back(wp->GetUniqueId()); waypointIds.push_back(wp->GetUniqueId());
} }
}
for (const TUniqueId& uid : waypointIds) { for (const TUniqueId& uid : waypointIds) {
CScriptSpiderBallWaypoint* wp = static_cast<CScriptSpiderBallWaypoint*>(mgr.ObjectById(uid)); auto* wp = static_cast<CScriptSpiderBallWaypoint*>(mgr.ObjectById(uid));
if (wp) { if (wp) {
#if 0 #if 0
wp->sub_801187B4(mgr); wp->sub_801187B4(mgr);