summaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-06-10 12:46:48 +0300
committerPerttu Ahola <celeron55@gmail.com>2012-06-10 12:46:48 +0300
commit6a0388bb4bedc1b1c6318d7bfebaf1ec67ccf94e (patch)
treed5c31cd32d0a1c73d8eaf9065a7b01235b0fff57 /src/game.cpp
parent7ba72f27630112286456aa5dd4e1738fde58ae6f (diff)
downloadminetest-6a0388bb4bedc1b1c6318d7bfebaf1ec67ccf94e.tar.gz
minetest-6a0388bb4bedc1b1c6318d7bfebaf1ec67ccf94e.tar.bz2
minetest-6a0388bb4bedc1b1c6318d7bfebaf1ec67ccf94e.zip
Node placement client-side prediction
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 485bcbb50..6ccf02677 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -2366,8 +2366,41 @@ void the_game(
// Otherwise report right click to server
else
{
+ // Report to server
client.interact(3, pointed);
camera.setDigging(1); // right click animation
+
+ // If the wielded item has node placement prediction,
+ // make that happen
+ const ItemDefinition &def =
+ playeritem.getDefinition(itemdef);
+ if(def.node_placement_prediction != "")
+ do{ // breakable
+ verbosestream<<"Node placement prediction for "
+ <<playeritem.name<<" is "
+ <<def.node_placement_prediction<<std::endl;
+ v3s16 p = neighbourpos;
+ content_t id;
+ bool found =
+ nodedef->getId(def.node_placement_prediction, id);
+ if(!found){
+ errorstream<<"Node placement prediction failed for "
+ <<playeritem.name<<" (places "
+ <<def.node_placement_prediction
+ <<") - Name not known"<<std::endl;
+ break;
+ }
+ MapNode n(id);
+ try{
+ // This triggers the required mesh update too
+ client.addNode(p, n);
+ }catch(InvalidPositionException &e){
+ errorstream<<"Node placement prediction failed for "
+ <<playeritem.name<<" (places "
+ <<def.node_placement_prediction
+ <<") - Position not loaded"<<std::endl;
+ }
+ }while(0);
}
}
}