TTT-2 / TTT2

Trouble in Terrorist Town 2 for Garry's Mod (gmod)
https://steamcommunity.com/sharedfiles/filedetails/?id=1357204556
179 stars 77 forks source link

refactor(targetid): Use `Vehicle:GetDriver` instead of NWEntity #1647

Closed Histalek closed 1 month ago

Histalek commented 1 month ago

This replaces the usage of the ttt specific ttt_driver NWEntity with the base gmod Vehicle:GetDriver [1] function to determine the driver of a targeted vehicle.

The ttt solution of keeping track of a vehicle's driver via a networked Entity on the vehicle has existed since forever (12+ years). So i'm sure it has had its reasons to exist. But for at least 5 years base gmod has had the ability to get the driver of a specific vehicle so this should be the way we determine this going forward.

I would love to rip the whole ttt_driver NWEntity out of the code completely. Not only because we definitely have better ways of handling this without increasing networking churn, but also because setting the driver to the vehicle itself, when the driver exits the vehicle, is questionable at best.

Given that some addon will without a doubt depend on this behaviour i'm not changing this though.

[1] https://wiki.facepunch.com/gmod/Vehicle:GetDriver