Remove special handling of creative mode
authorPerttu Ahola <celeron55@gmail.com>
Wed, 25 Jul 2012 11:07:45 +0000 (14:07 +0300)
committerPerttu Ahola <celeron55@gmail.com>
Wed, 25 Jul 2012 11:07:45 +0000 (14:07 +0300)
builtin/item.lua
src/content_sao.cpp
src/content_sao.h
src/inventorymanager.cpp
src/player.h
src/scriptapi.cpp
src/scriptapi.h
src/server.cpp

index 2a9b4ff27ee306cf7c1c04205ee34c1c1b75ebf3..1b4b4d25a1ea24de7a7be44d4cb032027d0ab69b 100644 (file)
@@ -273,25 +273,23 @@ function minetest.node_dig(pos, node, digger)
        minetest.log('action', digger:get_player_name() .. " digs "
                .. node.name .. " at " .. minetest.pos_to_string(pos))
 
-       if not minetest.setting_getbool("creative_mode") then
-               local wielded = digger:get_wielded_item()
-               local drops = minetest.get_node_drops(node.name, wielded:get_name())
-
-               -- Wear out tool
-               local tp = wielded:get_tool_capabilities()
-               local dp = minetest.get_dig_params(def.groups, tp)
-               wielded:add_wear(dp.wear)
-               digger:set_wielded_item(wielded)
-
-               -- Add dropped items to object's inventory
-               if digger:get_inventory() then
-                       local _, dropped_item
-                       for _, dropped_item in ipairs(drops) do
-                               digger:get_inventory():add_item("main", dropped_item)
-                       end
+       local wielded = digger:get_wielded_item()
+       local drops = minetest.get_node_drops(node.name, wielded:get_name())
+
+       -- Wear out tool
+       local tp = wielded:get_tool_capabilities()
+       local dp = minetest.get_dig_params(def.groups, tp)
+       wielded:add_wear(dp.wear)
+       digger:set_wielded_item(wielded)
+
+       -- Add dropped items to object's inventory
+       if digger:get_inventory() then
+               local _, dropped_item
+               for _, dropped_item in ipairs(drops) do
+                       digger:get_inventory():add_item("main", dropped_item)
                end
        end
-       
+
        local oldmetadata = nil
        if def.after_dig_node then
                oldmetadata = minetest.env:get_meta(pos):to_table()
index 0488c802394b536802370d6bfb3ff458a0553120..843ab29f76b38841dec43e0f9547fec37a710f94 100644 (file)
@@ -292,13 +292,6 @@ public:
                        ServerActiveObject *puncher,
                        float time_from_last_punch)
        {
-               // Directly delete item in creative mode
-               if(g_settings->getBool("creative_mode") == true)
-               {
-                       m_removed = true;
-                       return 0;
-               }
-               
                // Take item into inventory
                ItemStack item = createItemStack();
                Inventory *inv = puncher->getInventory();
@@ -1143,16 +1136,6 @@ void PlayerSAO::disconnected()
        }
 }
 
-void PlayerSAO::createCreativeInventory()
-{
-       if(m_inventory != &m_player->inventory)
-               delete m_inventory;
-
-       m_inventory = new Inventory(m_player->inventory);
-       m_inventory->clearContents();
-       scriptapi_get_creative_inventory(m_env->getLua(), this);
-}
-
 std::string PlayerSAO::getPropertyPacket()
 {
        m_prop.is_visible = (getHP() != 0);
index fac16ca994c5af6da1dd3d182ce426256d5196e6..ff427bac63c5d0b64c51bd3a68c18baaf7002ba2 100644 (file)
@@ -163,8 +163,6 @@ public:
 
        void disconnected();
 
-       void createCreativeInventory();
-
        Player* getPlayer()
        {
                return m_player;
index 5412a5dca5e1d916858540c3ff68710085cdeff6..35e986b56ee94aa0eb5b7b7c55a6668b379744f3 100644 (file)
@@ -514,19 +514,13 @@ void IDropAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame
                        return;
                }
 
-               // Don't remove from inventory in creative mode
-               if(g_settings->getBool("creative_mode") == true
-                               && from_inv.type == InventoryLocation::PLAYER){
-               }
-               else{
-                       // Take item from source list
-                       ItemStack item2 = list_from->takeItem(from_i, actually_dropped_count);
-
-                       if(item2.count != actually_dropped_count)
-                               errorstream<<"Could not take dropped count of items"<<std::endl;
-                       
-                       mgr->setInventoryModified(from_inv);
-               }
+               // Take item from source list
+               ItemStack item2 = list_from->takeItem(from_i, actually_dropped_count);
+
+               if(item2.count != actually_dropped_count)
+                       errorstream<<"Could not take dropped count of items"<<std::endl;
+               
+               mgr->setInventoryModified(from_inv);
        }
 
        infostream<<"IDropAction::apply(): dropped "
index 352b93e88eb77d02c917f8785a62e425fa908f57..47f34c178a18fc1e18d366b5ed95e4c6ea536057 100644 (file)
@@ -150,7 +150,6 @@ public:
        
        u8 light;
 
-       // In creative mode, this is the invisible backup inventory
        Inventory inventory;
 
        u16 hp;
index d28f8c7c1f07e911acf88a206a14a5d1a3266488..18a7c6a273db83e7a1496909e3a67040fce65c87 100644 (file)
@@ -5326,21 +5326,6 @@ void scriptapi_on_leaveplayer(lua_State *L, ServerActiveObject *player)
        scriptapi_run_callbacks(L, 1, RUN_CALLBACKS_MODE_FIRST);
 }
 
-void scriptapi_get_creative_inventory(lua_State *L, ServerActiveObject *player)
-{
-       realitycheck(L);
-       assert(lua_checkstack(L, 20));
-       StackUnroller stack_unroller(L);
-       
-       Inventory *inv = player->getInventory();
-       assert(inv);
-
-       lua_getglobal(L, "minetest");
-       lua_getfield(L, -1, "creative_inventory");
-       luaL_checktype(L, -1, LUA_TTABLE);
-       inventory_set_list_from_lua(inv, "main", L, -1, PLAYER_INVENTORY_SIZE);
-}
-
 static void get_auth_handler(lua_State *L)
 {
        lua_getglobal(L, "minetest");
index baaf061a90d9be866ca9d24212ce7cce5edd9e82..f695e5263f47391a420edddf972121b70a844f19 100644 (file)
@@ -61,7 +61,6 @@ void scriptapi_on_dieplayer(lua_State *L, ServerActiveObject *player);
 bool scriptapi_on_respawnplayer(lua_State *L, ServerActiveObject *player);
 void scriptapi_on_joinplayer(lua_State *L, ServerActiveObject *player);
 void scriptapi_on_leaveplayer(lua_State *L, ServerActiveObject *player);
-void scriptapi_get_creative_inventory(lua_State *L, ServerActiveObject *player);
 bool scriptapi_get_auth(lua_State *L, const std::string &playername,
                std::string *dst_password, std::set<std::string> *dst_privs);
 void scriptapi_create_auth(lua_State *L, const std::string &playername,
index c7698a10629ca7300904bb90b20106e938c0c209..21c936e6996dfcec97fe1d3f7d299c487bbc3618 100644 (file)
@@ -3131,8 +3131,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
                                // Placement was handled in lua
 
                                // Apply returned ItemStack
-                               if(g_settings->getBool("creative_mode") == false)
-                                       playersao->setWieldedItem(item);
+                               playersao->setWieldedItem(item);
                        }
                        
                        // If item has node placement prediction, always send the above
@@ -3158,8 +3157,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
                                        item, playersao, pointed))
                        {
                                // Apply returned ItemStack
-                               if(g_settings->getBool("creative_mode") == false)
-                                       playersao->setWieldedItem(item);
+                               playersao->setWieldedItem(item);
                        }
 
                } // action == 4
@@ -4380,9 +4378,7 @@ void Server::UpdateCrafting(u16 peer_id)
 
        // Get a preview for crafting
        ItemStack preview;
-       // No crafting in creative mode
-       if(g_settings->getBool("creative_mode") == false)
-               getCraftingResult(&player->inventory, preview, false, this);
+       getCraftingResult(&player->inventory, preview, false, this);
 
        // Put the new preview in
        InventoryList *plist = player->inventory.getList("craftpreview");
@@ -4717,10 +4713,6 @@ PlayerSAO* Server::emergePlayer(const char *name, u16 peer_id)
 
        scriptapi_on_joinplayer(m_lua, playersao);
 
-       /* Creative mode */
-       if(g_settings->getBool("creative_mode"))
-               playersao->createCreativeInventory();
-
        return playersao;
 }