add locking signs and furnaces
This commit is contained in:
parent
f409876950
commit
687ab0f8c6
Binary file not shown.
After Width: | Height: | Size: 318 B |
Binary file not shown.
After Width: | Height: | Size: 423 B |
Binary file not shown.
After Width: | Height: | Size: 415 B |
Binary file not shown.
After Width: | Height: | Size: 419 B |
|
@ -148,9 +148,10 @@ CONTENT_FIRE_SHORTTERM,
|
|||
CONTENT_TORCH,
|
||||
CONTENT_SIGN_WALL,
|
||||
CONTENT_SIGN,
|
||||
CONTENT_LOCKABLE_SIGN,
|
||||
CONTENT_CHEST,
|
||||
CONTENT_LOCKABLE_CHEST,
|
||||
CONTENT_FURNACE,
|
||||
CONTENT_LOCKABLE_FURNACE,
|
||||
CONTENT_INCINERATOR,
|
||||
CONTENT_ROUGHSTONE,
|
||||
CONTENT_COBBLE,
|
||||
|
|
|
@ -3147,6 +3147,99 @@ void content_mapnode_init()
|
|||
));
|
||||
f->setInventoryTextureNodeBox(i,"sign.png", "sign_front.png", "sign.png");
|
||||
|
||||
i = CONTENT_LOCKABLE_SIGN_WALL;
|
||||
f = &content_features(i);
|
||||
f->description = std::string("Locking Sign");
|
||||
f->setAllTextures("sign_wall_lock.png");
|
||||
f->setInventoryTexture("sign_lock_inventory.png");
|
||||
f->param_type = CPT_LIGHT;
|
||||
f->draw_type = CDT_SIGNLIKE;
|
||||
f->light_propagates = true;
|
||||
f->sunlight_propagates = true;
|
||||
f->solidness = 0; // drawn separately, makes no faces
|
||||
f->walkable = false;
|
||||
f->wall_mounted = true;
|
||||
f->air_equivalent = true;
|
||||
f->flammable = 1; // can be replaced by fire if the node under it is set on fire
|
||||
f->fuel_time = 1;
|
||||
f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_LOCKABLE_SIGN)+" 1";
|
||||
if(f->initial_metadata == NULL)
|
||||
f->initial_metadata = new LockingSignNodeMetadata("Some sign");
|
||||
f->digging_properties.set("", DiggingProperties(true, 0.5, 0));
|
||||
|
||||
i = CONTENT_LOCKABLE_SIGN;
|
||||
f = &content_features(i);
|
||||
f->description = std::string("Locking Sign");
|
||||
f->setAllTextures("sign.png");
|
||||
f->setTexture(4, "sign_back.png");
|
||||
f->setTexture(5, "sign_lock.png"); // Z-
|
||||
f->param_type = CPT_LIGHT;
|
||||
f->light_propagates = true;
|
||||
f->sunlight_propagates = true;
|
||||
f->param2_type = CPT_FACEDIR_SIMPLE;
|
||||
f->draw_type = CDT_NODEBOX;
|
||||
f->solidness = 0; // drawn separately, makes no faces
|
||||
f->flammable = 1; // can be replaced by fire if the node under it is set on fire
|
||||
f->fuel_time = 1;
|
||||
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||
if(f->initial_metadata == NULL)
|
||||
f->initial_metadata = new LockingSignNodeMetadata("Some sign");
|
||||
f->digging_properties.set("", DiggingProperties(true, 0.5, 0));
|
||||
f->setNodeBox(core::aabbox3d<f32>(
|
||||
-0.05*BS,
|
||||
-0.5*BS,
|
||||
-0.05*BS,
|
||||
0.05*BS,
|
||||
0.5*BS,
|
||||
0.05*BS
|
||||
));
|
||||
f->addNodeBox(core::aabbox3d<f32>(
|
||||
-0.4*BS,
|
||||
0.,
|
||||
-0.1*BS,
|
||||
0.4*BS,
|
||||
0.4*BS,
|
||||
-0.05*BS
|
||||
));
|
||||
f->setInventoryTextureNodeBox(i,"sign.png", "sign_lock.png", "sign.png");
|
||||
crafting::set1Any2Recipe(CONTENT_SIGN,CONTENT_CRAFTITEM_STEEL_INGOT,CONTENT_LOCKABLE_SIGN);
|
||||
|
||||
i = CONTENT_LOCKABLE_SIGN_UD;
|
||||
f = &content_features(i);
|
||||
f->description = std::string("Locking Sign");
|
||||
f->setAllTextures("sign.png");
|
||||
f->setTexture(4, "sign_back_ud.png");
|
||||
f->setTexture(5, "sign_lock_ud.png"); // Z-
|
||||
f->param_type = CPT_LIGHT;
|
||||
f->light_propagates = true;
|
||||
f->sunlight_propagates = true;
|
||||
f->param2_type = CPT_FACEDIR_SIMPLE;
|
||||
f->draw_type = CDT_NODEBOX;
|
||||
f->solidness = 0; // drawn separately, makes no faces
|
||||
f->flammable = 1; // can be replaced by fire if the node under it is set on fire
|
||||
f->fuel_time = 1;
|
||||
f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_LOCKABLE_SIGN)+" 1";
|
||||
if(f->initial_metadata == NULL)
|
||||
f->initial_metadata = new LockingSignNodeMetadata("Some sign");
|
||||
f->digging_properties.set("", DiggingProperties(true, 0.5, 0));
|
||||
f->setNodeBox(core::aabbox3d<f32>(
|
||||
-0.05*BS,
|
||||
-0.5*BS,
|
||||
-0.05*BS,
|
||||
0.05*BS,
|
||||
0.5*BS,
|
||||
0.05*BS
|
||||
));
|
||||
f->addNodeBox(core::aabbox3d<f32>(
|
||||
-0.4*BS,
|
||||
-0.4*BS,
|
||||
-0.1*BS,
|
||||
0.4*BS,
|
||||
0.,
|
||||
-0.05*BS
|
||||
));
|
||||
f->setInventoryTextureNodeBox(i,"sign.png", "sign_lock.png", "sign.png");
|
||||
|
||||
i = CONTENT_CHEST;
|
||||
f = &content_features(i);
|
||||
f->description = std::string("Chest");
|
||||
|
@ -3204,6 +3297,21 @@ void content_mapnode_init()
|
|||
setStoneLikeDiggingProperties(f->digging_properties, 3.0);
|
||||
crafting::setRoundRecipe(CONTENT_ROUGHSTONE,CONTENT_FURNACE);
|
||||
|
||||
i = CONTENT_LOCKABLE_FURNACE;
|
||||
f = &content_features(i);
|
||||
f->description = std::string("Locking Furnace");
|
||||
f->param_type = CPT_FACEDIR_SIMPLE;
|
||||
f->draw_type = CDT_CUBELIKE;
|
||||
f->setAllTextures("furnace_side.png");
|
||||
f->setTexture(5, "furnace_lock.png"); // Z-
|
||||
f->setInventoryTextureCube("furnace_side.png", "furnace_lock.png", "furnace_side.png");
|
||||
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||
if(f->initial_metadata == NULL)
|
||||
f->initial_metadata = new LockingFurnaceNodeMetadata();
|
||||
setStoneLikeDiggingProperties(f->digging_properties, 3.0);
|
||||
crafting::setFilledRoundRecipe(CONTENT_ROUGHSTONE,CONTENT_CRAFTITEM_STEEL_INGOT,CONTENT_LOCKABLE_FURNACE);
|
||||
crafting::set1Any2Recipe(CONTENT_FURNACE,CONTENT_CRAFTITEM_STEEL_INGOT,CONTENT_LOCKABLE_FURNACE);
|
||||
|
||||
i = CONTENT_INCINERATOR;
|
||||
f = &content_features(i);
|
||||
f->description = std::string("Incinerator");
|
||||
|
|
|
@ -54,9 +54,12 @@ MapNode mapnode_translate_to_internal(MapNode n_from, u8 version);
|
|||
#define CONTENT_LOCKABLE_CHEST 17
|
||||
#define CONTENT_SIGN 18
|
||||
#define CONTENT_SIGN_UD 19
|
||||
// FREE 20
|
||||
#define CONTENT_LOCKABLE_FURNACE 20
|
||||
#define CONTENT_FENCE 21
|
||||
// FREE 22-29
|
||||
#define CONTENT_LOCKABLE_SIGN_WALL 22
|
||||
#define CONTENT_LOCKABLE_SIGN 23
|
||||
#define CONTENT_LOCKABLE_SIGN_UD 24
|
||||
// FREE 25-29
|
||||
#define CONTENT_RAIL 30
|
||||
#define CONTENT_LADDER 31
|
||||
#define CONTENT_LAVA 32
|
||||
|
|
|
@ -57,6 +57,43 @@ std::string SignNodeMetadata::infoText()
|
|||
return std::string("\"")+m_text+"\"";
|
||||
}
|
||||
|
||||
/*
|
||||
LockingSignNodeMetadata
|
||||
*/
|
||||
|
||||
// Prototype
|
||||
LockingSignNodeMetadata proto_LockingSignNodeMetadata("");
|
||||
|
||||
LockingSignNodeMetadata::LockingSignNodeMetadata(std::string text):
|
||||
m_text(text)
|
||||
{
|
||||
NodeMetadata::registerType(typeId(), create);
|
||||
}
|
||||
u16 LockingSignNodeMetadata::typeId() const
|
||||
{
|
||||
return CONTENT_LOCKABLE_SIGN_WALL;
|
||||
}
|
||||
NodeMetadata* LockingSignNodeMetadata::create(std::istream &is)
|
||||
{
|
||||
std::string text = deSerializeString(is);
|
||||
LockingSignNodeMetadata *d = new LockingSignNodeMetadata(text);
|
||||
d->setOwner(deSerializeString(is));
|
||||
return d;
|
||||
}
|
||||
NodeMetadata* LockingSignNodeMetadata::clone()
|
||||
{
|
||||
return new LockingSignNodeMetadata(m_text);
|
||||
}
|
||||
void LockingSignNodeMetadata::serializeBody(std::ostream &os)
|
||||
{
|
||||
os<<serializeString(m_text);
|
||||
os<<serializeString(m_owner);
|
||||
}
|
||||
std::string LockingSignNodeMetadata::infoText()
|
||||
{
|
||||
return std::string("(")+m_owner+") \""+m_text+"\"";
|
||||
}
|
||||
|
||||
/*
|
||||
ChestNodeMetadata
|
||||
*/
|
||||
|
@ -156,12 +193,12 @@ NodeMetadata* LockingChestNodeMetadata::clone()
|
|||
}
|
||||
void LockingChestNodeMetadata::serializeBody(std::ostream &os)
|
||||
{
|
||||
os<<serializeString(m_text);
|
||||
os<<serializeString(m_owner);
|
||||
m_inventory->serialize(os);
|
||||
}
|
||||
std::string LockingChestNodeMetadata::infoText()
|
||||
{
|
||||
return std::string("Locking Chest owned by '")+m_text+"'";
|
||||
return std::string("Locking Chest owned by '")+m_owner+"'";
|
||||
}
|
||||
bool LockingChestNodeMetadata::nodeRemovalDisabled()
|
||||
{
|
||||
|
@ -477,6 +514,246 @@ std::string FurnaceNodeMetadata::getInventoryDrawSpecString()
|
|||
"list[current_player;main;0,5;8,4;]";
|
||||
}
|
||||
|
||||
/*
|
||||
LockingFurnaceNodeMetadata
|
||||
*/
|
||||
|
||||
// Prototype
|
||||
LockingFurnaceNodeMetadata proto_LockingFurnaceNodeMetadata;
|
||||
|
||||
LockingFurnaceNodeMetadata::LockingFurnaceNodeMetadata()
|
||||
{
|
||||
NodeMetadata::registerType(typeId(), create);
|
||||
|
||||
m_inventory = new Inventory();
|
||||
m_inventory->addList("fuel", 1);
|
||||
m_inventory->addList("src", 1);
|
||||
m_inventory->addList("dst", 4);
|
||||
|
||||
m_step_accumulator = 0;
|
||||
m_fuel_totaltime = 0;
|
||||
m_fuel_time = 0;
|
||||
m_src_totaltime = 0;
|
||||
m_src_time = 0;
|
||||
m_lock = 0;
|
||||
}
|
||||
LockingFurnaceNodeMetadata::~LockingFurnaceNodeMetadata()
|
||||
{
|
||||
delete m_inventory;
|
||||
}
|
||||
u16 LockingFurnaceNodeMetadata::typeId() const
|
||||
{
|
||||
return CONTENT_LOCKABLE_FURNACE;
|
||||
}
|
||||
NodeMetadata* LockingFurnaceNodeMetadata::clone()
|
||||
{
|
||||
LockingFurnaceNodeMetadata *d = new LockingFurnaceNodeMetadata();
|
||||
*d->m_inventory = *m_inventory;
|
||||
return d;
|
||||
}
|
||||
NodeMetadata* LockingFurnaceNodeMetadata::create(std::istream &is)
|
||||
{
|
||||
LockingFurnaceNodeMetadata *d = new LockingFurnaceNodeMetadata();
|
||||
|
||||
d->m_inventory->deSerialize(is);
|
||||
d->setOwner(deSerializeString(is));
|
||||
d->setInventoryOwner(deSerializeString(is));
|
||||
|
||||
int temp;
|
||||
is>>temp;
|
||||
d->m_fuel_totaltime = (float)temp/10;
|
||||
is>>temp;
|
||||
d->m_fuel_time = (float)temp/10;
|
||||
is>>temp;
|
||||
d->m_lock = (float)temp/10;
|
||||
|
||||
return d;
|
||||
}
|
||||
void LockingFurnaceNodeMetadata::serializeBody(std::ostream &os)
|
||||
{
|
||||
m_inventory->serialize(os);
|
||||
os<<serializeString(m_owner);
|
||||
os<<serializeString(m_inv_owner);
|
||||
os<<itos(m_fuel_totaltime*10)<<" ";
|
||||
os<<itos(m_fuel_time*10)<<" ";
|
||||
os<<itos(m_lock*10)<<" ";
|
||||
}
|
||||
std::string LockingFurnaceNodeMetadata::infoText()
|
||||
{
|
||||
//return "Furnace";
|
||||
std::string ostr = m_owner;
|
||||
if (m_inv_owner != "")
|
||||
ostr += ","+m_inv_owner;
|
||||
if(m_fuel_time >= m_fuel_totaltime)
|
||||
{
|
||||
const InventoryList *src_list = m_inventory->getList("src");
|
||||
assert(src_list);
|
||||
const InventoryItem *src_item = src_list->getItem(0);
|
||||
|
||||
if(src_item && src_item->isCookable()) {
|
||||
InventoryList *dst_list = m_inventory->getList("dst");
|
||||
if(!dst_list->roomForCookedItem(src_item))
|
||||
return std::string("Locking Furnace (")+ostr+") is overloaded";
|
||||
return std::string("Locking Furnace (")+ostr+") is out of fuel";
|
||||
}
|
||||
else
|
||||
return std::string("Locking Furnace (")+ostr+") is inactive";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string s = std::string("Locking Furnace (")+ostr+") is active";
|
||||
// Do this so it doesn't always show (0%) for weak fuel
|
||||
if(m_fuel_totaltime > 3) {
|
||||
s += " (";
|
||||
s += itos(m_fuel_time/m_fuel_totaltime*100);
|
||||
s += "%)";
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
bool LockingFurnaceNodeMetadata::nodeRemovalDisabled()
|
||||
{
|
||||
/*
|
||||
Disable removal if furnace is not empty
|
||||
*/
|
||||
InventoryList *list[3] = {m_inventory->getList("src"),
|
||||
m_inventory->getList("dst"), m_inventory->getList("fuel")};
|
||||
|
||||
for(int i = 0; i < 3; i++) {
|
||||
if(list[i] == NULL)
|
||||
continue;
|
||||
if(list[i]->getUsedSlots() == 0)
|
||||
continue;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
void LockingFurnaceNodeMetadata::inventoryModified()
|
||||
{
|
||||
infostream<<"LockingFurnace inventory modification callback"<<std::endl;
|
||||
}
|
||||
bool LockingFurnaceNodeMetadata::step(float dtime)
|
||||
{
|
||||
if(dtime > 60.0)
|
||||
infostream<<"LockingFurnace stepping a long time ("<<dtime<<")"<<std::endl;
|
||||
// Update at a fixed frequency
|
||||
const float interval = 2.0;
|
||||
m_step_accumulator += dtime;
|
||||
bool changed = false;
|
||||
while(m_step_accumulator > interval)
|
||||
{
|
||||
m_step_accumulator -= interval;
|
||||
dtime = interval;
|
||||
|
||||
//infostream<<"Furnace step dtime="<<dtime<<std::endl;
|
||||
|
||||
InventoryList *dst_list = m_inventory->getList("dst");
|
||||
assert(dst_list);
|
||||
|
||||
InventoryList *src_list = m_inventory->getList("src");
|
||||
assert(src_list);
|
||||
InventoryItem *src_item = src_list->getItem(0);
|
||||
|
||||
bool room_available = false;
|
||||
|
||||
printf("%f\n",m_lock);
|
||||
if (src_item && src_item->isCookable()) {
|
||||
room_available = dst_list->roomForCookedItem(src_item);
|
||||
m_lock = 300.0;
|
||||
changed = true;
|
||||
}else if (m_lock < 0.0) {
|
||||
setInventoryOwner("");
|
||||
changed = true;
|
||||
}else{
|
||||
m_lock -= dtime;
|
||||
changed = true;
|
||||
}
|
||||
printf("%f\n\n",m_lock);
|
||||
|
||||
// Start only if there are free slots in dst, so that it can
|
||||
// accomodate any result item
|
||||
if (room_available) {
|
||||
m_src_totaltime = 3;
|
||||
}else{
|
||||
m_src_time = 0;
|
||||
m_src_totaltime = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
If fuel is burning, increment the burn counters.
|
||||
If item finishes cooking, move it to result.
|
||||
*/
|
||||
if (m_fuel_time < m_fuel_totaltime) {
|
||||
//infostream<<"Furnace is active"<<std::endl;
|
||||
m_fuel_time += dtime;
|
||||
m_src_time += dtime;
|
||||
if (m_src_time >= m_src_totaltime && m_src_totaltime > 0.001 && src_item) {
|
||||
InventoryItem *cookresult = src_item->createCookResult();
|
||||
dst_list->addItem(cookresult);
|
||||
src_list->decrementMaterials(1);
|
||||
m_src_time = 0;
|
||||
m_src_totaltime = 0;
|
||||
}
|
||||
changed = true;
|
||||
|
||||
// If the fuel was not used up this step, just keep burning it
|
||||
if (m_fuel_time < m_fuel_totaltime)
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
Get the source again in case it has all burned
|
||||
*/
|
||||
src_item = src_list->getItem(0);
|
||||
|
||||
/*
|
||||
If there is no source item, or the source item is not cookable,
|
||||
or the furnace is still cooking, or the furnace became overloaded, stop loop.
|
||||
*/
|
||||
if(src_item == NULL || !room_available || m_fuel_time < m_fuel_totaltime ||
|
||||
dst_list->roomForCookedItem(src_item) == false)
|
||||
{
|
||||
m_step_accumulator = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
//infostream<<"Furnace is out of fuel"<<std::endl;
|
||||
|
||||
InventoryList *fuel_list = m_inventory->getList("fuel");
|
||||
assert(fuel_list);
|
||||
InventoryItem *fuel_item = fuel_list->getItem(0);
|
||||
if (fuel_item && fuel_item->isFuel()) {
|
||||
if ((fuel_item->getContent()&CONTENT_CRAFTITEM_MASK) == CONTENT_CRAFTITEM_MASK) {
|
||||
m_fuel_totaltime = ((CraftItem*)fuel_item)->getFuelTime();
|
||||
}else if ((fuel_item->getContent()&CONTENT_TOOLITEM_MASK) == CONTENT_TOOLITEM_MASK) {
|
||||
m_fuel_totaltime = ((ToolItem*)fuel_item)->getFuelTime();
|
||||
}else{
|
||||
m_fuel_totaltime = ((MaterialItem*)fuel_item)->getFuelTime();
|
||||
}
|
||||
m_fuel_time = 0;
|
||||
content_t c = fuel_item->getContent();
|
||||
fuel_list->decrementMaterials(1);
|
||||
if (c == CONTENT_TOOLITEM_STEELBUCKET_LAVA) {
|
||||
fuel_list->addItem(0,new ToolItem(CONTENT_TOOLITEM_STEELBUCKET,0));
|
||||
}
|
||||
changed = true;
|
||||
}else{
|
||||
m_step_accumulator = 0;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
std::string LockingFurnaceNodeMetadata::getInventoryDrawSpecString()
|
||||
{
|
||||
return
|
||||
"invsize[8,9;]"
|
||||
"list[current_name;fuel;2,3;1,1;]"
|
||||
"list[current_name;src;2,1;1,1;]"
|
||||
"list[current_name;dst;5,1;2,2;]"
|
||||
"list[current_player;main;0,5;8,4;]";
|
||||
}
|
||||
|
||||
/*
|
||||
LockedDoorNodeMetadata
|
||||
*/
|
||||
|
|
|
@ -43,6 +43,31 @@ private:
|
|||
std::string m_text;
|
||||
};
|
||||
|
||||
class LockingSignNodeMetadata : public NodeMetadata
|
||||
{
|
||||
public:
|
||||
LockingSignNodeMetadata(std::string text);
|
||||
//~LockingSignNodeMetadata();
|
||||
|
||||
virtual u16 typeId() const;
|
||||
static NodeMetadata* create(std::istream &is);
|
||||
virtual NodeMetadata* clone();
|
||||
virtual void serializeBody(std::ostream &os);
|
||||
virtual std::string infoText();
|
||||
|
||||
virtual std::string getOwner(){ return m_owner; }
|
||||
virtual void setOwner(std::string t){ m_owner = t; }
|
||||
virtual std::string getInventoryOwner(){ return m_owner; }
|
||||
virtual void setInventoryOwner(std::string t){ m_owner = t; }
|
||||
|
||||
std::string getText(){ return m_text; }
|
||||
void setText(std::string t){ m_text = t; }
|
||||
|
||||
private:
|
||||
std::string m_text;
|
||||
std::string m_owner;
|
||||
};
|
||||
|
||||
class ChestNodeMetadata : public NodeMetadata
|
||||
{
|
||||
public:
|
||||
|
@ -77,12 +102,14 @@ public:
|
|||
virtual bool nodeRemovalDisabled();
|
||||
virtual std::string getInventoryDrawSpecString();
|
||||
|
||||
virtual std::string getOwner(){ return m_text; }
|
||||
virtual void setOwner(std::string t){ m_text = t; }
|
||||
virtual std::string getOwner(){ return m_owner; }
|
||||
virtual void setOwner(std::string t){ m_owner = t; }
|
||||
virtual std::string getInventoryOwner(){ return m_owner; }
|
||||
virtual void setInventoryOwner(std::string t){ m_owner = t; }
|
||||
|
||||
private:
|
||||
Inventory *m_inventory;
|
||||
std::string m_text;
|
||||
std::string m_owner;
|
||||
};
|
||||
|
||||
class BorderStoneNodeMetadata : public NodeMetadata
|
||||
|
@ -149,6 +176,40 @@ private:
|
|||
float m_src_time;
|
||||
};
|
||||
|
||||
class LockingFurnaceNodeMetadata : public NodeMetadata
|
||||
{
|
||||
public:
|
||||
LockingFurnaceNodeMetadata();
|
||||
~LockingFurnaceNodeMetadata();
|
||||
|
||||
virtual u16 typeId() const;
|
||||
virtual NodeMetadata* clone();
|
||||
static NodeMetadata* create(std::istream &is);
|
||||
virtual void serializeBody(std::ostream &os);
|
||||
virtual std::string infoText();
|
||||
virtual Inventory* getInventory() {return m_inventory;}
|
||||
virtual void inventoryModified();
|
||||
virtual bool step(float dtime);
|
||||
virtual bool nodeRemovalDisabled();
|
||||
virtual std::string getInventoryDrawSpecString();
|
||||
|
||||
virtual std::string getOwner(){ return m_owner; }
|
||||
virtual void setOwner(std::string t){ m_owner = t; }
|
||||
virtual std::string getInventoryOwner(){ return m_inv_owner; }
|
||||
virtual void setInventoryOwner(std::string t){ m_inv_owner = t; }
|
||||
|
||||
private:
|
||||
Inventory *m_inventory;
|
||||
float m_step_accumulator;
|
||||
float m_fuel_totaltime;
|
||||
float m_fuel_time;
|
||||
float m_src_totaltime;
|
||||
float m_src_time;
|
||||
std::string m_owner;
|
||||
std::string m_inv_owner;
|
||||
float m_lock;
|
||||
};
|
||||
|
||||
class TNTNodeMetadata : public NodeMetadata
|
||||
{
|
||||
public:
|
||||
|
|
10
src/game.cpp
10
src/game.cpp
|
@ -1839,9 +1839,13 @@ void the_game(
|
|||
&client);
|
||||
menu->setDrawSpec(draw_spec);
|
||||
menu->drop();
|
||||
}
|
||||
else if(meta && meta->typeId() == CONTENT_SIGN_WALL && !random_input)
|
||||
{
|
||||
}else if (
|
||||
meta
|
||||
&& (
|
||||
meta->typeId() == CONTENT_SIGN_WALL
|
||||
|| meta->typeId() == CONTENT_LOCKABLE_SIGN_WALL
|
||||
) && !random_input
|
||||
) {
|
||||
infostream<<"Sign node right-clicked"<<std::endl;
|
||||
|
||||
SignNodeMetadata *signmeta = (SignNodeMetadata*)meta;
|
||||
|
|
|
@ -67,9 +67,12 @@ public:
|
|||
// Used to make custom inventory menus.
|
||||
// See format in guiInventoryMenu.cpp.
|
||||
virtual std::string getInventoryDrawSpecString(){return "";}
|
||||
// primarily used for locking chests, but others can play too
|
||||
// the node owner - if not "" then only the owner can dig the node
|
||||
virtual std::string getOwner(){ return std::string(""); }
|
||||
virtual void setOwner(std::string t){ }
|
||||
// the inventory owner - if not "" then only the owner can modify
|
||||
virtual std::string getInventoryOwner(){ return std::string(""); }
|
||||
virtual void setInventoryOwner(std::string t){ }
|
||||
// used by tnt to arm it, but also for future circuitry
|
||||
// level is the amount of power
|
||||
// powersrc is the generator or such that created the power
|
||||
|
|
|
@ -2814,23 +2814,37 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||
<<std::endl;
|
||||
cannot_remove_node = true;
|
||||
}else if((getPlayerPrivs(player) & PRIV_SERVER) == 0) {
|
||||
s16 max_d = g_settings->getS16("borderstone_radius");
|
||||
v3s16 test_p;
|
||||
MapNode testnode;
|
||||
for(s16 z=-max_d; !cannot_remove_node && z<=max_d; z++) {
|
||||
for(s16 y=-max_d; !cannot_remove_node && y<=max_d; y++) {
|
||||
for(s16 x=-max_d; !cannot_remove_node && x<=max_d; x++) {
|
||||
test_p = p_under + v3s16(x,y,z);
|
||||
NodeMetadata *meta = m_env.getMap().getNodeMetadata(test_p);
|
||||
if (meta && meta->typeId() == CONTENT_BORDERSTONE) {
|
||||
BorderStoneNodeMetadata *bsm = (BorderStoneNodeMetadata*)meta;
|
||||
if (bsm->getOwner() != player->getName()) {
|
||||
cannot_remove_node = true;
|
||||
break;
|
||||
NodeMetadata *meta = m_env.getMap().getNodeMetadata(p_under);
|
||||
if (meta
|
||||
&& (
|
||||
meta->typeId() == CONTENT_LOCKABLE_CHEST
|
||||
|| meta->typeId() == CONTENT_LOCKABLE_SIGN
|
||||
|| meta->typeId() == CONTENT_LOCKABLE_SIGN_WALL
|
||||
|| meta->typeId() == CONTENT_LOCKABLE_SIGN_UD
|
||||
|| meta->typeId() == CONTENT_LOCKABLE_FURNACE
|
||||
)
|
||||
&& meta->getOwner() != player->getName()
|
||||
) {
|
||||
cannot_remove_node = true;
|
||||
}else{
|
||||
s16 max_d = g_settings->getS16("borderstone_radius");
|
||||
v3s16 test_p;
|
||||
MapNode testnode;
|
||||
for(s16 z=-max_d; !cannot_remove_node && z<=max_d; z++) {
|
||||
for(s16 y=-max_d; !cannot_remove_node && y<=max_d; y++) {
|
||||
for(s16 x=-max_d; !cannot_remove_node && x<=max_d; x++) {
|
||||
test_p = p_under + v3s16(x,y,z);
|
||||
NodeMetadata *meta = m_env.getMap().getNodeMetadata(test_p);
|
||||
if (meta && meta->typeId() == CONTENT_BORDERSTONE) {
|
||||
BorderStoneNodeMetadata *bsm = (BorderStoneNodeMetadata*)meta;
|
||||
if (bsm->getOwner() != player->getName()) {
|
||||
cannot_remove_node = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3495,6 +3509,12 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||
}else if (p_dir.Y != -1) {
|
||||
n.setContent(CONTENT_SIGN_WALL);
|
||||
}
|
||||
}else if (n.getContent() == CONTENT_LOCKABLE_SIGN) {
|
||||
if (p_dir.Y == 1) {
|
||||
n.setContent(CONTENT_LOCKABLE_SIGN_UD);
|
||||
}else if (p_dir.Y != -1) {
|
||||
n.setContent(CONTENT_LOCKABLE_SIGN_WALL);
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate direction for wall mounted stuff
|
||||
|
@ -3950,8 +3970,13 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||
NodeMetadata *meta = m_env.getMap().getNodeMetadata(p);
|
||||
if(!meta)
|
||||
return;
|
||||
if(meta->typeId() != CONTENT_SIGN_WALL)
|
||||
return;
|
||||
if(meta->typeId() != CONTENT_SIGN_WALL) {
|
||||
if (meta->typeId() != CONTENT_LOCKABLE_SIGN_WALL)
|
||||
return;
|
||||
LockingSignNodeMetadata *lsm = (LockingSignNodeMetadata*)meta;
|
||||
if (lsm->getOwner() != player->getName())
|
||||
return;
|
||||
}
|
||||
SignNodeMetadata *signmeta = (SignNodeMetadata*)meta;
|
||||
signmeta->setText(text);
|
||||
|
||||
|
@ -4058,7 +4083,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||
{
|
||||
return;
|
||||
}
|
||||
// if it's a locking chest, only allow the owner or server admins to move items
|
||||
// if it's a locking inventory, only allow the owner or server admins to move items
|
||||
else if (ma->from_inv != "current_player" && (getPlayerPrivs(player) & PRIV_SERVER) == 0)
|
||||
{
|
||||
Strfnd fn(ma->from_inv);
|
||||
|
@ -4070,10 +4095,17 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||
p.Y = stoi(fn.next(","));
|
||||
p.Z = stoi(fn.next(","));
|
||||
NodeMetadata *meta = m_env.getMap().getNodeMetadata(p);
|
||||
if(meta && meta->typeId() == CONTENT_LOCKABLE_CHEST) {
|
||||
LockingChestNodeMetadata *lcm = (LockingChestNodeMetadata*)meta;
|
||||
if (lcm->getOwner() != player->getName())
|
||||
return;
|
||||
if (meta) {
|
||||
if (meta->typeId() == CONTENT_LOCKABLE_CHEST) {
|
||||
LockingChestNodeMetadata *lcm = (LockingChestNodeMetadata*)meta;
|
||||
if (lcm->getInventoryOwner() != player->getName())
|
||||
return;
|
||||
}else if (meta->typeId() == CONTENT_LOCKABLE_FURNACE) {
|
||||
LockingFurnaceNodeMetadata *lfm = (LockingFurnaceNodeMetadata*)meta;
|
||||
std::string name = lfm->getInventoryOwner();
|
||||
if (name != "" && name != player->getName() && lfm->getOwner() != player->getName())
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4088,10 +4120,21 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||
p.Y = stoi(fn.next(","));
|
||||
p.Z = stoi(fn.next(","));
|
||||
NodeMetadata *meta = m_env.getMap().getNodeMetadata(p);
|
||||
if(meta && meta->typeId() == CONTENT_LOCKABLE_CHEST) {
|
||||
LockingChestNodeMetadata *lcm = (LockingChestNodeMetadata*)meta;
|
||||
if (lcm->getOwner() != player->getName())
|
||||
return;
|
||||
if (meta) {
|
||||
if (meta->typeId() == CONTENT_LOCKABLE_CHEST) {
|
||||
LockingChestNodeMetadata *lcm = (LockingChestNodeMetadata*)meta;
|
||||
if (lcm->getInventoryOwner() != player->getName())
|
||||
return;
|
||||
}else if (meta->typeId() == CONTENT_LOCKABLE_FURNACE) {
|
||||
LockingFurnaceNodeMetadata *lfm = (LockingFurnaceNodeMetadata*)meta;
|
||||
std::string name = lfm->getInventoryOwner();
|
||||
// no owner and inserting to src, claim ownership of the inventory
|
||||
if ((name == "" || lfm->getOwner() == player->getName()) && ma->to_list == "src") {
|
||||
lfm->setInventoryOwner(player->getName());
|
||||
}else if (name != "" && name != player->getName()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue