new chests pt1
After Width: | Height: | Size: 719 B |
After Width: | Height: | Size: 823 B |
After Width: | Height: | Size: 857 B |
After Width: | Height: | Size: 527 B |
Before Width: | Height: | Size: 741 B After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.3 KiB |
|
@ -202,6 +202,7 @@ set(common_SRCS
|
|||
nodemeta/content_nodemeta_flag.cpp
|
||||
nodemeta/content_nodemeta_bed.cpp
|
||||
nodemeta/content_nodemeta_storage_old.cpp
|
||||
nodemeta/content_nodemeta_storage.cpp
|
||||
nodemeta/content_nodemeta_storage_prefill.cpp
|
||||
nodemeta/content_nodemeta_borderstone.cpp
|
||||
nodemeta/content_nodemeta_cooking.cpp
|
||||
|
|
|
@ -43,9 +43,9 @@ void config_default_init()
|
|||
config_set_default("debug.show","false",NULL);
|
||||
|
||||
#ifndef SERVER
|
||||
config_set_default("client.video.anisotropic","true",NULL);
|
||||
config_set_default("client.video.bilinear","true",NULL);
|
||||
config_set_default("client.video.trilinear","true",NULL);
|
||||
config_set_default("client.video.anisotropic","false",NULL);
|
||||
config_set_default("client.video.bilinear","false",NULL);
|
||||
config_set_default("client.video.trilinear","false",NULL);
|
||||
config_set_default("client.video.mipmaps","true",NULL);
|
||||
config_set_default("client.video.fullscreen","false",NULL);
|
||||
config_set_default("client.video.fullscreen.bpp","24",NULL);
|
||||
|
@ -65,7 +65,7 @@ void config_default_init()
|
|||
#endif
|
||||
|
||||
config_set_default("client.graphics.mesh.lod","3",NULL);
|
||||
config_set_default("client.graphics.texture.animations","true",NULL);
|
||||
config_set_default("client.graphics.texture.animations","false",NULL);
|
||||
config_set_default("client.graphics.texture.atlas","true",NULL);
|
||||
config_set_default("client.graphics.texture.lod","3",NULL);
|
||||
config_set_default("client.graphics.light.lod","3",NULL);
|
||||
|
|
|
@ -61,9 +61,9 @@ MapNode mapnode_translate_to_internal(MapNode n_from, u8 version);
|
|||
#define CONTENT_SPACEROCK 0x00C
|
||||
#define CONTENT_SAFE 0x00D
|
||||
#define CONTENT_SIGN_WALL 0x00E
|
||||
#define CONTENT_CHEST 0x00F
|
||||
#define CONTENT_CHEST_DEPRECATED 0x00F
|
||||
#define CONTENT_FURNACE 0x010
|
||||
#define CONTENT_LOCKABLE_CHEST 0x011
|
||||
#define CONTENT_LOCKABLE_CHEST_DEPRECATED 0x011
|
||||
#define CONTENT_SIGN 0x012
|
||||
#define CONTENT_SIGN_UD 0x013
|
||||
#define CONTENT_LOCKABLE_FURNACE 0x014
|
||||
|
@ -96,7 +96,10 @@ MapNode mapnode_translate_to_internal(MapNode n_from, u8 version);
|
|||
#define CONTENT_LIMESTONE_WALL 0x02C
|
||||
#define CONTENT_MARBLE_WALL 0x02D
|
||||
#define CONTENT_CAMPFIRE 0x02E
|
||||
// FREE 0x02F-0x03F
|
||||
#define CONTENT_CHEST 0x02F
|
||||
#define CONTENT_CHEST_PINE 0x030
|
||||
#define CONTENT_CHEST_JUNGLE 0x031
|
||||
// FREE 0x032-0x03F
|
||||
#define CONTENT_BUSH_BLUEBERRY 0x040
|
||||
#define CONTENT_BUSH_RASPBERRY 0x041
|
||||
// FREE 0x042-0x07C
|
||||
|
|
|
@ -1240,6 +1240,126 @@ void content_mapnode_special(bool repeat)
|
|||
i = CONTENT_CHEST;
|
||||
f = &content_features(i);
|
||||
f->description = gettext("Chest");
|
||||
f->draw_type = CDT_NODEBOX_META;
|
||||
f->setAllTextures("wood.png^chests_side.png");
|
||||
f->setTexture(0, "wood.png^chests_top.png");
|
||||
f->setTexture(1, "wood.png^chests_top.png");
|
||||
f->setTexture(4, "wood.png^chests_back.png");
|
||||
f->setTexture(5, "wood.png^chests_front.png"); // Z-
|
||||
f->param_type = CPT_LIGHT;
|
||||
f->param2_type = CPT_FACEDIR_SIMPLE;
|
||||
f->light_propagates = true;
|
||||
f->sunlight_propagates = true;
|
||||
f->air_equivalent = true;
|
||||
f->rotate_tile_with_nodebox = true;
|
||||
//-0.5*BS,-0.5*BS,-0.4375*BS,0.5*BS,0.4375*BS,0.4375*BS
|
||||
f->setNodeBox(NodeBox(
|
||||
-0.5*BS,-0.5*BS,-0.4375*BS,0.5*BS,0.3125*BS,0.4375*BS
|
||||
));
|
||||
f->addNodeBox(NodeBox(
|
||||
-0.5*BS,0.3125*BS,-0.3125*BS,0.5*BS,0.375*BS,0.3125*BS
|
||||
));
|
||||
f->addNodeBox(NodeBox(
|
||||
-0.5*BS,0.375*BS,-0.125*BS,0.5*BS,0.4375*BS,0.125*BS
|
||||
));
|
||||
f->addNodeBox(NodeBox(
|
||||
-0.0625*BS,-0.0625*BS,-0.5*BS,0.0625*BS,0.125*BS,-0.4375*BS
|
||||
));
|
||||
f->setInventoryTextureNodeBox(i,"wood.png^chests_top.png", "wood.png^chests_front.png", "wood.png^chests_side.png");
|
||||
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||
if (f->initial_metadata == NULL)
|
||||
f->initial_metadata = new ChestNodeMetadata();
|
||||
f->sound_access = "open-chest";
|
||||
f->type = CMT_WOOD;
|
||||
f->hardness = 1.0;
|
||||
f->pressure_type = CST_SOLID;
|
||||
crafting::setRoundRecipe(CONTENT_WOOD,CONTENT_CHEST);
|
||||
content_list_add("craftguide",i,1,0);
|
||||
content_list_add("creative",i,1,0);
|
||||
|
||||
i = CONTENT_CHEST_PINE;
|
||||
f = &content_features(i);
|
||||
f->description = gettext("Chest");
|
||||
f->draw_type = CDT_NODEBOX_META;
|
||||
f->setAllTextures("pine.png^chests_side.png");
|
||||
f->setTexture(0, "pine.png^chests_top.png");
|
||||
f->setTexture(1, "pine.png^chests_top.png");
|
||||
f->setTexture(4, "pine.png^chests_back.png");
|
||||
f->setTexture(5, "pine.png^chests_front.png"); // Z-
|
||||
f->param_type = CPT_LIGHT;
|
||||
f->param2_type = CPT_FACEDIR_SIMPLE;
|
||||
f->light_propagates = true;
|
||||
f->sunlight_propagates = true;
|
||||
f->air_equivalent = true;
|
||||
f->rotate_tile_with_nodebox = true;
|
||||
//-0.5*BS,-0.5*BS,-0.4375*BS,0.5*BS,0.4375*BS,0.4375*BS
|
||||
f->setNodeBox(NodeBox(
|
||||
-0.5*BS,-0.5*BS,-0.4375*BS,0.5*BS,0.3125*BS,0.4375*BS
|
||||
));
|
||||
f->addNodeBox(NodeBox(
|
||||
-0.5*BS,0.3125*BS,-0.3125*BS,0.5*BS,0.375*BS,0.3125*BS
|
||||
));
|
||||
f->addNodeBox(NodeBox(
|
||||
-0.5*BS,0.375*BS,-0.125*BS,0.5*BS,0.4375*BS,0.125*BS
|
||||
));
|
||||
f->addNodeBox(NodeBox(
|
||||
-0.0625*BS,-0.0625*BS,-0.5*BS,0.0625*BS,0.125*BS,-0.4375*BS
|
||||
));
|
||||
f->setInventoryTextureNodeBox(i,"pine.png^chests_top.png", "pine.png^chests_front.png", "pine.png^chests_side.png");
|
||||
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||
if (f->initial_metadata == NULL)
|
||||
f->initial_metadata = new ChestNodeMetadata();
|
||||
f->sound_access = "open-chest";
|
||||
f->type = CMT_WOOD;
|
||||
f->hardness = 1.0;
|
||||
f->pressure_type = CST_SOLID;
|
||||
crafting::setRoundRecipe(CONTENT_WOOD_PINE,CONTENT_CHEST_PINE);
|
||||
content_list_add("craftguide",i,1,0);
|
||||
content_list_add("creative",i,1,0);
|
||||
|
||||
i = CONTENT_CHEST_JUNGLE;
|
||||
f = &content_features(i);
|
||||
f->description = gettext("Chest");
|
||||
f->draw_type = CDT_NODEBOX_META;
|
||||
f->setAllTextures("junglewood.png^chests_side.png");
|
||||
f->setTexture(0, "junglewood.png^chests_top.png");
|
||||
f->setTexture(1, "junglewood.png^chests_top.png");
|
||||
f->setTexture(4, "junglewood.png^chests_back.png");
|
||||
f->setTexture(5, "junglewood.png^chests_front.png"); // Z-
|
||||
f->param_type = CPT_LIGHT;
|
||||
f->param2_type = CPT_FACEDIR_SIMPLE;
|
||||
f->light_propagates = true;
|
||||
f->sunlight_propagates = true;
|
||||
f->air_equivalent = true;
|
||||
f->rotate_tile_with_nodebox = true;
|
||||
//-0.5*BS,-0.5*BS,-0.4375*BS,0.5*BS,0.4375*BS,0.4375*BS
|
||||
f->setNodeBox(NodeBox(
|
||||
-0.5*BS,-0.5*BS,-0.4375*BS,0.5*BS,0.3125*BS,0.4375*BS
|
||||
));
|
||||
f->addNodeBox(NodeBox(
|
||||
-0.5*BS,0.3125*BS,-0.3125*BS,0.5*BS,0.375*BS,0.3125*BS
|
||||
));
|
||||
f->addNodeBox(NodeBox(
|
||||
-0.5*BS,0.375*BS,-0.125*BS,0.5*BS,0.4375*BS,0.125*BS
|
||||
));
|
||||
f->addNodeBox(NodeBox(
|
||||
-0.0625*BS,-0.0625*BS,-0.5*BS,0.0625*BS,0.125*BS,-0.4375*BS
|
||||
));
|
||||
f->setInventoryTextureNodeBox(i,"junglewood.png^chests_top.png", "junglewood.png^chests_front.png", "junglewood.png^chests_side.png");
|
||||
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||
if (f->initial_metadata == NULL)
|
||||
f->initial_metadata = new ChestNodeMetadata();
|
||||
f->sound_access = "open-chest";
|
||||
f->type = CMT_WOOD;
|
||||
f->hardness = 1.0;
|
||||
f->pressure_type = CST_SOLID;
|
||||
crafting::setRoundRecipe(CONTENT_JUNGLEWOOD,CONTENT_CHEST_JUNGLE);
|
||||
content_list_add("craftguide",i,1,0);
|
||||
content_list_add("creative",i,1,0);
|
||||
|
||||
i = CONTENT_CHEST_DEPRECATED;
|
||||
f = &content_features(i);
|
||||
f->description = gettext("Chest");
|
||||
f->param_type = CPT_FACEDIR_SIMPLE;
|
||||
f->draw_type = CDT_CUBELIKE;
|
||||
f->setAllTextures("chest_side.png");
|
||||
|
@ -1248,18 +1368,13 @@ void content_mapnode_special(bool repeat)
|
|||
f->setTexture(5, "chest_front.png"); // Z-
|
||||
f->setInventoryTexture("chest_top.png");
|
||||
f->setInventoryTextureCube("chest_top.png", "chest_front.png", "chest_side.png");
|
||||
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||
f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_CHEST)+" 1";
|
||||
if(f->initial_metadata == NULL)
|
||||
f->initial_metadata = new ChestNodeMetadata();
|
||||
f->initial_metadata = new DeprecatedChestNodeMetadata();
|
||||
f->sound_access = "open-chest";
|
||||
f->type = CMT_WOOD;
|
||||
f->hardness = 1.0;
|
||||
f->pressure_type = CST_SOLID;
|
||||
f->alternate_lockstate_node = CONTENT_LOCKABLE_CHEST;
|
||||
crafting::setRoundRecipe(CONTENT_WOOD,CONTENT_CHEST);
|
||||
crafting::setRoundRecipe(CONTENT_JUNGLEWOOD,CONTENT_CHEST);
|
||||
content_list_add("craftguide",i,1,0);
|
||||
content_list_add("creative",i,1,0);
|
||||
|
||||
i = CONTENT_CREATIVE_CHEST;
|
||||
f = &content_features(i);
|
||||
|
@ -1282,7 +1397,7 @@ void content_mapnode_special(bool repeat)
|
|||
content_list_add("player-creative",i,1,0);
|
||||
content_list_add("creative",i,1,0);
|
||||
|
||||
i = CONTENT_LOCKABLE_CHEST;
|
||||
i = CONTENT_LOCKABLE_CHEST_DEPRECATED;
|
||||
f = &content_features(i);
|
||||
f->description = gettext("Locking Chest");
|
||||
f->param_type = CPT_FACEDIR_SIMPLE;
|
||||
|
@ -1293,25 +1408,14 @@ void content_mapnode_special(bool repeat)
|
|||
f->setTexture(5, "chest_lock.png"); // Z-
|
||||
f->setInventoryTexture("chest_lock.png");
|
||||
f->setInventoryTextureCube("chest_top.png", "chest_lock.png", "chest_side.png");
|
||||
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||
f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_CHEST)+" 1";
|
||||
/* TODO: give padlock */
|
||||
if(f->initial_metadata == NULL)
|
||||
f->initial_metadata = new LockingChestNodeMetadata();
|
||||
f->initial_metadata = new LockingDeprecatedChestNodeMetadata();
|
||||
f->sound_access = "open-chest";
|
||||
f->type = CMT_WOOD;
|
||||
f->hardness = 1.0;
|
||||
f->pressure_type = CST_SOLID;
|
||||
f->alternate_lockstate_node = CONTENT_CHEST;
|
||||
crafting::setFilledRoundRecipe(CONTENT_WOOD,CONTENT_CRAFTITEM_STEEL_INGOT,CONTENT_LOCKABLE_CHEST);
|
||||
crafting::setFilledRoundRecipe(CONTENT_JUNGLEWOOD,CONTENT_CRAFTITEM_STEEL_INGOT,CONTENT_LOCKABLE_CHEST);
|
||||
crafting::set1Any2Recipe(CONTENT_CHEST,CONTENT_CRAFTITEM_STEEL_INGOT,CONTENT_LOCKABLE_CHEST);
|
||||
crafting::setFilledRoundRecipe(CONTENT_WOOD,CONTENT_CRAFTITEM_COPPER_INGOT,CONTENT_LOCKABLE_CHEST);
|
||||
crafting::setFilledRoundRecipe(CONTENT_JUNGLEWOOD,CONTENT_CRAFTITEM_COPPER_INGOT,CONTENT_LOCKABLE_CHEST);
|
||||
crafting::set1Any2Recipe(CONTENT_CHEST,CONTENT_CRAFTITEM_COPPER_INGOT,CONTENT_LOCKABLE_CHEST);
|
||||
crafting::setFilledRoundRecipe(CONTENT_WOOD,CONTENT_CRAFTITEM_SILVER_INGOT,CONTENT_LOCKABLE_CHEST);
|
||||
crafting::setFilledRoundRecipe(CONTENT_JUNGLEWOOD,CONTENT_CRAFTITEM_SILVER_INGOT,CONTENT_LOCKABLE_CHEST);
|
||||
crafting::set1Any2Recipe(CONTENT_CHEST,CONTENT_CRAFTITEM_SILVER_INGOT,CONTENT_LOCKABLE_CHEST);
|
||||
content_list_add("craftguide",i,1,0);
|
||||
content_list_add("creative",i,1,0);
|
||||
|
||||
i = CONTENT_SAFE;
|
||||
f = &content_features(i);
|
||||
|
|
|
@ -159,6 +159,37 @@ public:
|
|||
ChestNodeMetadata();
|
||||
~ChestNodeMetadata();
|
||||
|
||||
virtual u16 typeId() const;
|
||||
static NodeMetadata* create(std::istream &is);
|
||||
virtual NodeMetadata* clone();
|
||||
virtual void serializeBody(std::ostream &os);
|
||||
virtual std::wstring infoText();
|
||||
virtual Inventory* getInventory();
|
||||
virtual void inventoryModified();
|
||||
virtual bool nodeRemovalDisabled();
|
||||
virtual std::string getDrawSpecString(Player *player);
|
||||
virtual std::vector<NodeBox> getNodeBoxes(MapNode &n);
|
||||
|
||||
virtual std::string getOwner();
|
||||
virtual void setOwner(std::string t){ m_owner = t; }
|
||||
virtual std::string getInventoryOwner();
|
||||
virtual void setInventoryOwner(std::string t){ m_owner = t; }
|
||||
|
||||
private:
|
||||
Inventory *m_inventory;
|
||||
std::string m_owner;
|
||||
bool m_is_exo;
|
||||
bool m_is_expanded;
|
||||
bool m_is_locked;
|
||||
uint16_t m_expanded_slot_id;
|
||||
};
|
||||
|
||||
class DeprecatedChestNodeMetadata : public NodeMetadata
|
||||
{
|
||||
public:
|
||||
DeprecatedChestNodeMetadata();
|
||||
~DeprecatedChestNodeMetadata();
|
||||
|
||||
virtual u16 typeId() const;
|
||||
static NodeMetadata* create(std::istream &is);
|
||||
virtual NodeMetadata* clone();
|
||||
|
@ -174,11 +205,11 @@ private:
|
|||
Inventory *m_inventory;
|
||||
};
|
||||
|
||||
class LockingChestNodeMetadata : public NodeMetadata
|
||||
class LockingDeprecatedChestNodeMetadata : public NodeMetadata
|
||||
{
|
||||
public:
|
||||
LockingChestNodeMetadata();
|
||||
~LockingChestNodeMetadata();
|
||||
LockingDeprecatedChestNodeMetadata();
|
||||
~LockingDeprecatedChestNodeMetadata();
|
||||
|
||||
virtual u16 typeId() const;
|
||||
static NodeMetadata* create(std::istream &is);
|
||||
|
|
|
@ -966,6 +966,7 @@ void content_toolitem_init()
|
|||
f->has_unlock_effect = true;
|
||||
crafting::set1To1Recipe(CONTENT_CRAFTITEM_GOLD_INGOT,CONTENT_TOOLITEM_KEY);
|
||||
content_list_add("craftguide",i,1,0);
|
||||
content_list_add("creative",i,1,0);
|
||||
|
||||
i = CONTENT_TOOLITEM_MITHRIL_KEY;
|
||||
f = &g_content_toolitem_features[i];
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
* for Voxelands.
|
||||
************************************************************************/
|
||||
|
||||
|
||||
#include "common.h"
|
||||
#include "inventory.h"
|
||||
#include "serialization.h"
|
||||
#include "utility.h"
|
||||
|
@ -840,7 +840,7 @@ void InventoryList::deSerialize(std::istream &is)
|
|||
m_items[item_i] = InventoryItem::create(c,wc,wc);
|
||||
}
|
||||
if (readU8(is) != 3)
|
||||
throw SerializationError("Unknown inventory identifier");
|
||||
throw SerializationError("Unknown inventory identifier (2)");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -903,7 +903,7 @@ void InventoryList::deSerialize(std::istream &is)
|
|||
delete m_items[item_i];
|
||||
m_items[item_i++] = NULL;
|
||||
}else{
|
||||
throw SerializationError("Unknown inventory identifier");
|
||||
throw SerializationError("Unknown inventory identifier (3)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1314,7 +1314,7 @@ void Inventory::deSerialize(std::istream &is)
|
|||
|
||||
list->deSerialize(is);
|
||||
}else{
|
||||
throw SerializationError("Unknown inventory identifier");
|
||||
throw SerializationError("Unknown Inventory identifier");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1850,8 +1850,8 @@ MapBlock* ServerMap::finishBlockMake(mapgen::BlockMakeData *data,
|
|||
for (p0.Y=0; p0.Y<MAP_BLOCKSIZE; p0.Y++) {
|
||||
for (p0.Z=0; p0.Z<MAP_BLOCKSIZE; p0.Z++) {
|
||||
MapNode n = block->getNodeNoEx(p0);
|
||||
if (n.getContent() == CONTENT_CHEST) {
|
||||
printf("CHEST!!\n");
|
||||
/* TODO: chests */
|
||||
if (n.getContent() == CONTENT_CHEST_DEPRECATED) {
|
||||
// chest? give it metadata and put shit in it
|
||||
NodeMetadata *f = block->m_node_metadata.get(p0);
|
||||
Inventory *inv = f->getInventory();
|
||||
|
|
|
@ -548,7 +548,8 @@ static void make_room1(VoxelManipulator &vmanip, v3s16 roomsize, v3s16 roomplace
|
|||
u32 vi = vmanip.m_area.index(p);
|
||||
if (vmanip.m_data[vi].getContent() == CONTENT_AIR) {
|
||||
vmanip.m_flags[vi] |= VMANIP_FLAG_DUNGEON_UNTOUCHABLE;
|
||||
vmanip.m_data[vi] = MapNode(CONTENT_CHEST);
|
||||
/* TODO: chests
|
||||
vmanip.m_data[vi] = MapNode(CONTENT_CHEST); */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,305 @@
|
|||
/************************************************************************
|
||||
* Minetest-c55
|
||||
* Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
*
|
||||
* content_nodemeta.cpp
|
||||
* voxelands - 3d voxel world sandbox game
|
||||
* Copyright (C) Lisa 'darkrose' Milne 2013-2014 <lisa@ltmnet.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
* License updated from GPLv2 or later to GPLv3 or later by Lisa Milne
|
||||
* for Voxelands.
|
||||
************************************************************************/
|
||||
|
||||
#include "common.h"
|
||||
#include "content_nodemeta.h"
|
||||
#include "inventory.h"
|
||||
#include "content_mapnode.h"
|
||||
#include "content_craftitem.h"
|
||||
#include "content_toolitem.h"
|
||||
#include "player.h"
|
||||
|
||||
|
||||
/*
|
||||
ChestNodeMetadata
|
||||
*/
|
||||
|
||||
// Prototype
|
||||
ChestNodeMetadata proto_ChestNodeMetadata;
|
||||
|
||||
ChestNodeMetadata::ChestNodeMetadata()
|
||||
{
|
||||
NodeMetadata::registerType(typeId(), create);
|
||||
|
||||
m_is_locked = false;
|
||||
m_is_expanded = false;
|
||||
m_is_exo = false;
|
||||
m_expanded_slot_id = 0;
|
||||
|
||||
m_inventory = new Inventory();
|
||||
m_inventory->addList("upgrades", 2);
|
||||
m_inventory->addList("main", 18);
|
||||
inventoryModified();
|
||||
}
|
||||
ChestNodeMetadata::~ChestNodeMetadata()
|
||||
{
|
||||
delete m_inventory;
|
||||
}
|
||||
u16 ChestNodeMetadata::typeId() const
|
||||
{
|
||||
return CONTENT_CHEST;
|
||||
}
|
||||
NodeMetadata* ChestNodeMetadata::create(std::istream &is)
|
||||
{
|
||||
std::string s;
|
||||
ChestNodeMetadata *d = new ChestNodeMetadata();
|
||||
|
||||
d->setOwner(deSerializeString(is));
|
||||
|
||||
s = deSerializeString(is);
|
||||
d->m_is_exo = !!mystoi(s);
|
||||
|
||||
s = deSerializeString(is);
|
||||
d->m_is_expanded = !!mystoi(s);
|
||||
|
||||
s = deSerializeString(is);
|
||||
d->m_is_locked = !!mystoi(s);
|
||||
|
||||
s = deSerializeString(is);
|
||||
d->m_expanded_slot_id = mystoi(s);
|
||||
|
||||
if (d->m_is_expanded) {
|
||||
delete d->m_inventory;
|
||||
d->m_inventory = new Inventory();
|
||||
d->m_inventory->addList("upgrades", 2);
|
||||
d->m_inventory->addList("main", 36);
|
||||
}
|
||||
d->m_inventory->deSerialize(is);
|
||||
d->inventoryModified();
|
||||
|
||||
return d;
|
||||
}
|
||||
NodeMetadata* ChestNodeMetadata::clone()
|
||||
{
|
||||
ChestNodeMetadata *d = new ChestNodeMetadata();
|
||||
d->m_is_exo = m_is_exo;
|
||||
d->m_is_expanded = m_is_expanded;
|
||||
d->m_is_locked = m_is_locked;
|
||||
d->m_expanded_slot_id = m_expanded_slot_id;
|
||||
*d->m_inventory = *m_inventory;
|
||||
return d;
|
||||
}
|
||||
void ChestNodeMetadata::serializeBody(std::ostream &os)
|
||||
{
|
||||
os<<serializeString(m_owner);
|
||||
os<<serializeString(itos(m_is_exo ? 1 : 0));
|
||||
os<<serializeString(itos(m_is_expanded ? 1 : 0));
|
||||
os<<serializeString(itos(m_is_locked ? 1 : 0));
|
||||
os<<serializeString(itos(m_expanded_slot_id));
|
||||
m_inventory->serialize(os);
|
||||
}
|
||||
std::wstring ChestNodeMetadata::infoText()
|
||||
{
|
||||
char buff[256];
|
||||
if (m_is_locked) {
|
||||
snprintf(buff, 256, gettext("Locked Chest owned by '%s'"), m_owner.c_str());
|
||||
}else if (m_is_exo) {
|
||||
snprintf(buff, 256, gettext("Exo Chest"));
|
||||
}else{
|
||||
snprintf(buff, 256, gettext("Chest"));
|
||||
}
|
||||
return narrow_to_wide(buff);
|
||||
}
|
||||
Inventory* ChestNodeMetadata::getInventory()
|
||||
{
|
||||
return m_inventory;
|
||||
}
|
||||
void ChestNodeMetadata::inventoryModified()
|
||||
{
|
||||
int i;
|
||||
int k;
|
||||
int a[3] = {1,1,1};
|
||||
int ex = 0;
|
||||
Inventory *inv;
|
||||
InventoryList *il;
|
||||
InventoryList *im;
|
||||
InventoryItem *itm;
|
||||
InventoryList *l = m_inventory->getList("upgrades");
|
||||
InventoryList *m = m_inventory->getList("main");
|
||||
if (!l || !m)
|
||||
return;
|
||||
|
||||
for (i=0; i<2; i++) {
|
||||
itm = l->getItem(i);
|
||||
if (!itm)
|
||||
continue;
|
||||
if (itm->getContent() == CONTENT_CHEST) {
|
||||
if (m_is_expanded) {
|
||||
ex = 1;
|
||||
continue;
|
||||
}
|
||||
if (m_is_exo)
|
||||
continue;
|
||||
inv = new Inventory();
|
||||
inv->addList("upgrades", 2);
|
||||
inv->addList("main", 36);
|
||||
il = inv->getList("upgrades");
|
||||
im = inv->getList("main");
|
||||
if (!il || !im) {
|
||||
delete inv;
|
||||
continue;
|
||||
}
|
||||
for (k=0; k<2; k++) {
|
||||
itm = l->changeItem(k,NULL);
|
||||
if (itm)
|
||||
il->addItem(k,itm);
|
||||
}
|
||||
for (k=0; k<18; k++) {
|
||||
itm = m->changeItem(k,NULL);
|
||||
if (itm)
|
||||
im->addItem(k,itm);
|
||||
}
|
||||
delete m_inventory;
|
||||
m_inventory = inv;
|
||||
l = il;
|
||||
m = im;
|
||||
a[2] = 0;
|
||||
ex = 1;
|
||||
m_is_expanded = true;
|
||||
m_expanded_slot_id = i;
|
||||
}else if (itm->getContent() == CONTENT_TOOLITEM_KEY) {
|
||||
if (m_is_exo)
|
||||
continue;
|
||||
a[2] = 0;
|
||||
m_is_locked = true;
|
||||
}else if (itm->getContent() == CONTENT_CRAFTITEM_OERKKI_DUST) {
|
||||
if (m_is_exo)
|
||||
continue;
|
||||
if (m->getUsedSlots() != 0)
|
||||
continue;
|
||||
if (l->getUsedSlots() != 1)
|
||||
continue;
|
||||
if (m_is_locked)
|
||||
continue;
|
||||
if (m_is_expanded)
|
||||
continue;
|
||||
m_is_exo = true;
|
||||
a[0] = 0;
|
||||
a[1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_is_expanded && !ex) {
|
||||
inv = new Inventory();
|
||||
inv->addList("upgrades", 2);
|
||||
inv->addList("main", 18);
|
||||
il = inv->getList("upgrades");
|
||||
im = inv->getList("main");
|
||||
if (!il || !im) {
|
||||
delete inv;
|
||||
}else{
|
||||
for (k=0; k<2; k++) {
|
||||
itm = l->changeItem(k,NULL);
|
||||
if (itm)
|
||||
il->addItem(k,itm);
|
||||
}
|
||||
for (k=0; k<36; k++) {
|
||||
itm = m->changeItem(k,NULL);
|
||||
if (itm) {
|
||||
if (k > 17) {
|
||||
im->addItem(itm);
|
||||
}else{
|
||||
im->addItem(k,itm);
|
||||
}
|
||||
}
|
||||
}
|
||||
delete m_inventory;
|
||||
m_inventory = inv;
|
||||
l = il;
|
||||
m = im;
|
||||
m_is_expanded = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_is_expanded || m_is_locked || m->getUsedSlots() != 0)
|
||||
a[2] = 0;
|
||||
|
||||
l->clearAllowed();
|
||||
if (a[0])
|
||||
l->addAllowed(CONTENT_CHEST);
|
||||
if (a[1])
|
||||
l->addAllowed(CONTENT_TOOLITEM_KEY);
|
||||
if (a[2])
|
||||
l->addAllowed(CONTENT_CRAFTITEM_OERKKI_DUST);
|
||||
}
|
||||
bool ChestNodeMetadata::nodeRemovalDisabled()
|
||||
{
|
||||
/*
|
||||
Disable removal if chest contains something
|
||||
*/
|
||||
InventoryList *list = m_inventory->getList("main");
|
||||
if(list == NULL)
|
||||
return false;
|
||||
if(list->getUsedSlots() == 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
std::string ChestNodeMetadata::getDrawSpecString(Player *player)
|
||||
{
|
||||
std::string spec("size[9,10]");
|
||||
|
||||
if (!m_is_exo) {
|
||||
InventoryList *l = m_inventory->getList("main");
|
||||
if (m_is_expanded && l && l->getUsedSlots() > 18) {
|
||||
if (m_expanded_slot_id == 0) {
|
||||
spec += "list[current_name;upgrades;1,0;1,1;1,1;]";
|
||||
}else{
|
||||
spec += "list[current_name;upgrades;0,0;1,1;0,1;]";
|
||||
}
|
||||
}else{
|
||||
spec += "list[current_name;upgrades;0,0;2,1;]";
|
||||
}
|
||||
}
|
||||
|
||||
if (m_is_expanded) {
|
||||
spec += "list[current_name;main;0,1;9,4;]";
|
||||
}else if (m_is_exo) {
|
||||
spec += "list[current_player;exo;1.5,1.5;6,3;]";
|
||||
}else{
|
||||
spec += "list[current_name;main;1.5,1.5;6,3;]";
|
||||
}
|
||||
|
||||
spec += "list[current_player;main;0.5,5.8;8,1;0,8;]";
|
||||
spec += "list[current_player;main;0.5,7;8,3;8,-1;]";
|
||||
|
||||
return spec;
|
||||
}
|
||||
std::vector<NodeBox> ChestNodeMetadata::getNodeBoxes(MapNode &n)
|
||||
{
|
||||
std::vector<NodeBox> boxes;
|
||||
return boxes;
|
||||
}
|
||||
std::string ChestNodeMetadata::getOwner()
|
||||
{
|
||||
if (m_is_locked)
|
||||
return m_owner;
|
||||
return "";
|
||||
}
|
||||
std::string ChestNodeMetadata::getInventoryOwner()
|
||||
{
|
||||
if (m_is_locked)
|
||||
return m_owner;
|
||||
return "";
|
||||
}
|
|
@ -31,48 +31,48 @@
|
|||
|
||||
|
||||
/*
|
||||
ChestNodeMetadata
|
||||
DeprecatedChestNodeMetadata
|
||||
*/
|
||||
|
||||
// Prototype
|
||||
ChestNodeMetadata proto_ChestNodeMetadata;
|
||||
DeprecatedChestNodeMetadata proto_DeprecatedChestNodeMetadata;
|
||||
|
||||
ChestNodeMetadata::ChestNodeMetadata()
|
||||
DeprecatedChestNodeMetadata::DeprecatedChestNodeMetadata()
|
||||
{
|
||||
NodeMetadata::registerType(typeId(), create);
|
||||
|
||||
m_inventory = new Inventory();
|
||||
m_inventory->addList("0", 8*4);
|
||||
}
|
||||
ChestNodeMetadata::~ChestNodeMetadata()
|
||||
DeprecatedChestNodeMetadata::~DeprecatedChestNodeMetadata()
|
||||
{
|
||||
delete m_inventory;
|
||||
}
|
||||
u16 ChestNodeMetadata::typeId() const
|
||||
u16 DeprecatedChestNodeMetadata::typeId() const
|
||||
{
|
||||
return CONTENT_CHEST;
|
||||
return CONTENT_CHEST_DEPRECATED;
|
||||
}
|
||||
NodeMetadata* ChestNodeMetadata::create(std::istream &is)
|
||||
NodeMetadata* DeprecatedChestNodeMetadata::create(std::istream &is)
|
||||
{
|
||||
ChestNodeMetadata *d = new ChestNodeMetadata();
|
||||
DeprecatedChestNodeMetadata *d = new DeprecatedChestNodeMetadata();
|
||||
d->m_inventory->deSerialize(is);
|
||||
return d;
|
||||
}
|
||||
NodeMetadata* ChestNodeMetadata::clone()
|
||||
NodeMetadata* DeprecatedChestNodeMetadata::clone()
|
||||
{
|
||||
ChestNodeMetadata *d = new ChestNodeMetadata();
|
||||
DeprecatedChestNodeMetadata *d = new DeprecatedChestNodeMetadata();
|
||||
*d->m_inventory = *m_inventory;
|
||||
return d;
|
||||
}
|
||||
void ChestNodeMetadata::serializeBody(std::ostream &os)
|
||||
void DeprecatedChestNodeMetadata::serializeBody(std::ostream &os)
|
||||
{
|
||||
m_inventory->serialize(os);
|
||||
}
|
||||
std::wstring ChestNodeMetadata::infoText()
|
||||
std::wstring DeprecatedChestNodeMetadata::infoText()
|
||||
{
|
||||
return narrow_to_wide(gettext("Chest"));
|
||||
}
|
||||
bool ChestNodeMetadata::nodeRemovalDisabled()
|
||||
bool DeprecatedChestNodeMetadata::nodeRemovalDisabled()
|
||||
{
|
||||
/*
|
||||
Disable removal if chest contains something
|
||||
|
@ -84,69 +84,69 @@ bool ChestNodeMetadata::nodeRemovalDisabled()
|
|||
return false;
|
||||
return true;
|
||||
}
|
||||
std::string ChestNodeMetadata::getDrawSpecString(Player *player)
|
||||
std::string DeprecatedChestNodeMetadata::getDrawSpecString(Player *player)
|
||||
{
|
||||
return
|
||||
"size[8,9]"
|
||||
"list[current_name;0;0,0;8,4;]"
|
||||
"list[current_player;main;0,5;8,4;]";
|
||||
}
|
||||
bool ChestNodeMetadata::import(NodeMetadata *meta)
|
||||
bool DeprecatedChestNodeMetadata::import(NodeMetadata *meta)
|
||||
{
|
||||
if (meta->typeId() != CONTENT_LOCKABLE_CHEST)
|
||||
if (meta->typeId() != CONTENT_LOCKABLE_CHEST_DEPRECATED)
|
||||
return false;
|
||||
LockingChestNodeMetadata *l = (LockingChestNodeMetadata*)meta;
|
||||
LockingDeprecatedChestNodeMetadata *l = (LockingDeprecatedChestNodeMetadata*)meta;
|
||||
*m_inventory = *l->getInventory();
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
LockingChestNodeMetadata
|
||||
LockingDeprecatedChestNodeMetadata
|
||||
*/
|
||||
|
||||
// Prototype
|
||||
LockingChestNodeMetadata proto_LockingChestNodeMetadata;
|
||||
LockingDeprecatedChestNodeMetadata proto_LockingDeprecatedChestNodeMetadata;
|
||||
|
||||
LockingChestNodeMetadata::LockingChestNodeMetadata()
|
||||
LockingDeprecatedChestNodeMetadata::LockingDeprecatedChestNodeMetadata()
|
||||
{
|
||||
NodeMetadata::registerType(typeId(), create);
|
||||
|
||||
m_inventory = new Inventory();
|
||||
m_inventory->addList("0", 8*4);
|
||||
}
|
||||
LockingChestNodeMetadata::~LockingChestNodeMetadata()
|
||||
LockingDeprecatedChestNodeMetadata::~LockingDeprecatedChestNodeMetadata()
|
||||
{
|
||||
delete m_inventory;
|
||||
}
|
||||
u16 LockingChestNodeMetadata::typeId() const
|
||||
u16 LockingDeprecatedChestNodeMetadata::typeId() const
|
||||
{
|
||||
return CONTENT_LOCKABLE_CHEST;
|
||||
return CONTENT_LOCKABLE_CHEST_DEPRECATED;
|
||||
}
|
||||
NodeMetadata* LockingChestNodeMetadata::create(std::istream &is)
|
||||
NodeMetadata* LockingDeprecatedChestNodeMetadata::create(std::istream &is)
|
||||
{
|
||||
LockingChestNodeMetadata *d = new LockingChestNodeMetadata();
|
||||
LockingDeprecatedChestNodeMetadata *d = new LockingDeprecatedChestNodeMetadata();
|
||||
d->setOwner(deSerializeString(is));
|
||||
d->m_inventory->deSerialize(is);
|
||||
return d;
|
||||
}
|
||||
NodeMetadata* LockingChestNodeMetadata::clone()
|
||||
NodeMetadata* LockingDeprecatedChestNodeMetadata::clone()
|
||||
{
|
||||
LockingChestNodeMetadata *d = new LockingChestNodeMetadata();
|
||||
LockingDeprecatedChestNodeMetadata *d = new LockingDeprecatedChestNodeMetadata();
|
||||
*d->m_inventory = *m_inventory;
|
||||
return d;
|
||||
}
|
||||
void LockingChestNodeMetadata::serializeBody(std::ostream &os)
|
||||
void LockingDeprecatedChestNodeMetadata::serializeBody(std::ostream &os)
|
||||
{
|
||||
os<<serializeString(m_owner);
|
||||
m_inventory->serialize(os);
|
||||
}
|
||||
std::wstring LockingChestNodeMetadata::infoText()
|
||||
std::wstring LockingDeprecatedChestNodeMetadata::infoText()
|
||||
{
|
||||
char buff[256];
|
||||
snprintf(buff, 256, gettext("Locking Chest owned by '%s'"), m_owner.c_str());
|
||||
return narrow_to_wide(buff);
|
||||
}
|
||||
bool LockingChestNodeMetadata::nodeRemovalDisabled()
|
||||
bool LockingDeprecatedChestNodeMetadata::nodeRemovalDisabled()
|
||||
{
|
||||
/*
|
||||
Disable removal if chest contains something
|
||||
|
@ -158,18 +158,18 @@ bool LockingChestNodeMetadata::nodeRemovalDisabled()
|
|||
return false;
|
||||
return true;
|
||||
}
|
||||
std::string LockingChestNodeMetadata::getDrawSpecString(Player *player)
|
||||
std::string LockingDeprecatedChestNodeMetadata::getDrawSpecString(Player *player)
|
||||
{
|
||||
return
|
||||
"size[8,9]"
|
||||
"list[current_name;0;0,0;8,4;]"
|
||||
"list[current_player;main;0,5;8,4;]";
|
||||
}
|
||||
bool LockingChestNodeMetadata::import(NodeMetadata *meta)
|
||||
bool LockingDeprecatedChestNodeMetadata::import(NodeMetadata *meta)
|
||||
{
|
||||
if (meta->typeId() != CONTENT_CHEST)
|
||||
if (meta->typeId() != CONTENT_CHEST_DEPRECATED)
|
||||
return false;
|
||||
ChestNodeMetadata *l = (ChestNodeMetadata*)meta;
|
||||
DeprecatedChestNodeMetadata *l = (DeprecatedChestNodeMetadata*)meta;
|
||||
*m_inventory = *l->getInventory();
|
||||
return true;
|
||||
}
|
||||
|
@ -241,9 +241,9 @@ std::string SafeNodeMetadata::getDrawSpecString(Player *player)
|
|||
}
|
||||
bool SafeNodeMetadata::import(NodeMetadata *meta)
|
||||
{
|
||||
if (meta->typeId() != CONTENT_CHEST)
|
||||
if (meta->typeId() != CONTENT_CHEST_DEPRECATED)
|
||||
return false;
|
||||
ChestNodeMetadata *l = (ChestNodeMetadata*)meta;
|
||||
DeprecatedChestNodeMetadata *l = (DeprecatedChestNodeMetadata*)meta;
|
||||
*m_inventory = *l->getInventory();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
* for Voxelands.
|
||||
************************************************************************/
|
||||
|
||||
#include "common.h"
|
||||
#include "nodemetadata.h"
|
||||
#include "utility.h"
|
||||
#include "mapnode.h"
|
||||
|
@ -30,7 +31,6 @@
|
|||
#include "inventory.h"
|
||||
#include <sstream>
|
||||
#include "content_mapnode.h"
|
||||
#include "log.h"
|
||||
|
||||
/*
|
||||
NodeMetadata
|
||||
|
@ -62,8 +62,7 @@ NodeMetadata* NodeMetadata::deSerialize(std::istream &is)
|
|||
if(n == NULL)
|
||||
{
|
||||
// If factory is not found, just return.
|
||||
infostream<<"WARNING: NodeMetadata: No factory for typeId="
|
||||
<<id<<std::endl;
|
||||
vlprintf(CN_INFO,"WARNING: NodeMetadata: No factory for typeId=%d",id);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -78,7 +77,7 @@ NodeMetadata* NodeMetadata::deSerialize(std::istream &is)
|
|||
}
|
||||
catch(SerializationError &e)
|
||||
{
|
||||
infostream<<"WARNING: NodeMetadata: ignoring SerializationError"<<std::endl;
|
||||
vlprintf(CN_INFO,"WARNING: NodeMetadata: ignoring SerializationError '%s'",e.what());
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -144,8 +143,7 @@ void NodeMetadataList::deSerialize(std::istream &is)
|
|||
u16 version = readU16(buf);
|
||||
|
||||
if (version > 1) {
|
||||
infostream<<__FUNCTION_NAME<<": version "<<version<<" not supported"
|
||||
<<std::endl;
|
||||
vlprintf(CN_INFO,"NodeMetadataList::deSerialize: version %u not supported",version);
|
||||
throw SerializationError("NodeMetadataList::deSerialize");
|
||||
}
|
||||
|
||||
|
@ -169,10 +167,7 @@ void NodeMetadataList::deSerialize(std::istream &is)
|
|||
continue;
|
||||
|
||||
if (m_data.find(p)) {
|
||||
infostream<<"WARNING: NodeMetadataList::deSerialize(): "
|
||||
<<"already set data at position"
|
||||
<<"("<<p.X<<","<<p.Y<<","<<p.Z<<"): Ignoring."
|
||||
<<std::endl;
|
||||
vlprintf(CN_INFO,"WARNING: NodeMetadataList::deSerialize(): already set data at position (%d,%d,%d): Ignoring.",p.X,p.Y,p.Z);
|
||||
delete data;
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -95,6 +95,9 @@ void Player::resetInventory(bool include_clothes)
|
|||
inventory.clear();
|
||||
}else{
|
||||
InventoryList *l = inventory.getList("main");
|
||||
if (l)
|
||||
l->clearItems();
|
||||
l = inventory.getList("exo");
|
||||
if (l)
|
||||
l->clearItems();
|
||||
l = inventory.getList("discard");
|
||||
|
@ -114,6 +117,8 @@ void Player::checkInventory()
|
|||
{
|
||||
if (!inventory.getList("main"))
|
||||
inventory.addList("main", PLAYER_INVENTORY_SIZE);
|
||||
if (!inventory.getList("exo"))
|
||||
inventory.addList("exo", 18);
|
||||
if (!inventory.getList("hat"))
|
||||
inventory.addList("hat",1);
|
||||
if (!inventory.getList("jacket"))
|
||||
|
|
|
@ -3079,7 +3079,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||
if (
|
||||
meta
|
||||
&& (
|
||||
meta->typeId() == CONTENT_LOCKABLE_CHEST
|
||||
meta->typeId() == CONTENT_LOCKABLE_CHEST_DEPRECATED
|
||||
|| meta->typeId() == CONTENT_LOCKABLE_SIGN
|
||||
|| meta->typeId() == CONTENT_LOCKABLE_SIGN_WALL
|
||||
|| meta->typeId() == CONTENT_LOCKABLE_SIGN_UD
|
||||
|
@ -4394,8 +4394,8 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||
p.Z = mystoi(fn.next(","));
|
||||
NodeMetadata *meta = m_env.getMap().getNodeMetadata(p);
|
||||
if (meta) {
|
||||
if (meta->typeId() == CONTENT_LOCKABLE_CHEST) {
|
||||
LockingChestNodeMetadata *lcm = (LockingChestNodeMetadata*)meta;
|
||||
if (meta->typeId() == CONTENT_LOCKABLE_CHEST_DEPRECATED) {
|
||||
LockingDeprecatedChestNodeMetadata *lcm = (LockingDeprecatedChestNodeMetadata*)meta;
|
||||
if (lcm->getInventoryOwner() != player->getName())
|
||||
return;
|
||||
}else if (meta->typeId() == CONTENT_LOCKABLE_FURNACE) {
|
||||
|
@ -4423,8 +4423,8 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||
p.Z = mystoi(fn.next(","));
|
||||
NodeMetadata *meta = m_env.getMap().getNodeMetadata(p);
|
||||
if (meta) {
|
||||
if (meta->typeId() == CONTENT_LOCKABLE_CHEST) {
|
||||
LockingChestNodeMetadata *lcm = (LockingChestNodeMetadata*)meta;
|
||||
if (meta->typeId() == CONTENT_LOCKABLE_CHEST_DEPRECATED) {
|
||||
LockingDeprecatedChestNodeMetadata *lcm = (LockingDeprecatedChestNodeMetadata*)meta;
|
||||
if (lcm->getInventoryOwner() != player->getName())
|
||||
return;
|
||||
}else if (meta->typeId() == CONTENT_LOCKABLE_FURNACE) {
|
||||
|
@ -4755,8 +4755,7 @@ void Server::onMapEditEvent(MapEditEvent *event)
|
|||
|
||||
Inventory* Server::getInventory(InventoryContext *c, std::string id)
|
||||
{
|
||||
if(id == "current_player")
|
||||
{
|
||||
if (id == "current_player") {
|
||||
assert(c->current_player);
|
||||
return &(c->current_player->inventory);
|
||||
}
|
||||
|
@ -4764,14 +4763,13 @@ Inventory* Server::getInventory(InventoryContext *c, std::string id)
|
|||
Strfnd fn(id);
|
||||
std::string id0 = fn.next(":");
|
||||
|
||||
if(id0 == "nodemeta")
|
||||
{
|
||||
if (id0 == "nodemeta") {
|
||||
v3s16 p;
|
||||
p.X = mystoi(fn.next(","));
|
||||
p.Y = mystoi(fn.next(","));
|
||||
p.Z = mystoi(fn.next(","));
|
||||
NodeMetadata *meta = m_env.getMap().getNodeMetadata(p);
|
||||
if(meta)
|
||||
if (meta)
|
||||
return meta->getInventory();
|
||||
infostream<<"nodemeta at ("<<p.X<<","<<p.Y<<","<<p.Z<<"): "
|
||||
<<"no metadata found"<<std::endl;
|
||||
|
@ -4783,8 +4781,7 @@ Inventory* Server::getInventory(InventoryContext *c, std::string id)
|
|||
}
|
||||
void Server::inventoryModified(InventoryContext *c, std::string id)
|
||||
{
|
||||
if(id == "current_player")
|
||||
{
|
||||
if (id == "current_player") {
|
||||
assert(c->current_player);
|
||||
// Send inventory
|
||||
UpdateCrafting(c->current_player->peer_id);
|
||||
|
|