X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fserver%2Fplayer_sao.cpp;h=0d31f2e0b549ba455f5bd2c62f4cb969ed3728b6;hb=b7b5aad02758ae897fc0239f50f93e04d085ceed;hp=62515d1c938f02aa5743c6c2ab1b5263c0fcdce3;hpb=adffef2b94f2d9cb3104cbc75e315cda3c0728aa;p=dragonfireclient.git diff --git a/src/server/player_sao.cpp b/src/server/player_sao.cpp index 62515d1c9..0d31f2e0b 100644 --- a/src/server/player_sao.cpp +++ b/src/server/player_sao.cpp @@ -148,7 +148,7 @@ std::string PlayerSAO::getClientInitializationData(u16 protocol_version) void PlayerSAO::getStaticData(std::string * result) const { - FATAL_ERROR("Obsolete function"); + FATAL_ERROR("This function shall not be called for PlayerSAO"); } void PlayerSAO::step(float dtime, bool send_recommended) @@ -260,10 +260,13 @@ void PlayerSAO::step(float dtime, bool send_recommended) // otherwise it's calculated normally. // If the object gets detached this comes into effect automatically from // the last known origin. - if (isAttached()) { - v3f pos = m_env->getActiveObject(m_attachment_parent_id)->getBasePosition(); + if (auto *parent = getParent()) { + v3f pos = parent->getBasePosition(); m_last_good_position = pos; setBasePosition(pos); + + if (m_player) + m_player->setSpeed(v3f()); } if (!send_recommended) @@ -456,6 +459,11 @@ u16 PlayerSAO::punch(v3f dir, return hitparams.wear; } +void PlayerSAO::rightClick(ServerActiveObject *clicker) +{ + m_env->getScriptIface()->on_rightclickplayer(this, clicker); +} + void PlayerSAO::setHP(s32 hp, const PlayerHPChangeReason &reason) { if (hp == (s32)m_hp) @@ -531,7 +539,7 @@ bool PlayerSAO::setWieldedItem(const ItemStack &item) void PlayerSAO::disconnected() { m_peer_id = PEER_ID_INEXISTENT; - m_pending_removal = true; + markForRemoval(); } void PlayerSAO::unlinkPlayerSessionAndSave() @@ -565,34 +573,11 @@ void PlayerSAO::setMaxSpeedOverride(const v3f &vel) bool PlayerSAO::checkMovementCheat() { if (m_is_singleplayer || + isAttached() || g_settings->getBool("disable_anticheat")) { m_last_good_position = m_base_position; return false; } - if (UnitSAO *parent = dynamic_cast(getParent())) { - v3f attachment_pos; - { - int parent_id; - std::string bone; - v3f attachment_rot; - bool force_visible; - getAttachment(&parent_id, &bone, &attachment_pos, &attachment_rot, &force_visible); - } - - v3f parent_pos = parent->getBasePosition(); - f32 diff = m_base_position.getDistanceFromSQ(parent_pos) - attachment_pos.getLengthSQ(); - const f32 maxdiff = 4.0f * BS; // fair trade-off value for various latencies - - if (diff > maxdiff * maxdiff) { - setBasePosition(parent_pos); - actionstream << "Server: " << m_player->getName() - << " moved away from parent; diff=" << sqrtf(diff) / BS - << " resetting position." << std::endl; - return true; - } - // Player movement is locked to the entity. Skip further checks - return false; - } bool cheated = false; /*