-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
795f2b4
commit 9721a7e
Showing
5 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
#include "httplib.h" | ||
#include <DaybreakModule.h> | ||
#include <payloads/DebugPayload.h> | ||
|
||
namespace Daybreak::Modules { | ||
class DebugModule : public DaybreakModule<DebugPayload, uint32_t> { | ||
public: | ||
std::string ApiUri() override; | ||
protected: | ||
std::optional<uint32_t> GetContext(const httplib::Request& req, httplib::Response& res) override; | ||
std::optional<DebugPayload> GetPayload(uint32_t context) override; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
#include <cstdint> | ||
#include <GWCA/GameEntities/Map.h> | ||
#include <json.hpp> | ||
#include <payloads/MainPlayer.h> | ||
#include <payloads/MapIcon.h> | ||
|
||
using json = nlohmann::json; | ||
|
||
namespace Daybreak { | ||
struct DebugPayload { | ||
std::string GameContextAddress; | ||
std::string WorldContextAddress; | ||
std::string AgentContextAddress; | ||
std::string MapContextAddress; | ||
std::string CharContextAddress; | ||
}; | ||
|
||
void to_json(json& j, const DebugPayload& p); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include "pch.h" | ||
#include "DebugModule.h" | ||
#include "payloads/DebugPayload.h" | ||
#include <GWCA/GWCA.h> | ||
#include <GWCA/Context/GameContext.h> | ||
|
||
namespace Daybreak::Modules { | ||
std::string DebugModule::ApiUri() | ||
{ | ||
return "/debug"; | ||
} | ||
|
||
std::optional<uint32_t> DebugModule::GetContext(const httplib::Request& req, httplib::Response& res) | ||
{ | ||
return 0; | ||
} | ||
|
||
std::optional<DebugPayload> DebugModule::GetPayload(const uint32_t) | ||
{ | ||
char buffer[20]; | ||
DebugPayload debugPayload; | ||
const auto gameContext = GW::GetGameContext(); | ||
std::sprintf(buffer, "%p", static_cast<void*>(gameContext)); | ||
debugPayload.GameContextAddress = std::string(buffer); | ||
std::sprintf(buffer, "%p", static_cast<void*>(gameContext->agent)); | ||
debugPayload.AgentContextAddress = std::string(buffer); | ||
std::sprintf(buffer, "%p", static_cast<void*>(gameContext->character)); | ||
debugPayload.CharContextAddress = std::string(buffer); | ||
std::sprintf(buffer, "%p", static_cast<void*>(gameContext->world)); | ||
debugPayload.WorldContextAddress = std::string(buffer); | ||
std::sprintf(buffer, "%p", static_cast<void*>(gameContext->map)); | ||
debugPayload.MapContextAddress = std::string(buffer); | ||
|
||
return debugPayload; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <cstdint> | ||
#include <json.hpp> | ||
#include <payloads/DebugPayload.h> | ||
|
||
using json = nlohmann::json; | ||
|
||
namespace Daybreak { | ||
void to_json(json& j, const DebugPayload& p) { | ||
j = json | ||
{ | ||
{"GameContextAddress", p.GameContextAddress}, | ||
{"WorldContextAddress", p.WorldContextAddress}, | ||
{"MapContextAddress", p.MapContextAddress}, | ||
{"AgentContextAddress", p.AgentContextAddress}, | ||
{"CharContextAddress", p.CharContextAddress}, | ||
}; | ||
} | ||
} |