Object properties: Fix loss of custom selectionbox
authorSmallJoker <mk939@ymail.com>
Sun, 10 Sep 2017 18:16:25 +0000 (20:16 +0200)
committerSmallJoker <mk939@ymail.com>
Sun, 10 Sep 2017 18:26:03 +0000 (20:26 +0200)
Only adjust it to the collisionbox value when the collisionbox was really set.

src/script/common/c_content.cpp

index 3932321a72a66134680a483fc04a149a61c53be2..9e1fed2f11cc054433db120737ec1584ea7fef7c 100644 (file)
@@ -199,16 +199,18 @@ void read_object_properties(lua_State *L, int index,
        getfloatfield(L, -1, "weight", prop->weight);
 
        lua_getfield(L, -1, "collisionbox");
-       if(lua_istable(L, -1))
+       bool collisionbox_defined = lua_istable(L, -1);
+       if (collisionbox_defined)
                prop->collisionbox = read_aabb3f(L, -1, 1.0);
        lua_pop(L, 1);
 
        lua_getfield(L, -1, "selectionbox");
        if (lua_istable(L, -1))
                prop->selectionbox = read_aabb3f(L, -1, 1.0);
-       else
+       else if (collisionbox_defined)
                prop->selectionbox = prop->collisionbox;
        lua_pop(L, 1);
+
        getboolfield(L, -1, "pointable", prop->pointable);
        getstringfield(L, -1, "visual", prop->visual);