aboutsummaryrefslogtreecommitdiff
path: root/src/server.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/server.cpp
parent7ba72f27630112286456aa5dd4e1738fde58ae6f (diff)
downloadminetest-6a0388bb4bedc1b1c6318d7bfebaf1ec67ccf94e.tar.gz
minetest-6a0388bb4bedc1b1c6318d7bfebaf1ec67ccf94e.tar.bz2
minetest-6a0388bb4bedc1b1c6318d7bfebaf1ec67ccf94e.zip
Node placement client-side prediction
Diffstat (limited to 'src/server.cpp')
-rw-r--r--src/server.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/server.cpp b/src/server.cpp
index a7bd5e953..98072e854 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -2971,8 +2971,16 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
<<std::endl;
// Re-send block to revert change on client-side
RemoteClient *client = getClient(peer_id);
- v3s16 blockpos = getNodeBlockPos(floatToInt(pointed_pos_under, BS));
- client->SetBlockNotSent(blockpos);
+ // Digging completed -> under
+ if(action == 2){
+ v3s16 blockpos = getNodeBlockPos(floatToInt(pointed_pos_under, BS));
+ client->SetBlockNotSent(blockpos);
+ }
+ // Placement -> above
+ if(action == 3){
+ v3s16 blockpos = getNodeBlockPos(floatToInt(pointed_pos_above, BS));
+ client->SetBlockNotSent(blockpos);
+ }
return;
}
@@ -3104,7 +3112,14 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
if(g_settings->getBool("creative_mode") == false)
playersao->setWieldedItem(item);
}
-
+
+ // If item has node placement prediction, always send the above
+ // node to make sure the client knows what exactly happened
+ if(item.getDefinition(m_itemdef).node_placement_prediction != ""){
+ RemoteClient *client = getClient(peer_id);
+ v3s16 blockpos = getNodeBlockPos(floatToInt(pointed_pos_above, BS));
+ client->SetBlockNotSent(blockpos);
+ }
} // action == 3
/*