From 12296ce5534b0b362a765a9885da1f507f300f81 Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Thu, 24 Jul 2025 04:26:51 -0700 Subject: [PATCH] feat: activity component debug stuff and fix issues with duplicates in debug ui (#1850) Tested that duplicate data in ui is no longer hidden and that activity debug stuff is shown --- dGame/dComponents/ActivityComponent.cpp | 98 ++++++++++++++++++- dGame/dComponents/ActivityComponent.h | 13 ++- .../ControllablePhysicsComponent.cpp | 7 +- dGame/dComponents/DestroyableComponent.cpp | 6 +- 4 files changed, 114 insertions(+), 10 deletions(-) diff --git a/dGame/dComponents/ActivityComponent.cpp b/dGame/dComponents/ActivityComponent.cpp index a3a25082..9f256a3e 100644 --- a/dGame/dComponents/ActivityComponent.cpp +++ b/dGame/dComponents/ActivityComponent.cpp @@ -28,8 +28,11 @@ #include "CDActivitiesTable.h" #include "LeaderboardManager.h" #include "CharacterComponent.h" +#include "Amf3.h" ActivityComponent::ActivityComponent(Entity* parent, int32_t activityID) : Component(parent) { + using namespace GameMessages; + RegisterMsg(this, &ActivityComponent::OnGetObjectReportInfo); /* * This is precisely what the client does functionally * Use the component id as the default activity id and load its data from the database @@ -348,14 +351,13 @@ bool ActivityComponent::CheckCost(Entity* player) const { return true; } -bool ActivityComponent::TakeCost(Entity* player) const{ - +bool ActivityComponent::TakeCost(Entity* player) const { + auto* inventoryComponent = player->GetComponent(); if (CheckCost(player)) { inventoryComponent->RemoveItem(m_ActivityInfo.optionalCostLOT, m_ActivityInfo.optionalCostCount); return true; - } - else return false; + } else return false; } void ActivityComponent::PlayerReady(Entity* player, bool bReady) { @@ -618,3 +620,91 @@ void ActivityInstance::SetScore(uint32_t score) { Entity* LobbyPlayer::GetEntity() const { return Game::entityManager->GetEntity(entityID); } + +bool ActivityComponent::OnGetObjectReportInfo(GameMessages::GameMsg& msg) { + auto& reportInfo = static_cast(msg); + + auto& activityInfo = reportInfo.info->PushDebug("Activity"); + + auto& instances = activityInfo.PushDebug("Instances: " + std::to_string(m_Instances.size())); + size_t i = 0; + for (const auto& activityInstance : m_Instances) { + if (!activityInstance) continue; + auto& instance = instances.PushDebug("Instance " + std::to_string(i++)); + instance.PushDebug("Score") = activityInstance->GetScore(); + instance.PushDebug("Next Zone Clone ID") = activityInstance->GetNextZoneCloneID(); + + { + auto& activityInfo = instance.PushDebug("Activity Info"); + const auto& instanceActInfo = activityInstance->GetActivityInfo(); + activityInfo.PushDebug("ActivityID") = instanceActInfo.ActivityID; + activityInfo.PushDebug("locStatus") = instanceActInfo.locStatus; + activityInfo.PushDebug("instanceMapID") = instanceActInfo.instanceMapID; + activityInfo.PushDebug("minTeams") = instanceActInfo.minTeams; + activityInfo.PushDebug("maxTeams") = instanceActInfo.maxTeams; + activityInfo.PushDebug("minTeamSize") = instanceActInfo.minTeamSize; + activityInfo.PushDebug("maxTeamSize") = instanceActInfo.maxTeamSize; + activityInfo.PushDebug("waitTime") = instanceActInfo.waitTime; + activityInfo.PushDebug("startDelay") = instanceActInfo.startDelay; + activityInfo.PushDebug("requiresUniqueData") = instanceActInfo.requiresUniqueData; + activityInfo.PushDebug("leaderboardType") = instanceActInfo.leaderboardType; + activityInfo.PushDebug("localize") = instanceActInfo.localize; + activityInfo.PushDebug("optionalCostLOT") = instanceActInfo.optionalCostLOT; + activityInfo.PushDebug("optionalCostCount") = instanceActInfo.optionalCostCount; + activityInfo.PushDebug("showUIRewards") = instanceActInfo.showUIRewards; + activityInfo.PushDebug("CommunityActivityFlagID") = instanceActInfo.CommunityActivityFlagID; + activityInfo.PushDebug("gate_version") = instanceActInfo.gate_version; + activityInfo.PushDebug("noTeamLootOnDeath") = instanceActInfo.noTeamLootOnDeath; + activityInfo.PushDebug("optionalPercentage") = instanceActInfo.optionalPercentage; + } + + auto& participants = instance.PushDebug("Participants"); + for (const auto* participant : activityInstance->GetParticipants()) { + if (!participant) continue; + auto* character = participant->GetCharacter(); + if (!character) continue; + participants.PushDebug(std::to_string(participant->GetObjectID()) + ": " + character->GetName()) = ""; + } + } + + auto& queue = activityInfo.PushDebug("Queue"); + i = 0; + for (const auto& lobbyQueue : m_Queue) { + auto& lobby = queue.PushDebug("Lobby " + std::to_string(i++)); + lobby.PushDebug("Timer") = lobbyQueue->timer; + + auto& players = lobby.PushDebug("Players"); + for (const auto* player : lobbyQueue->players) { + if (!player) continue; + auto* playerEntity = player->GetEntity(); + if (!playerEntity) continue; + auto* character = playerEntity->GetCharacter(); + if (!character) continue; + + players.PushDebug(std::to_string(playerEntity->GetObjectID()) + ": " + character->GetName()) = player->ready ? "Ready" : "Not Ready"; + } + } + + auto& activityPlayers = activityInfo.PushDebug("Activity Players"); + for (const auto* activityPlayer : m_ActivityPlayers) { + if (!activityPlayer) continue; + auto* const activityPlayerEntity = Game::entityManager->GetEntity(activityPlayer->playerID); + if (!activityPlayerEntity) continue; + auto* character = activityPlayerEntity->GetCharacter(); + if (!character) continue; + + auto& playerData = activityPlayers.PushDebug(std::to_string(activityPlayer->playerID) + " " + character->GetName()); + + auto& scores = playerData.PushDebug("Scores"); + for (size_t i = 0; i < 10; ++i) { + scores.PushDebug(std::to_string(i)) = activityPlayer->values[i]; + } + } + + auto& lootMatrices = activityInfo.PushDebug("Loot Matrices"); + for (const auto& [activityRating, lootMatrixID] : m_ActivityLootMatrices) { + lootMatrices.PushDebug("Loot Matrix " + std::to_string(activityRating)) = lootMatrixID; + } + activityInfo.PushDebug("ActivityID") = m_ActivityID; + return true; +} diff --git a/dGame/dComponents/ActivityComponent.h b/dGame/dComponents/ActivityComponent.h index ec482a42..925b3a8d 100644 --- a/dGame/dComponents/ActivityComponent.h +++ b/dGame/dComponents/ActivityComponent.h @@ -9,6 +9,10 @@ #include "CDActivitiesTable.h" +namespace GameMessages { + class GameMsg; +}; + /** * Represents an instance of an activity, having participants and score */ @@ -60,6 +64,10 @@ public: * Currently unused */ void SetScore(uint32_t score); + + [[nodiscard]] uint32_t GetNextZoneCloneID() const noexcept { return m_NextZoneCloneID; } + + const CDActivities& GetActivityInfo() const noexcept { return m_ActivityInfo; } private: /** @@ -75,12 +83,12 @@ private: /** * The database information for this activity */ - CDActivities m_ActivityInfo; + CDActivities m_ActivityInfo{}; /** * The entity that owns this activity (the entity that has the ScriptedActivityComponent) */ - Entity* m_Parent; + Entity* m_Parent{}; /** * All the participants of this activity @@ -341,6 +349,7 @@ public: uint32_t GetLootMatrixForTeamSize(uint32_t teamSize) { return m_ActivityLootMatrices[teamSize]; } private: + bool OnGetObjectReportInfo(GameMessages::GameMsg& msg); /** * The database information for this activity */ diff --git a/dGame/dComponents/ControllablePhysicsComponent.cpp b/dGame/dComponents/ControllablePhysicsComponent.cpp index ccc5a7e2..09028fd8 100644 --- a/dGame/dComponents/ControllablePhysicsComponent.cpp +++ b/dGame/dComponents/ControllablePhysicsComponent.cpp @@ -385,16 +385,19 @@ bool ControllablePhysicsComponent::OnGetObjectReportInfo(GameMessages::GameMsg& info.PushDebug("Is Static") = m_Static; auto& pickupRadii = info.PushDebug("Active Pickup Radius Scales"); + + size_t i = 0; for (const auto& scale : m_ActivePickupRadiusScales) { - pickupRadii.PushDebug(std::to_string(scale)) = ""; + pickupRadii.PushDebug(std::to_string(i++) + " " + std::to_string(scale)) = ""; } info.PushDebug("Largest Pickup Radius") = m_PickupRadius; info.PushDebug("Is Teleporting") = m_IsTeleporting; auto& activeSpeedBoosts = info.PushDebug("Active Speed Boosts"); + i = 0; for (const auto& boost : m_ActiveSpeedBoosts) { - activeSpeedBoosts.PushDebug(std::to_string(boost)) = ""; + activeSpeedBoosts.PushDebug(std::to_string(i++) + " " + std::to_string(boost)) = ""; } info.PushDebug("Speed Boost") = m_SpeedBoost; diff --git a/dGame/dComponents/DestroyableComponent.cpp b/dGame/dComponents/DestroyableComponent.cpp index d1356b48..4c0e75bd 100644 --- a/dGame/dComponents/DestroyableComponent.cpp +++ b/dGame/dComponents/DestroyableComponent.cpp @@ -1052,12 +1052,14 @@ bool DestroyableComponent::OnGetObjectReportInfo(GameMessages::GameMsg& msg) { destroyableInfo.PushDebug("Attacks To Block") = m_AttacksToBlock; destroyableInfo.PushDebug("Damage Reduction") = m_DamageReduction; auto& factions = destroyableInfo.PushDebug("Factions"); + size_t i = 0; for (const auto factionID : m_FactionIDs) { - factions.PushDebug(std::to_string(factionID)) = ""; + factions.PushDebug(std::to_string(i++) + " " + std::to_string(factionID)) = ""; } auto& enemyFactions = destroyableInfo.PushDebug("Enemy Factions"); + i = 0; for (const auto enemyFactionID : m_EnemyFactionIDs) { - enemyFactions.PushDebug(std::to_string(enemyFactionID)) = ""; + enemyFactions.PushDebug(std::to_string(i++) + " " + std::to_string(enemyFactionID)) = ""; } destroyableInfo.PushDebug("Is Smashable") = m_IsSmashable; destroyableInfo.PushDebug("Is Dead") = m_IsDead;