Remove special handling of creative mode

This commit is contained in:
Perttu Ahola 2012-07-25 14:07:45 +03:00
parent 9eaf93d41d
commit 0a18dda158
8 changed files with 22 additions and 74 deletions

View File

@ -273,7 +273,6 @@ function minetest.node_dig(pos, node, digger)
minetest.log('action', digger:get_player_name() .. " digs " minetest.log('action', digger:get_player_name() .. " digs "
.. node.name .. " at " .. minetest.pos_to_string(pos)) .. node.name .. " at " .. minetest.pos_to_string(pos))
if not minetest.setting_getbool("creative_mode") then
local wielded = digger:get_wielded_item() local wielded = digger:get_wielded_item()
local drops = minetest.get_node_drops(node.name, wielded:get_name()) local drops = minetest.get_node_drops(node.name, wielded:get_name())
@ -290,7 +289,6 @@ function minetest.node_dig(pos, node, digger)
digger:get_inventory():add_item("main", dropped_item) digger:get_inventory():add_item("main", dropped_item)
end end
end end
end
local oldmetadata = nil local oldmetadata = nil
if def.after_dig_node then if def.after_dig_node then

View File

@ -292,13 +292,6 @@ public:
ServerActiveObject *puncher, ServerActiveObject *puncher,
float time_from_last_punch) 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 // Take item into inventory
ItemStack item = createItemStack(); ItemStack item = createItemStack();
Inventory *inv = puncher->getInventory(); 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() std::string PlayerSAO::getPropertyPacket()
{ {
m_prop.is_visible = (getHP() != 0); m_prop.is_visible = (getHP() != 0);

View File

@ -163,8 +163,6 @@ public:
void disconnected(); void disconnected();
void createCreativeInventory();
Player* getPlayer() Player* getPlayer()
{ {
return m_player; return m_player;

View File

@ -514,11 +514,6 @@ void IDropAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame
return; 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 // Take item from source list
ItemStack item2 = list_from->takeItem(from_i, actually_dropped_count); ItemStack item2 = list_from->takeItem(from_i, actually_dropped_count);
@ -527,7 +522,6 @@ void IDropAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame
mgr->setInventoryModified(from_inv); mgr->setInventoryModified(from_inv);
} }
}
infostream<<"IDropAction::apply(): dropped " infostream<<"IDropAction::apply(): dropped "
<<" from inv=\""<<from_inv.dump()<<"\"" <<" from inv=\""<<from_inv.dump()<<"\""

View File

@ -150,7 +150,6 @@ public:
u8 light; u8 light;
// In creative mode, this is the invisible backup inventory
Inventory inventory; Inventory inventory;
u16 hp; u16 hp;

View File

@ -5326,21 +5326,6 @@ void scriptapi_on_leaveplayer(lua_State *L, ServerActiveObject *player)
scriptapi_run_callbacks(L, 1, RUN_CALLBACKS_MODE_FIRST); 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) static void get_auth_handler(lua_State *L)
{ {
lua_getglobal(L, "minetest"); lua_getglobal(L, "minetest");

View File

@ -61,7 +61,6 @@ void scriptapi_on_dieplayer(lua_State *L, ServerActiveObject *player);
bool scriptapi_on_respawnplayer(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_joinplayer(lua_State *L, ServerActiveObject *player);
void scriptapi_on_leaveplayer(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, bool scriptapi_get_auth(lua_State *L, const std::string &playername,
std::string *dst_password, std::set<std::string> *dst_privs); std::string *dst_password, std::set<std::string> *dst_privs);
void scriptapi_create_auth(lua_State *L, const std::string &playername, void scriptapi_create_auth(lua_State *L, const std::string &playername,

View File

@ -3131,7 +3131,6 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
// Placement was handled in lua // Placement was handled in lua
// Apply returned ItemStack // Apply returned ItemStack
if(g_settings->getBool("creative_mode") == false)
playersao->setWieldedItem(item); playersao->setWieldedItem(item);
} }
@ -3158,7 +3157,6 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
item, playersao, pointed)) item, playersao, pointed))
{ {
// Apply returned ItemStack // Apply returned ItemStack
if(g_settings->getBool("creative_mode") == false)
playersao->setWieldedItem(item); playersao->setWieldedItem(item);
} }
@ -4380,8 +4378,6 @@ void Server::UpdateCrafting(u16 peer_id)
// Get a preview for crafting // Get a preview for crafting
ItemStack preview; 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 // Put the new preview in
@ -4717,10 +4713,6 @@ PlayerSAO* Server::emergePlayer(const char *name, u16 peer_id)
scriptapi_on_joinplayer(m_lua, playersao); scriptapi_on_joinplayer(m_lua, playersao);
/* Creative mode */
if(g_settings->getBool("creative_mode"))
playersao->createCreativeInventory();
return playersao; return playersao;
} }