Player collisionbox: Make settable
authorTeTpaAka <TeTpaAka@users.noreply.github.com>
Fri, 29 May 2015 18:30:55 +0000 (20:30 +0200)
committerparamat <mat.gregory@virginmedia.com>
Fri, 21 Jul 2017 01:03:22 +0000 (02:03 +0100)
Breaks compatibility with old clients.

src/content_cao.cpp
src/content_sao.cpp
src/inventorymanager.cpp
src/localplayer.h

index 49c2049eb0df96d857c4cf6b69688d7883a0eb92..2cc675573c26076cf94b7cbfa88f02557b4740db 100644 (file)
@@ -972,7 +972,7 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
                if (m_is_visible) {
                        int old_anim = player->last_animation;
                        float old_anim_speed = player->last_animation_speed;
-                       m_position = player->getPosition() + v3f(0,BS,0);
+                       m_position = player->getPosition();
                        m_velocity = v3f(0,0,0);
                        m_acceleration = v3f(0,0,0);
                        pos_translator.vect_show = m_position;
@@ -1512,6 +1512,7 @@ void GenericCAO::processMessage(const std::string &data)
                if (m_is_local_player) {
                        LocalPlayer *player = m_env->getLocalPlayer();
                        player->makes_footstep_sound = m_prop.makes_footstep_sound;
+                       player->setCollisionbox(m_selection_box);
                }
 
                if ((m_is_player && !m_is_local_player) && m_prop.nametag == "")
index 5bbbd154d4a195ba3075a9661fb6749c2c9ced59..df5cae34fae3b59725c0dbab57d78c5391db23a0 100644 (file)
@@ -784,7 +784,7 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, RemotePlayer *player_, u16 peer_id
        m_prop.hp_max = PLAYER_MAX_HP;
        m_prop.physical = false;
        m_prop.weight = 75;
-       m_prop.collisionbox = aabb3f(-0.3f, -1.0f, -0.3f, 0.3f, 0.75f, 0.3f);
+       m_prop.collisionbox = aabb3f(-0.3f, 0.0f, -0.3f, 0.3f, 1.77f, 0.3f);
        // start of default appearance, this should be overwritten by LUA
        m_prop.visual = "upright_sprite";
        m_prop.visual_size = v2f(1, 2);
@@ -856,7 +856,7 @@ std::string PlayerSAO::getClientInitializationData(u16 protocol_version)
        os << serializeString(m_player->getName()); // name
        writeU8(os, 1); // is_player
        writeS16(os, getId()); //id
-       writeV3F1000(os, m_base_position + v3f(0,BS*1,0));
+       writeV3F1000(os, m_base_position);
        writeF1000(os, m_yaw);
        writeS16(os, getHP());
 
@@ -1009,7 +1009,7 @@ void PlayerSAO::step(float dtime, bool send_recommended)
                if(isAttached()) // Just in case we ever do send attachment position too
                        pos = m_env->getActiveObject(m_attachment_parent_id)->getBasePosition();
                else
-                       pos = m_base_position + v3f(0,BS*1,0);
+                       pos = m_base_position;
                std::string str = gob_cmd_update_position(
                        pos,
                        v3f(0,0,0),
@@ -1414,7 +1414,9 @@ bool PlayerSAO::checkMovementCheat()
 
 bool PlayerSAO::getCollisionBox(aabb3f *toset) const
 {
-       *toset = aabb3f(-0.3f * BS, 0.0f, -0.3f * BS, 0.3f * BS, 1.75f * BS, 0.3f * BS);
+       //update collision box
+       toset->MinEdge = m_prop.collisionbox.MinEdge * BS;
+       toset->MaxEdge = m_prop.collisionbox.MaxEdge * BS;
 
        toset->MinEdge += m_base_position;
        toset->MaxEdge += m_base_position;
index fe37bcd83d4815c1939d346177c9f63d63a60030..0d44e9cdab30aedc9411ff455139a7ec0424383c 100644 (file)
@@ -611,8 +611,8 @@ void IDropAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame
        // Drop the item
        ItemStack item1 = list_from->getItem(from_i);
        item1.count = take_count;
-       if (PLAYER_TO_SA(player)->item_OnDrop(item1, player,
-                               player->getBasePosition() + v3f(0,1,0))) {
+       if(PLAYER_TO_SA(player)->item_OnDrop(item1, player,
+                               player->getBasePosition())) {
                actually_dropped_count = take_count - item1.count;
 
                if (actually_dropped_count == 0) {
@@ -815,7 +815,7 @@ void ICraftAction::apply(InventoryManager *mgr,
                u16 count = it->count;
                do {
                        PLAYER_TO_SA(player)->item_OnDrop(*it, player,
-                               player->getBasePosition() + v3f(0,1,0));
+                               player->getBasePosition());
                        if (count >= it->count) {
                                errorstream << "Couldn't drop replacement stack " <<
                                        it->getItemString() << " because drop loop didn't "
index 32714ff3226f66f68e75ab95e96662d112a45c0c..9f7e921286eb6a850b22078830f75e3ca9da633c 100644 (file)
@@ -140,6 +140,8 @@ public:
        v3f getEyePosition() const { return m_position + getEyeOffset(); }
        v3f getEyeOffset() const;
 
+       void setCollisionbox(const aabb3f &box) { m_collisionbox = box; }
+
 private:
        void accelerateHorizontal(const v3f &target_speed, const f32 max_increase);
        void accelerateVertical(const v3f &target_speed, const f32 max_increase);