Refactored writing RandomID into a set that's locally tracked by the user. (#2376)
This commit is contained in:
parent
d64afe65db
commit
7e6c6367b1
@ -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>
|
||||
|
@ -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.";
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user