| 482 | |
| 483 | |
| 484 | void cClientHandle::HandlePlayerPos(double a_PosX, double a_PosY, double a_PosZ, double a_Stance, bool a_IsOnGround) |
| 485 | { |
| 486 | if ((m_Player == NULL) || (m_State != csPlaying)) |
| 487 | { |
| 488 | // The client hasn't been spawned yet and sends nonsense, we know better |
| 489 | return; |
| 490 | } |
| 491 | |
| 492 | /* |
| 493 | // TODO: Invalid stance check |
| 494 | if ((a_PosY >= a_Stance) || (a_Stance > a_PosY + 1.65)) |
| 495 | { |
| 496 | LOGD("Invalid stance"); |
| 497 | SendPlayerMoveLook(); |
| 498 | return; |
| 499 | } |
| 500 | */ |
| 501 | |
| 502 | // If the player has moved too far, "repair" them: |
| 503 | Vector3d Pos(a_PosX, a_PosY, a_PosZ); |
| 504 | if ((m_Player->GetPosition() - Pos).SqrLength() > 100 * 100) |
| 505 | { |
| 506 | LOGD("Too far away (%0.2f), \"repairing\" the client", (m_Player->GetPosition() - Pos).Length()); |
| 507 | SendPlayerMoveLook(); |
| 508 | return; |
| 509 | } |
| 510 | |
| 511 | // If a jump just started, process food exhaustion: |
| 512 | if ((a_PosY > m_Player->GetPosY()) && !a_IsOnGround && m_Player->IsOnGround()) |
| 513 | { |
| 514 | // we only add this exhaustion if the player is not swimming - otherwise we end up with both jump + swim exhaustion |
| 515 | |
| 516 | if (!m_Player->IsSwimming()) |
| 517 | { |
| 518 | m_Player->AddFoodExhaustion(m_Player->IsSprinting() ? 0.8 : 0.2); |
| 519 | } |
| 520 | } |
| 521 | |
| 522 | m_Player->MoveTo(Pos); |
| 523 | m_Player->SetStance(a_Stance); |
| 524 | m_Player->SetTouchGround(a_IsOnGround); |
| 525 | } |
| 526 | |
| 527 | |
| 528 |
no test coverage detected