aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeija <norrepli@gmail.com>2013-01-27 10:33:25 +0100
committerPilzAdam <PilzAdam@gmx.de>2013-02-19 20:02:40 +0100
commit365c169b43f61b7f957bdd302b3cf9a837cabec1 (patch)
tree05117c9c24e525868c03d81e0d44a513b47d1548
parent214a8b4597728213065f1bf880f4357b723b5bea (diff)
downloadminetest-365c169b43f61b7f957bdd302b3cf9a837cabec1.tar.gz
minetest-365c169b43f61b7f957bdd302b3cf9a837cabec1.tar.bz2
minetest-365c169b43f61b7f957bdd302b3cf9a837cabec1.zip
Disable placement prediction for nodes that use on_rightclick
-rw-r--r--src/game.cpp3
-rw-r--r--src/itemdef.cpp1
-rw-r--r--src/itemdef.h2
-rw-r--r--src/nodedef.cpp3
-rw-r--r--src/nodedef.h2
-rw-r--r--src/scriptapi.cpp6
6 files changed, 15 insertions, 2 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 5693c5c12..c77754b5f 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -2531,7 +2531,8 @@ void the_game(
// make that happen
const ItemDefinition &def =
playeritem.getDefinition(itemdef);
- if(def.node_placement_prediction != "")
+ if(def.node_placement_prediction != ""
+ && !nodedef->get(map.getNode(nodepos)).rightclickable)
do{ // breakable
verbosestream<<"Node placement prediction for "
<<playeritem.name<<" is "
diff --git a/src/itemdef.cpp b/src/itemdef.cpp
index 260baadc0..a4f3895e0 100644
--- a/src/itemdef.cpp
+++ b/src/itemdef.cpp
@@ -100,6 +100,7 @@ void ItemDefinition::reset()
wield_scale = v3f(1.0, 1.0, 1.0);
stack_max = 99;
usable = false;
+ rightclickable = false;
liquids_pointable = false;
if(tool_capabilities)
{
diff --git a/src/itemdef.h b/src/itemdef.h
index 699d727bd..ae3600868 100644
--- a/src/itemdef.h
+++ b/src/itemdef.h
@@ -62,6 +62,8 @@ struct ItemDefinition
*/
s16 stack_max;
bool usable;
+ // If true, don't use node placement prediction
+ bool rightclickable;
bool liquids_pointable;
// May be NULL. If non-NULL, deleted by destructor
ToolCapabilities *tool_capabilities;
diff --git a/src/nodedef.cpp b/src/nodedef.cpp
index 729c69c92..12d9238ad 100644
--- a/src/nodedef.cpp
+++ b/src/nodedef.cpp
@@ -199,6 +199,7 @@ void ContentFeatures::reset()
diggable = true;
climbable = false;
buildable_to = false;
+ rightclickable = true;
liquid_type = LIQUID_NONE;
liquid_alternative_flowing = "";
liquid_alternative_source = "";
@@ -271,6 +272,7 @@ void ContentFeatures::serialize(std::ostream &os, u16 protocol_version)
serializeSimpleSoundSpec(sound_dug, os);
// Stuff below should be moved to correct place in a version that otherwise changes
// the protocol version
+ writeU8(os, rightclickable);
}
void ContentFeatures::deSerialize(std::istream &is)
@@ -334,6 +336,7 @@ void ContentFeatures::deSerialize(std::istream &is)
try{
// Stuff below should be moved to correct place in a version that
// otherwise changes the protocol version
+ rightclickable = readU8(is);
}catch(SerializationError &e) {};
}
diff --git a/src/nodedef.h b/src/nodedef.h
index 8588caeab..fa0c1f2e8 100644
--- a/src/nodedef.h
+++ b/src/nodedef.h
@@ -199,6 +199,8 @@ struct ContentFeatures
bool climbable;
// Player can build on these
bool buildable_to;
+ // Player cannot build to these (placement prediction disabled)
+ bool rightclickable;
// Whether the node is non-liquid, source liquid or flowing liquid
enum LiquidType liquid_type;
// If the content is liquid, this is the flowing version of the liquid.
diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp
index 020709cab..66654813e 100644
--- a/src/scriptapi.cpp
+++ b/src/scriptapi.cpp
@@ -1063,6 +1063,10 @@ static ItemDefinition read_item_definition(lua_State *L, int index,
def.usable = lua_isfunction(L, -1);
lua_pop(L, 1);
+ lua_getfield(L, index, "on_rightclick");
+ def.rightclickable = lua_isfunction(L, -1);
+ lua_pop(L, 1);
+
getboolfield(L, index, "liquids_pointable", def.liquids_pointable);
warn_if_field_exists(L, index, "tool_digging_properties",
@@ -4746,7 +4750,7 @@ static int l_register_item_raw(lua_State *L)
// Default to having client-side placement prediction for nodes
// ("" in item definition sets it off)
if(def.node_placement_prediction == "__default"){
- if(def.type == ITEM_NODE)
+ if(def.type == ITEM_NODE && !def.rightclickable)
def.node_placement_prediction = name;
else
def.node_placement_prediction = "";