Repository navigation
Fix destroyed vehicles not taking time of death into account - #1299
Open
DignitySAMP wants to merge 1 commit into
Open
DignitySAMP wants to merge 1 commit into
DignitySAMP wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Vehicle that get destroyed respawn right away instead of respecting
game.vehicle_respawn_time. When nobody has been in a vehicle for longer thangame.vehicle_respawn_time,OnVehicleSpawngets called on the same tick asOnVehicleDeath.This is the cause:
open.mp/Server/Components/Vehicles/vehicles_impl.hpp
Lines 598 to 602 in 2b4a69d
This is easily reproducable on a clean script:
With this code above, drive a vehicle, get out, wait longer than
game.vehicle_respawn_timeand blow it up.Expected:
spawn10 seconds afterdeathActual: both on the same tick
deathDatais a reference whichsetTimeOfDeathclears the same time thatstd::maxis called (the immediate next line). So it never updated the last occupied time and instantly passed the respawn check right below it. This was changed at 661adf4 so this PR restores the original logic prior to that commit by reading the time of death into a local before it gets cleared.With the fix death triggers at 5036 ms and spawn at 15032 ms after I set it on fire. Before it was 5035 ms for both. I also tested this with vehicles that die with the driver still inside and the normal respawn delay of vehicles that aren't destroyed, which were fine.
This PR now forces a wreck to always wait the full respawn time counted from the death. Previously it only took the timestamp of exiting the vehicle into account.