From 8154fb5da2cc44ba2daa733ba88545bc3c204978 Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Wed, 21 Aug 2024 23:23:07 +0800 Subject: [PATCH] [saco] Implement/match CPickupPool destructor * Update CPickupPool constructor --- saco/game/scripting.h | 2 ++ saco/net/pickuppool.cpp | 16 +++++++++++++++- saco/net/pickuppool.h | 3 ++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/saco/game/scripting.h b/saco/game/scripting.h index 404904b..f6aac63 100644 --- a/saco/game/scripting.h +++ b/saco/game/scripting.h @@ -90,6 +90,8 @@ const SCRIPT_COMMAND text_clear_all = { 0x00be, "" }; const SCRIPT_COMMAND create_pickup_with_ammo = { 0x032b, "iiifffv" }; +const SCRIPT_COMMAND destroy_pickup = { 0x0215, "i" }; + const SCRIPT_COMMAND link_vehicle_to_interior = { 0x0840, "ii" }; const SCRIPT_COMMAND create_radar_marker_icon = { 0x0570, "fffiv" }; diff --git a/saco/net/pickuppool.cpp b/saco/net/pickuppool.cpp index 9eb3ba2..a9b4dad 100644 --- a/saco/net/pickuppool.cpp +++ b/saco/net/pickuppool.cpp @@ -9,10 +9,24 @@ CPickupPool::CPickupPool() field_0 = 0; for (int i = 0; i < MAX_PICKUPS; i++) { - field_4[i] = 0; + m_dwHnd[i] = NULL; field_8004[i] = 0; field_4004[i] = -1; } } //---------------------------------------------------- + +CPickupPool::~CPickupPool() +{ + for(int i = 0; i < MAX_PICKUPS; i++) + { + if (m_dwHnd[i] != NULL) + { + ScriptCommand(&destroy_pickup, m_dwHnd[i]); + } + } +} + +//---------------------------------------------------- + diff --git a/saco/net/pickuppool.h b/saco/net/pickuppool.h index 91caf66..696c9e6 100644 --- a/saco/net/pickuppool.h +++ b/saco/net/pickuppool.h @@ -10,7 +10,7 @@ class CPickupPool private: int field_0; - int field_4[MAX_PICKUPS]; + DWORD m_dwHnd[MAX_PICKUPS]; int field_4004[MAX_PICKUPS]; int field_8004[MAX_PICKUPS]; @@ -21,6 +21,7 @@ private: public: CPickupPool(); + ~CPickupPool(); };