debug stuff

This commit is contained in:
David Markowitz
2025-01-20 19:20:58 -08:00
parent af2ba5b287
commit 60971409c1
10 changed files with 93 additions and 18 deletions

View File

@@ -49,19 +49,13 @@ CharacterComponent::CharacterComponent(Entity* parent, Character* character, con
m_LastUpdateTimestamp = std::time(nullptr);
m_SystemAddress = systemAddress;
RegisterMsg(MessageType::Game::REQUEST_SERVER_OBJECT_INFO, this, &CharacterComponent::OnRequestServerObjectInfo);
RegisterMsg(MessageType::Game::GET_OBJECT_REPORT_INFO, this, &CharacterComponent::OnGetObjectReportInfo);
}
bool CharacterComponent::OnRequestServerObjectInfo(GameMessages::GameMsg& msg) {
auto& request = static_cast<GameMessages::RequestServerObjectInfo&>(msg);
AMFArrayValue response;
bool CharacterComponent::OnGetObjectReportInfo(GameMessages::GameMsg& msg) {
auto& request = static_cast<GameMessages::GetObjectReportInfo&>(msg);
response.Insert("visible", true);
response.Insert("objectID", std::to_string(request.targetForReport));
response.Insert("serverInfo", true);
auto& data = *response.InsertArray("data");
auto& cmptType = data.PushDebug("Character");
auto& cmptType = request.info->PushDebug("Character");
cmptType.PushDebug<AMFIntValue>("Component ID") = GeneralUtils::ToUnderlying(ComponentType);
cmptType.PushDebug<AMFIntValue>("Character's account ID") = m_Character->GetParentUser()->GetAccountID();
@@ -83,9 +77,6 @@ bool CharacterComponent::OnRequestServerObjectInfo(GameMessages::GameMsg& msg) {
cmptType.PushDebug<AMFIntValue>("Current Activity Type") = GeneralUtils::ToUnderlying(m_CurrentActivity);
cmptType.PushDebug<AMFDoubleValue>("Property Clone ID") = m_Character->GetPropertyCloneID();
GameMessages::SendUIMessageServerToSingleClient("ToggleObjectDebugger", response, m_Parent->GetSystemAddress());
LOG("Handled!");
return true;
}

View File

@@ -323,7 +323,7 @@ public:
Character* m_Character;
private:
bool OnRequestServerObjectInfo(GameMessages::GameMsg& msg);
bool OnGetObjectReportInfo(GameMessages::GameMsg& msg);
/**
* The map of active venture vision effects

View File

@@ -6,17 +6,18 @@
#include "ePlayerFlag.h"
#include "MissionComponent.h"
#include "Amf3.h"
FlagComponent::FlagComponent(Entity* parent) : Component(parent) {
RegisterMsg(MessageType::Game::SET_FLAG, this, &FlagComponent::OnSetFlag);
RegisterMsg(MessageType::Game::GET_FLAG, this, &FlagComponent::OnGetFlag);
RegisterMsg(MessageType::Game::CLEAR_SESSION_FLAGS, this, &FlagComponent::OnClearSessionFlags);
RegisterMsg(MessageType::Game::SET_RETROACTIVE_FLAGS, this, &FlagComponent::OnSetRetroactiveFlags);
RegisterMsg(MessageType::Game::GET_OBJECT_REPORT_INFO, this, &FlagComponent::OnGetObjectReportInfo);
}
bool FlagComponent::OnSetFlag(GameMessages::GameMsg& msg) {
auto& setFlag = static_cast<GameMessages::SetFlag&>(msg);
LOG("Set %i", setFlag.iFlagId);
SetPlayerFlag(setFlag.iFlagId, setFlag.bFlag);
// This is always set the first time a player loads into a world from character select
@@ -30,8 +31,6 @@ bool FlagComponent::OnSetFlag(GameMessages::GameMsg& msg) {
bool FlagComponent::OnGetFlag(GameMessages::GameMsg& msg) {
auto& getFlag = static_cast<GameMessages::GetFlag&>(msg);
LOG("Get %i", getFlag.iFlagId);
getFlag.bFlag = GetPlayerFlag(getFlag.iFlagId);
return true;
}
@@ -181,6 +180,30 @@ bool FlagComponent::OnSetRetroactiveFlags(GameMessages::GameMsg& msg) {
return true;
}
bool FlagComponent::OnGetObjectReportInfo(GameMessages::GameMsg& msg) {
auto& request = static_cast<GameMessages::GetObjectReportInfo&>(msg);
auto& cmptType = request.info->PushDebug("Player Flag");
cmptType.PushDebug<AMFIntValue>("Component ID") = GeneralUtils::ToUnderlying(ComponentType);
auto& allFlags = cmptType.PushDebug("All flags");
for (const auto& [id, flagChunk] : m_PlayerFlags) {
const auto base = id * 64;
auto flagChunkCopy = flagChunk;
for (int i = 0; i < 64; i++) {
if (static_cast<bool>(flagChunkCopy & 1)) {
const int32_t flagId = base + i;
std::stringstream stream;
stream << "Flag: " << flagId;
allFlags.PushDebug(stream.str().c_str());
}
flagChunkCopy >>= 1;
}
}
return true;
}
void FlagComponent::ClearSessionFlags(tinyxml2::XMLDocument& doc) {
if (!doc.FirstChildElement("obj")) return;
auto& obj = *doc.FirstChildElement("obj");

View File

@@ -44,6 +44,9 @@ private:
* missing in a previous patch.
*/
bool OnSetRetroactiveFlags(GameMessages::GameMsg& msg);
bool OnGetObjectReportInfo(GameMessages::GameMsg& msg);
/**
* Flags only set for the duration of a session
*