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/send_non_physical_player_data.cpp
Andreas Maerten cba19d0c33
refactor!: Rewrite of the old notification service (#2866)
The main goal was improving the readability of the original code however some ugliness remains.

- Swapped from pointer singleton to instance singleton
- Actually make use of the alpha logic that used to be present
- Added a counter to notifications to indicate if something is being spammed
- Notification timeouts reset if they're sent to the queue again
2024-03-23 00:04:49 +01:00

29 lines
943 B
C++

#include "hooking/hooking.hpp"
#include "pointers.hpp"
#include "services/players/player_service.hpp"
#include <network/CNetGamePlayer.hpp>
#include <player/CNonPhysicalPlayerData.hpp>
namespace big
{
bool hooks::send_non_physical_player_data(CNetGamePlayer* player, __int64 message, int flags, void* a4, CNetGamePlayer* a5)
{
auto plyr = g_player_service->get_by_id(player->m_player_id);
auto data = *(CNonPhysicalPlayerData**)(message + 0x10);
int old_bubble_id = data->m_bubble_id;
if (plyr && plyr->block_join && *g_pointers->m_gta.m_is_session_started)
{
data->m_bubble_id = 10;
g_notification_service.push("BLOCK_JOIN"_T.data(), std::vformat("BLOCK_JOIN_PREVENT_PLAYER_JOIN"_T, std::make_format_args(plyr->get_name())));
}
bool result = g_hooking->get_original<hooks::send_non_physical_player_data>()(player, message, flags, a4, a5);
data->m_bubble_id = old_bubble_id;
return result;
}
}