diff options
author | Nikolay Korolev <nickvnuk@gmail.com> | 2020-05-19 00:49:09 +0200 |
---|---|---|
committer | Nikolay Korolev <nickvnuk@gmail.com> | 2020-05-19 00:49:09 +0200 |
commit | 6510b15704998b14b89fa453ba9d142f85c30dd5 (patch) | |
tree | e194a3641474f3a0818bb4ff2dd139f2c293e804 /src/vehicles | |
parent | fixes for braking and cloud rotation at high fps (diff) | |
download | re3-6510b15704998b14b89fa453ba9d142f85c30dd5.tar re3-6510b15704998b14b89fa453ba9d142f85c30dd5.tar.gz re3-6510b15704998b14b89fa453ba9d142f85c30dd5.tar.bz2 re3-6510b15704998b14b89fa453ba9d142f85c30dd5.tar.lz re3-6510b15704998b14b89fa453ba9d142f85c30dd5.tar.xz re3-6510b15704998b14b89fa453ba9d142f85c30dd5.tar.zst re3-6510b15704998b14b89fa453ba9d142f85c30dd5.zip |
Diffstat (limited to 'src/vehicles')
-rw-r--r-- | src/vehicles/Vehicle.cpp | 15 | ||||
-rw-r--r-- | src/vehicles/Vehicle.h | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index 2b0132b2..fe798514 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -1368,3 +1368,18 @@ CVehicle::GetVehicleAppearance(void) return VEHICLE_APPEARANCE_HELI; return VEHICLE_APPEARANCE_NONE; } + +bool +IsVehiclePointerValid(CVehicle* pVehicle) +{ + if (!pVehicle) + return false; + int index = CPools::GetVehiclePool()->GetJustIndex(pVehicle); +#ifdef FIX_BUGS + if (index < 0 || index >= NUMVEHICLES) +#else + if (index < 0 || index > NUMVEHICLES) +#endif + return false; + return pVehicle->m_vehType == VEHICLE_TYPE_PLANE || pVehicle->m_entryInfoList.first; +} diff --git a/src/vehicles/Vehicle.h b/src/vehicles/Vehicle.h index 5ec20c43..c2cfa5e4 100644 --- a/src/vehicles/Vehicle.h +++ b/src/vehicles/Vehicle.h @@ -314,3 +314,4 @@ public: }; void DestroyVehicleAndDriverAndPassengers(CVehicle* pVehicle); +bool IsVehiclePointerValid(CVehicle* pVehicle); |