This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
YimMenu/src/hooks/protections/update_presence_attribute.cpp
Andreas Maerten e07601347d
refactor: switch RAGE_JOAAT with string literal functions (#2806)
Why? Shorter to write and removes the macro usage

I used the following regex to find all occurrences:
```r
RAGE_JOAAT\("(.*?)"\)
```
then the following to replace it all:
```r
"$1"_J
```
2024-03-12 09:42:11 +01:00

39 lines
1.1 KiB
C++

#include "hooking/hooking.hpp"
#include "services/player_database/player_database_service.hpp"
namespace big
{
inline bool block_session_presence()
{
return g.protections.rid_join || (g_player_database_service && g_player_database_service->is_redirect_join_active());
}
bool hooks::update_presence_attribute_int(void* presence_data, int profile_index, char* attr, uint64_t value)
{
auto hash = rage::joaat(attr);
if (block_session_presence() && (hash == "gstok"_J || hash == "gsid"_J || hash == "gstype"_J || hash == "gshost"_J || hash == "gsjoin"_J))
{
return true;
}
return g_hooking->get_original<hooks::update_presence_attribute_int>()(presence_data, profile_index, attr, value);
}
bool hooks::update_presence_attribute_string(void* presence_data, int profile_index, char* attr, char* value)
{
auto hash = rage::joaat(attr);
if (block_session_presence() && hash == "gsinfo"_J)
{
return true;
}
// shouldn't have any side effects
if (hash == "peeraddr"_J)
{
value = (char*)"";
}
return g_hooking->get_original<hooks::update_presence_attribute_string>()(presence_data, profile_index, attr, value);
}
}