Refactored writing RandomID into a set that's locally tracked by the user. (#2376)

This commit is contained in:
gir489 2023-11-03 13:34:22 -04:00 committed by GitHub
parent d64afe65db
commit 7e6c6367b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 3 deletions

View File

@ -36,6 +36,7 @@
#include <utility>
#include <set>
#include <unordered_set>
#include <stack>
#include <vector>
@ -83,6 +84,7 @@ namespace self
inline Vector3 rot;
inline Vehicle veh;
inline int char_index;
inline std::unordered_set<int> spawned_vehicles;
}
template<size_t N>

View File

@ -26,6 +26,7 @@ namespace big
void hooks::network_player_mgr_shutdown(CNetworkPlayerMgr* _this)
{
g_player_service->do_cleanup();
self::spawned_vehicles.clear();
if (g.notifications.network_player_mgr_shutdown.log)
LOG(INFO) << "CNetworkPlayerMgr#shutdown got called, we're probably leaving our session.";

View File

@ -507,7 +507,7 @@ namespace big
Vehicle veh = g_pointers->m_gta.m_ptr_to_handle(g_local_player->m_vehicle);
if (!NETWORK::NETWORK_IS_ACTIVITY_SESSION() //If we're in Freemode.
|| personal_vehicle == veh //Or we're in our personal vehicle.
|| DECORATOR::DECOR_GET_INT(veh, "RandomId") == g_local_player->m_net_object->m_object_id) // Or it's a vehicle we spawned.
|| self::spawned_vehicles.contains(net_id)) // Or it's a vehicle we spawned.
{
g_pointers->m_gta.m_send_event_ack(event_manager, source_player, target_player, event_index, event_handled_bitset); // Tell them to get bent.
g.reactions.request_control_event.process(plyr);

View File

@ -46,10 +46,10 @@ namespace big::vehicle
void set_mp_bitset(Vehicle veh)
{
DECORATOR::DECOR_SET_INT(veh, "MPBitset", 0);
DECORATOR::DECOR_SET_INT(veh, "RandomId", g_local_player->m_net_object->m_object_id);
auto networkId = NETWORK::VEH_TO_NET(veh);
self::spawned_vehicles.insert(networkId);
if (NETWORK::NETWORK_GET_ENTITY_IS_NETWORKED(veh))
NETWORK::SET_NETWORK_ID_EXISTS_ON_ALL_MACHINES(networkId, true);
NETWORK::SET_NETWORK_ID_EXISTS_ON_ALL_MACHINES(networkId, TRUE);
VEHICLE::SET_VEHICLE_IS_STOLEN(veh, FALSE);
}