Created attachment 2742[details]
change setviewpos to work as it sounds like
setviewpos now precisely puts the player's view origin to the specified coordinates, and does not spit the player forward. it now optionally takes yaw and pitch arguments.
for this, setviewpos takes ps->viewheight into account when teleporting the player. TeleportPlayer() now takes an addition float argument specifying how fast spit the player forward, currently it's called with 0 only from the setviewpos function.
Um, you don't actually *use* the speed value in Teleport, apart from checking it is nonzero (with a float equality comparison, naughty)
I'm undecided whether setviewpos should take viewheight into account. I don't think that's what I'd expect while using it.
(In reply to comment #1)
> I'm undecided whether setviewpos should take viewheight into account. I don't
> think that's what I'd expect while using it.
setviewpos is a companion function to the viewpos function, both should operate your view origin (setting and displaying, respectively). there is also a function named "where", which prints out your player entity's internal origin, and a corresponding function ("teleport" or "setpos") could be added to set that origin.
Okay, I agree that /setviewpos and /viewpos should be consistent.
I'm somewhat inclined to move the whole "spit the player out" logic out of TeleportPlayer, possibly into a separate SpitPlayer function. If you want to do that that would be great, otherwise I'll probably commit what you've done already.
(In reply to comment #4)
> I'm somewhat inclined to move the whole "spit the player out" logic out of
> TeleportPlayer, possibly into a separate SpitPlayer function.
then we would be basically calling TeleportPlayer and SpitPlayer consecutively (or renaming TeleportPlayer to TeleportAndSpitPlayer) because the majority of the code utilizes spitting. are you still inclined?
We'd be using them consecutively in three places, one of which we want to remove to fix #2757, so yes, I'm still inclined, especially as those might not be the only places where SpitPlayer would be used (what about spawning aliens, for example?)
Created attachment 2742 [details] change setviewpos to work as it sounds like setviewpos now precisely puts the player's view origin to the specified coordinates, and does not spit the player forward. it now optionally takes yaw and pitch arguments. for this, setviewpos takes ps->viewheight into account when teleporting the player. TeleportPlayer() now takes an addition float argument specifying how fast spit the player forward, currently it's called with 0 only from the setviewpos function.
Created attachment 2771 [details] change setviewpos to work as it sounds like a fixed and improved version of the previous patch