Added formatting to money on HUD. (#2957)
This commit is contained in:
parent
e887ac2eba
commit
b1bf477d1f
@ -366,6 +366,8 @@ namespace big
|
||||
CWeaponInfoManager* m_weapon_info_manager;
|
||||
|
||||
functions::can_create_vehicle m_can_create_vehicle;
|
||||
|
||||
PVOID m_format_int;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
static_assert(sizeof(gta_pointers) % 8 == 0, "Pointers are not properly aligned");
|
||||
|
@ -142,6 +142,8 @@ namespace big
|
||||
|
||||
detour_hook_helper::add<hooks::can_create_vehicle>("CCV", g_pointers->m_gta.m_can_create_vehicle);
|
||||
|
||||
detour_hook_helper::add<hooks::format_int>("FI", g_pointers->m_gta.m_format_int);
|
||||
|
||||
g_hooking = this;
|
||||
}
|
||||
|
||||
|
@ -193,6 +193,8 @@ namespace big
|
||||
static bool sync_reader_serialize_array(void* _this, void* array, int size);
|
||||
|
||||
static bool can_create_vehicle();
|
||||
|
||||
static void format_int(int64_t integer_to_format, char* format_string, size_t size_always_64, bool use_commas);
|
||||
};
|
||||
|
||||
class minhook_keepalive
|
||||
|
26
src/hooks/misc/format_int.cpp
Normal file
26
src/hooks/misc/format_int.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include "hooking/hooking.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
static inline std::string format_money(int64_t amount)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss.imbue(std::locale(""));
|
||||
ss << "$" << std::put_money(static_cast<long double>(amount) * 100, false);
|
||||
std::string money = ss.str();
|
||||
return money.substr(0, money.size() - 3);
|
||||
}
|
||||
|
||||
void hooks::format_int(int64_t integer_to_format, char* format_string, size_t size_always_64, bool use_commas)
|
||||
{
|
||||
auto return_address = _ReturnAddress();
|
||||
auto return_bytes = static_cast<unsigned char*>(return_address);
|
||||
if (return_bytes[0] == 0x48 && return_bytes[1] == 0x8D && return_bytes[2] == 0x15) //lea rdx, aHcGreenlightFo ; "~HC_GREENLIGHT~ <font size='20'>"
|
||||
{
|
||||
auto money_format = format_money(integer_to_format);
|
||||
std::strcpy(format_string, money_format.c_str());
|
||||
return;
|
||||
}
|
||||
g_hooking->get_original<format_int>()(integer_to_format, format_string, size_always_64, use_commas);
|
||||
}
|
||||
}
|
@ -1772,6 +1772,15 @@ namespace big
|
||||
{
|
||||
g_pointers->m_gta.m_can_create_vehicle = ptr.as<functions::can_create_vehicle>();
|
||||
}
|
||||
},
|
||||
// Format Integer
|
||||
{
|
||||
"FI",
|
||||
"48 83 EC ? 44 88 4C 24",
|
||||
[](memory::handle ptr)
|
||||
{
|
||||
g_pointers->m_gta.m_format_int = ptr.as<PVOID>();
|
||||
}
|
||||
}
|
||||
>(); // don't leave a trailing comma at the end
|
||||
|
||||
|
Reference in New Issue
Block a user