1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 08:47:17 +01:00

Work around server defect.

This commit is contained in:
Sandu Liviu Catalin 2021-02-21 13:34:08 +02:00
parent 1f2b75ed26
commit 9017236b13
2 changed files with 15 additions and 5 deletions

View File

@ -514,11 +514,11 @@ struct VehicleInst
SQInteger mTrackRotation{0}; // The number of times to track rotation changes.
// ----------------------------------------------------------------------------------------
int32_t mLastPrimaryColor{-1}; // Last known secondary-color of the player entity.
int32_t mLastSecondaryColor{-1}; // Last known primary-color of the player entity.
float mLastHealth{0}; // Last known health of the player entity.
Vector3 mLastPosition{}; // Last known position of the player entity.
Quaternion mLastRotation{}; // Last known rotation of the player entity.
int32_t mLastPrimaryColor{-1}; // Last known secondary-color of the vehicle entity.
int32_t mLastSecondaryColor{-1}; // Last known primary-color of the vehicle entity.
float mLastHealth{0}; // Last known health of the vehicle entity.
Vector3 mLastPosition{}; // Last known position of the vehicle entity.
Quaternion mLastRotation{}; // Last known rotation of the vehicle entity.
// ----------------------------------------------------------------------------------------
LightObj mEvents{}; // Table containing the emitted entity events.

View File

@ -1810,6 +1810,16 @@ void Core::EmitVehicleUpdate(int32_t vehicle_id, vcmpVehicleUpdate update_type)
} break;
default:
{
// Obtain the current health of this instance
float health = _Func->GetVehicleHealth(vehicle_id);
// Server is actually dumb and never triggers vcmpVehicleUpdateHealth
if (!EpsEq(health, inst.mLastHealth))
{
// Trigger the event specific to this change
EmitVehicleHealth(vehicle_id, inst.mLastHealth, health);
// Update the tracked value
inst.mLastHealth = health;
}
// Finally, forward the call to the update callback
(*inst.mOnUpdate.first)(static_cast< int32_t >(update_type));
(*mOnVehicleUpdate.first)(inst.mObj, static_cast< int32_t >(update_type));