fix: stand-up-on-move and nameplate position tracking

Camera controller / sitting:
- Any movement key (WASD/QE/Space) pressed while sitting now clears the
  sitting flag immediately, matching WoW's sit-to-stand-on-move behaviour
- Added StandUpCallback: when the player stands up via local input the
  callback fires setStandState(0) → CMSG_STAND_STATE_CHANGE(STAND) so
  the server releases the sit lock and restores normal movement
- Fixes character getting stuck in sit state after accidentally
  right-clicking a chair GO in Goldshire Inn (or similar)

Nameplates:
- Use getRenderPositionForGuid() (renderer visual position) as primary
  source for nameplate anchor, falling back to entity X/Y/Z only when
  no render instance exists yet; keeps health bars in sync with the
  rendered model instead of the parallel entity interpolator
This commit is contained in:
Kelsi 2026-03-10 19:49:33 -07:00
parent 48d15fc653
commit 564a286282
4 changed files with 34 additions and 8 deletions

View file

@ -369,6 +369,7 @@ void CameraController::update(float deltaTime) {
// Toggle sit/crouch with X key (edge-triggered) — only when UI doesn't want keyboard
// Blocked while mounted
bool prevSitting = sitting;
bool xDown = !uiWantsKeyboard && input.isKeyPressed(SDL_SCANCODE_X);
if (xDown && !xKeyWasDown && !mounted_) {
sitting = !sitting;
@ -376,6 +377,21 @@ void CameraController::update(float deltaTime) {
if (mounted_) sitting = false;
xKeyWasDown = xDown;
// Stand up on any movement key or jump while sitting (WoW behaviour)
if (!uiWantsKeyboard && sitting && !movementSuppressed) {
bool anyMoveKey =
input.isKeyPressed(SDL_SCANCODE_W) || input.isKeyPressed(SDL_SCANCODE_S) ||
input.isKeyPressed(SDL_SCANCODE_A) || input.isKeyPressed(SDL_SCANCODE_D) ||
input.isKeyPressed(SDL_SCANCODE_Q) || input.isKeyPressed(SDL_SCANCODE_E) ||
input.isKeyPressed(SDL_SCANCODE_SPACE);
if (anyMoveKey) sitting = false;
}
// Notify server when the player stands up via local input
if (prevSitting && !sitting && standUpCallback_) {
standUpCallback_();
}
// Update eye height based on crouch state (smooth transition)
float targetEyeHeight = sitting ? CROUCH_EYE_HEIGHT : STAND_EYE_HEIGHT;
float heightLerpSpeed = 10.0f * deltaTime;
@ -389,11 +405,6 @@ void CameraController::update(float deltaTime) {
if (nowStrafeLeft) movement += right;
if (nowStrafeRight) movement -= right;
// Stand up if jumping while crouched
if (!uiWantsKeyboard && sitting && input.isKeyPressed(SDL_SCANCODE_SPACE)) {
sitting = false;
}
// Third-person orbit camera mode
if (thirdPerson && followTarget) {
// Move the follow target (character position) instead of the camera