From 610eba9527f7ebd01edc97e23adf2478e09e8f72 Mon Sep 17 00:00:00 2001 From: jadebenn Date: Sun, 8 Dec 2024 16:21:53 -0600 Subject: [PATCH] formatting and const --- .../02_server/Map/AG/NpcAgCourseStarter.cpp | 38 ++++++------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/dScripts/02_server/Map/AG/NpcAgCourseStarter.cpp b/dScripts/02_server/Map/AG/NpcAgCourseStarter.cpp index b6ed242c..05cc1e5d 100644 --- a/dScripts/02_server/Map/AG/NpcAgCourseStarter.cpp +++ b/dScripts/02_server/Map/AG/NpcAgCourseStarter.cpp @@ -3,23 +3,17 @@ #include "ScriptedActivityComponent.h" #include "GameMessages.h" #include "LeaderboardManager.h" +#include "dServer.h" #include "eMissionTaskType.h" #include "eMissionState.h" #include "MissionComponent.h" -#include #include -#include "dServer.h" - -void NpcAgCourseStarter::OnStartup(Entity* self) { -} +void NpcAgCourseStarter::OnStartup(Entity* self) {} void NpcAgCourseStarter::OnUse(Entity* self, Entity* user) { - auto* scriptedActivityComponent = self->GetComponent(); - - if (scriptedActivityComponent == nullptr) { - return; - } + auto* const scriptedActivityComponent = self->GetComponent(); + if (!scriptedActivityComponent) return; if (scriptedActivityComponent->GetActivityPlayerData(user->GetObjectID()) != nullptr) { GameMessages::SendNotifyClientObject(self->GetObjectID(), u"exit", 0, 0, LWOOBJID_EMPTY, "", user->GetSystemAddress()); @@ -29,15 +23,11 @@ void NpcAgCourseStarter::OnUse(Entity* self, Entity* user) { } void NpcAgCourseStarter::OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData) { - auto* scriptedActivityComponent = self->GetComponent(); - - if (scriptedActivityComponent == nullptr) { - return; - } + auto* const scriptedActivityComponent = self->GetComponent(); + if (!scriptedActivityComponent) return; if (identifier == u"player_dialog_cancel_course" && button == 1) { GameMessages::SendNotifyClientObject(self->GetObjectID(), u"stop_timer", 0, 0, LWOOBJID_EMPTY, "", sender->GetSystemAddress()); - GameMessages::SendNotifyClientObject(self->GetObjectID(), u"cancel_timer", 0, 0, LWOOBJID_EMPTY, "", sender->GetSystemAddress()); scriptedActivityComponent->RemoveActivityPlayerData(sender->GetObjectID()); @@ -45,17 +35,15 @@ void NpcAgCourseStarter::OnMessageBoxResponse(Entity* self, Entity* sender, int3 Game::entityManager->SerializeEntity(self); } else if (identifier == u"player_dialog_start_course" && button == 1) { GameMessages::SendNotifyClientObject(self->GetObjectID(), u"start_timer", 0, 0, LWOOBJID_EMPTY, "", sender->GetSystemAddress()); - GameMessages::SendActivityStart(self->GetObjectID(), sender->GetSystemAddress()); - auto* data = scriptedActivityComponent->AddActivityPlayerData(sender->GetObjectID()); + auto* const data = scriptedActivityComponent->AddActivityPlayerData(sender->GetObjectID()); if (data->values[1] != 0) return; const auto raceStartTime = std::chrono::steady_clock::now() - Game::server->GetStartTime() + std::chrono::seconds(4); // Offset for starting timer const auto fRaceStartTime = std::chrono::duration>(raceStartTime).count(); data->values[1] = fRaceStartTime; - LOG_DEBUG("Race started at: %0.f s", fRaceStartTime); Game::entityManager->SerializeEntity(self); } else if (identifier == u"FootRaceCancel") { @@ -72,11 +60,11 @@ void NpcAgCourseStarter::OnMessageBoxResponse(Entity* self, Entity* sender, int3 } void NpcAgCourseStarter::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) { - auto* scriptedActivityComponent = self->GetComponent(); - if (scriptedActivityComponent == nullptr) return; + auto* const scriptedActivityComponent = self->GetComponent(); + if (!scriptedActivityComponent) return; - auto* data = scriptedActivityComponent->GetActivityPlayerData(sender->GetObjectID()); - if (data == nullptr) return; + auto* const data = scriptedActivityComponent->GetActivityPlayerData(sender->GetObjectID()); + if (!data) return; if (args == "course_cancel") { GameMessages::SendNotifyClientObject(self->GetObjectID(), u"cancel_timer", 0, 0, @@ -86,11 +74,9 @@ void NpcAgCourseStarter::OnFireEventServerSide(Entity* self, Entity* sender, std const auto raceEndTime = std::chrono::steady_clock::now() - Game::server->GetStartTime(); const auto fRaceEndTime = std::chrono::duration>(raceEndTime).count(); const auto raceTimeElapsed = fRaceEndTime - data->values[1]; - data->values[2] = raceTimeElapsed; - LOG_DEBUG("Race time elapsed: %0.f s", raceTimeElapsed); - auto* missionComponent = sender->GetComponent(); + auto* const missionComponent = sender->GetComponent(); if (missionComponent != nullptr) { missionComponent->ForceProgressTaskType(1884, 1, 1, false); missionComponent->Progress(eMissionTaskType::PERFORM_ACTIVITY, -raceTimeElapsed, self->GetObjectID(),