fix: NPC_PutInVehicle not visually attaching NPC to boat seat#1236
Open
Revelts wants to merge 1 commit into
Open
fix: NPC_PutInVehicle not visually attaching NPC to boat seat#1236Revelts wants to merge 1 commit into
Revelts wants to merge 1 commit into
Conversation
Vehicle::putPlayer only sends PutPlayerInVehicle to the entering player, which is a no-op for an NPC since it has no real client. Without an explicit broadcast, remote clients have no signal to visually attach the NPC and must rely on the next DriverSync — which some vehicles, notably boats (e.g. 595, 446), refuse to honour while the player is on-foot from their perspective. Mirror the natural goToVehicle flow by broadcasting EnterVehicle to streamed players inside NPC::putInVehicle. Fixes openmultiplayer#1225
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.
Summary
Fixes #1225 —
NPC_PutInVehicleupdates logical state correctly (NPC_GetVehicle/NPC_GetVehicleSeatreturn expected values) but the NPC remains visually on foot for boats (tested with models 595 Launch, 446 Squalo).Root cause
NPC::putInVehiclecallsVehicle::putPlayer, which sends thePutPlayerInVehicleRPC only to the entering player. For an NPC this is a no-op — it has no real client to receive the RPC. Other streamed-in clients receive no broadcast and must rely on the next periodicDriverSyncto visually attach the NPC. While the SA-MP client auto-attaches a remote player to most vehicles fromDriverSyncalone, boats refuse to honour this when the local view still shows the player on foot, so the NPC stays visually on foot even though every server-side data structure agrees the NPC is the driver.The natural
goToVehicleflow does not have this problem because it emulatesOnPlayerEnterVehiclefirst, whose handler broadcastsEnterVehicleto streamed players. That broadcast is the signal the SA-MP client needs to actually attach the NPC.Fix
In
Server/Components/NPCs/NPC/npc.cpp, insideNPC::putInVehicle, broadcastNetCode::RPC::EnterVehicleto streamed-in players immediately afterVehicle::putPlayerand thevehicle_/vehicleSeat_assignment. This mirrors the natural entry path without firing theOnPlayerEnterVehiclepawn callback.Test plan
NPC_PutInVehicle(npc, boatId, 0)from a command while a real player stands near the boat.NPC_GoToVehicleflow is unaffected.NPC_GetVehicle/NPC_GetVehicleSeatstill return correct values.Notes
PacketHelperandNetCode::RPC::EnterVehicleare already transitively included vianetcode.hpp.