From 01fd323e8dbeac597fed56412891c32ce55c187c Mon Sep 17 00:00:00 2001 From: ricardoofnl Date: Fri, 4 Sep 2026 21:55:56 +0700 Subject: [PATCH] [saco] Implement/match `CVehiclePool::FUNC_1001ED10`; the waiting slots are 100 forty byte entries and the scan must be a `do`/`while(i != n)` --- saco/net/vehiclepool.cpp | 21 +++++++++++++++++++++ saco/net/vehiclepool.h | 15 +++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/saco/net/vehiclepool.cpp b/saco/net/vehiclepool.cpp index a82bb06..78b48a9 100644 --- a/saco/net/vehiclepool.cpp +++ b/saco/net/vehiclepool.cpp @@ -2,6 +2,7 @@ #include "../main.h" #include "../game/util.h" +extern CChatWindow *pChatWindow; extern int dword_1026EBA0; // same layout as the camera collision points that game/hooks.cpp passes around @@ -24,6 +25,8 @@ public: // layout locks: these fail to compile if a field offset or the size moves typedef char chk_CVehiclePool_size[sizeof(CVehiclePool) == 0x17898 ? 1 : -1]; +typedef char chk_VEHICLE_WAITING_size[sizeof(VEHICLE_WAITING) == 40 ? 1 : -1]; +typedef char chk_field_4[offsetof(CVehiclePool, field_4) == 4 ? 1 : -1]; typedef char chk_field_FA4[offsetof(CVehiclePool, field_FA4) == 0xFA4 ? 1 : -1]; typedef char chk_field_1134[offsetof(CVehiclePool, field_1134) == 0x1134 ? 1 : -1]; typedef char chk_field_3074[offsetof(CVehiclePool, field_3074) == 0x3074 ? 1 : -1]; @@ -273,3 +276,21 @@ short CVehiclePool::FUNC_1001EF30(float fMaxDistance, VECTOR *vecStart, VECTOR * } //---------------------------------------------------- + +int CVehiclePool::FUNC_1001ED10(VEHICLE_WAITING *pWaiting) +{ + // do/while with a `!=` bound, a for or while here gets unrolled or rotated + int i = 0; + do { + if(!field_FA4[i]) break; + i++; + } while(i != MAX_WAITING_VEHICLES); + if(i == MAX_WAITING_VEHICLES) + return pChatWindow->AddDebugMessage("All vehicle waiting slots are consumed!"); + + field_FA4[i] = 1; + field_4[i] = *pWaiting; + return i; +} + +//---------------------------------------------------- diff --git a/saco/net/vehiclepool.h b/saco/net/vehiclepool.h index 6b09c0c..b338783 100644 --- a/saco/net/vehiclepool.h +++ b/saco/net/vehiclepool.h @@ -2,6 +2,15 @@ #pragma once #define INVALID_VEHICLE_ID 0xFFFF +#define MAX_WAITING_VEHICLES 100 + +//---------------------------------------------------- + +// a vehicle the pool cannot create yet is parked in one of these; the payload layout is unresolved +struct VEHICLE_WAITING +{ + char field_0[40]; +}; //---------------------------------------------------- @@ -10,9 +19,9 @@ class CVehiclePool public: int field_0; - char _gap4[4000]; + VEHICLE_WAITING field_4[MAX_WAITING_VEHICLES]; - char field_FA4[400]; + int field_FA4[MAX_WAITING_VEHICLES]; int field_1134[MAX_VEHICLES]; int field_3074[MAX_VEHICLES]; int field_4FB4[MAX_VEHICLES]; @@ -55,6 +64,8 @@ public: int FUNC_1001EC00(); // .text:1001EC00 + int FUNC_1001ED10(VEHICLE_WAITING *pWaiting); // .text:1001ED10 + int FUNC_1001EC70(float fX, float fY, float fZ); // .text:1001EC70 short FUNC_1001EF30(float fMaxDistance, VECTOR *vecStart, VECTOR *vecEnd, float fRadius); // .text:1001EF30