From 026d199e615b66f889b7f44b1c1d8d7d2c1bb282 Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Sat, 27 Apr 2024 18:21:27 +0800 Subject: [PATCH] [server] Implement and match `n_GetVehiclePoolSize(...)` --- server/netgame.h | 1 + server/scrcustom.cpp | 10 ++++++++-- server/vehiclepool.cpp | 2 +- server/vehiclepool.h | 4 +++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/server/netgame.h b/server/netgame.h index 8f1465e..e790cc9 100644 --- a/server/netgame.h +++ b/server/netgame.h @@ -78,6 +78,7 @@ public: CPlayerPool * GetPlayerPool() { return m_pPlayerPool; }; + CVehiclePool * GetVehiclePool() { return m_pVehiclePool; }; RakServerInterface * GetRakServer() { return m_pRak; }; CGameMode * GetGameMode() { return m_pGameMode; }; CFilterScripts * GetFilterScripts() { return m_pFilterScripts; }; diff --git a/server/scrcustom.cpp b/server/scrcustom.cpp index 62beff7..0bf9a1a 100644 --- a/server/scrcustom.cpp +++ b/server/scrcustom.cpp @@ -21,10 +21,16 @@ static cell AMX_NATIVE_CALL n_GetPlayerPoolSize(AMX *amx, cell *params) return -1; } +//---------------------------------------------------------------------------------- +// native GetVehiclePoolSize() static cell AMX_NATIVE_CALL n_GetVehiclePoolSize(AMX *amx, cell *params) { - // TODO: GetVehiclePoolSize - return 0; + if(!pNetGame) return -1; + CVehiclePool *pVehiclePool = pNetGame->GetVehiclePool(); + if(pVehiclePool) { + return pVehiclePool->GetPoolSize(); + } + return -1; } static cell AMX_NATIVE_CALL n_GetActorPoolSize(AMX *amx, cell *params) diff --git a/server/vehiclepool.cpp b/server/vehiclepool.cpp index bf21855..496c5ea 100644 --- a/server/vehiclepool.cpp +++ b/server/vehiclepool.cpp @@ -9,7 +9,7 @@ CVehiclePool::CVehiclePool() field_D4[VehicleID] = 0; } memset(field_0,0,sizeof(field_0)); - field_5E94 = 0; + m_iPoolSize = 0; } CVehiclePool::~CVehiclePool() diff --git a/server/vehiclepool.h b/server/vehiclepool.h index 5192ad1..ec0c2de 100644 --- a/server/vehiclepool.h +++ b/server/vehiclepool.h @@ -9,7 +9,7 @@ private: int field_D4[2000]; int field_2014[2000]; int field_3F54[2000]; - int field_5E94; + int m_iPoolSize; public: CVehiclePool(); @@ -18,6 +18,8 @@ public: BOOL Delete(VEHICLEID VehicleID); int GetModelCount(); + + int GetPoolSize() { return m_iPoolSize; }; }; #endif