t7x/src/client/component/branding.cpp

97 lines
2.7 KiB
C++
Raw Normal View History

2022-09-16 14:55:36 -04:00
#include <std_include.hpp>
#include "loader/component_loader.hpp"
#include "game/game.hpp"
#include "version.hpp"
2022-09-16 14:55:36 -04:00
2022-09-17 08:51:34 -04:00
#include "scheduler.hpp"
2022-09-16 14:55:36 -04:00
#include <utils/hook.hpp>
2022-10-17 14:09:13 -04:00
#include "utils/string.hpp"
2022-09-16 14:55:36 -04:00
namespace branding
{
namespace
{
2022-10-17 14:09:13 -04:00
std::map<int, std::string> connectivity_bits = {
{0x10000000, "???"},
{0x01000000, "LiveInventory_IsValid"},
{0x02000000, "LiveStorage_AreDDLsInSync"},
{0x04000000, "LiveInventory_InitialCODPointsChecked"},
{0x08000000, "Marketing_HaveMessages"},
{0x00100000, "LivePublisherVariables_AreVariablesAvailable"},
{0x00200000, "SaveGame_IsDataReady(controllerIndex, MODE_NETWORK_ONLINE)"},
{0x00400000, "LPC_IsLPCReady() || !Dvar_GetBool(live_useLPC)"},
{0x00800000, "LiveAntiCheat_ConsoleDetailsReported"},
{0x00010000, "Live_Qos_Finished"},
{0x00080000, "???"},
{0x00002000, "Live_IsGeoLocationDataRetrieved"},
{0x00000100, "LiveStorage_DoWeHavePlaylists"},
{0x00000200, "LiveStorage_ValidateFFOTD"},
{0x00000010, "LiveStats_Loadouts_Ready(controllerIndex, MODE_NETWORK_ONLINE)"},
{0x00000040, "g_dwNetStatus == 6"},
{0x00000080, "LiveStorage_DoWeHaveFFOTD"},
{0x00000002, "LiveUser_IsUserSignedInToLive"},
{0x00000004, "Live_IsUserSignedInToDemonware"},
{0x00000008, "LiveStats_Core_Ready(controllerIndex, MODE_NETWORK_ONLINE)"},
};
2022-10-17 14:17:41 -04:00
std::string get_connectivity_info()
2022-10-17 14:09:13 -04:00
{
int bits = 0;
game::Live_GetConnectivityInformation(0, &bits, false);
std::string str = utils::string::va("Bits: %X\n", bits);
int required_mask = 0x1FF923DE;
for (int i = 0; (1 << i) <= 0x10000000; ++i)
{
auto value = 1 << i;
2022-10-17 14:17:41 -04:00
const bool set = bits & value;
const bool req = required_mask & value;
2022-10-17 14:09:13 -04:00
if (!req) continue;
std::string name = "?";
auto entry = connectivity_bits.find(value);
if (entry != connectivity_bits.end())
{
name = entry->second;
}
2022-10-17 14:17:41 -04:00
str += utils::string::va("%08X - %d - %s\n", value, static_cast<int>(set), name.data());
2022-10-17 14:09:13 -04:00
}
return str;
}
2022-09-16 14:55:36 -04:00
void draw_branding()
{
constexpr auto x = 4;
2022-09-17 03:16:24 -04:00
constexpr auto y = 0;
2022-09-18 02:33:11 -04:00
constexpr auto scale = 0.45f;
2022-10-17 15:01:21 -04:00
float color[4] = {0.666f, 0.666f, 0.666f, 0.666f};
2022-09-16 14:55:36 -04:00
auto* font = reinterpret_cast<uint32_t*(*)()>(0x141CAC8E0_g)();
if (!font) return;
2022-10-17 14:09:13 -04:00
std::string str = "BOIII: " VERSION;
2022-10-17 14:17:41 -04:00
//str += "\n\n" + get_connectivity_info();
game::R_AddCmdDrawText(str.data(), std::numeric_limits<int>::max(), font, static_cast<float>(x),
2022-09-16 14:55:36 -04:00
y + static_cast<float>(font[2]) * scale,
2022-10-17 15:01:21 -04:00
scale, scale, 0.0f, color, game::ITEM_TEXTSTYLE_NORMAL);
2022-09-16 14:55:36 -04:00
}
}
class component final : public component_interface
{
public:
void post_unpack() override
{
2022-09-17 08:51:34 -04:00
scheduler::loop(draw_branding, scheduler::renderer);
2022-09-16 14:55:36 -04:00
}
};
}
REGISTER_COMPONENT(branding::component)