Skip to content

vehicle paintjob reset on respawn, SeedCookie timing, and NPC vehicle death events#1213

Open
Aesir1337 wants to merge 3 commits intoopenmultiplayer:masterfrom
Aesir1337:issue-fixes
Open

vehicle paintjob reset on respawn, SeedCookie timing, and NPC vehicle death events#1213
Aesir1337 wants to merge 3 commits intoopenmultiplayer:masterfrom
Aesir1337:issue-fixes

Conversation

@Aesir1337
Copy link
Copy Markdown

1. Reset paintjob on vehicle respawn (closes #1212)

Vehicle paintjob was not being cleared in _respawn() alongside other visual properties (mods, colours). After respawn the paintjob persisted, causing a desync between the vehicle's visual state and its server-side data.

Fix: Added paintJob = 0 to Vehicle::_respawn() in vehicle.cpp.


2. Move SeedCookie after rakNetServer.Start() (closes #1211)

SeedCookie was being set before the RakNet server started, which could cause connection failures in certain scenarios.

Fix: Moved SeedCookie call to after rakNetServer.Start().


3. Fix OnVehicleDeath / OnVehicleSpawn not firing for NPC-driven vehicles (closes #1196)

NPCs don’t send exit/death RPCs, so vehicles stay permanently occupied. This blocks the onTick respawn logic and prevents OnVehicleDeath/Spawn, leaving vehicles in a zombie state.

Fix: In VehiclesComponent::onTick() (vehicles_impl.hpp), detect the case where a dead vehicle's only occupant is an NPC driver and bypass the occupation check. The existing _respawn() already clears the driver pointer, so no further changes are needed.

Vehicle paintjob was not being cleared in _respawn() while all other
modifications (mods, colours, damage) were properly reset, causing the
paintjob to persist after vehicle respawn.

Fixes openmultiplayer#1212
… failures

RakPeer::Start() internally calls RakPeer::Disconnect() which resets
RakNet internal state. SeedCookie() was called before Start(), meaning
the seeded cookie was discarded. Clients connecting in the window
between server start and the first onTick() re-seed would fail cookie
validation and have their packets silently ignored (issue openmultiplayer#1211).

Also adds an explanatory comment to the paintjob reset fix.
NPC players have no game client to send vehicle exit or death RPCs,
so their vehicles remained permanently "occupied" after dying. The
onTick death/respawn path was gated behind !isOccupied(), causing
OnVehicleDeath and OnVehicleSpawn to never fire for NPC-driven vehicles.

Detect the NPC-only occupied dead case and bypass the occupation check,
allowing death events and respawn to proceed normally (respawn already
clears the driver pointer via _respawn()).

Fixes openmultiplayer#1196
@Joey251
Copy link
Copy Markdown

Joey251 commented Apr 22, 2026

@Aesir1337 Thanks a lot, I implemented your SeedCookie solution and so far I haven’t noticed any complaints about connection issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants