Repository navigation
Conversation
A freshly spawned NPC was spawned again inside NPC_PutInVehicle, so OnPlayerSpawn ran twice and could delete the vehicle mid-call.
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.
NPC_PutInVehiclespawns the NPC again if it is notPlayerState_OnFoot. Right afterNPC_Spawnthe NPC is stillPlayerState_Spawned, so it gets spawned a second time andOnPlayerSpawnruns inside the native. If the script destroys the vehicle there,putInVehiclekeeps using it.The crash
Access violation in Vehicles.dll, executing an address that is not code. In the minidump the vehicle's vtable pointer is already
IExtensible::vftable(its destructor has run), sovehicle.getModel()at npc.cpp:1556 jumps into data.NPC::respawncan hit the same thing: it keeps the vehicle pointer across its ownPlayerSpawnRPC, which also runsOnPlayerSpawn.Without the destroy it does not crash, but
OnPlayerSpawnstill runs twice and the second spawn resets health, armour and weapon.Repro
Crashes every time on 3d20f3d:
Fix
PlayerState_Spawnedcounts as spawned, so there is no second spawn.falseif it is not.respawndoes the same check.NPC_PutInVehicle(Pawn and CAPI) returns the real result instead of alwaystrue.Tested
Windows, RelWithDebInfo, same tree before and after:
OnPlayerSpawnonce, NPC seatedNPC_Spawn, set weapon and health,NPC_PutInVehicleOnPlayerSpawntwice, weapon and health resetOnPlayerSpawnonce, weapon and health keptNPC_Respawnwhile seated,OnPlayerSpawndestroys the vehicleOnPlayerSpawndestroys the secondfalse, NPC not seated