if(dr != m_env.getDayNightRatio())
{
//dstream<<"dr="<<dr<<std::endl;
+ dout_client<<DTIME<<"Client: changing day-night ratio"<<std::endl;
m_env.setDayNightRatio(dr);
m_env.expireMeshes(true);
}
p.Z = readS16(&data[6]);
//TimeTaker t1("TOCLIENT_REMOVENODE", g_device);
+
+ // This will clear the cracking animation after digging
+ ((ClientMap&)m_env.getMap()).clearTempMod(p);
core::map<v3s16, MapBlock*> modified_blocks;
v3s16 blockpos = ((ClientMap&)m_env.getMap()).clearTempMod(p);
m_env.getMap().updateMeshes(blockpos, m_env.getDayNightRatio());
}
+
+ float getAvgRtt()
+ {
+ JMutexAutoLock lock(m_con_mutex);
+ con::Peer *peer = m_con.GetPeerNoEx(PEER_ID_SERVER);
+ if(peer == NULL)
+ return 0.0;
+ return peer->avg_rtt;
+ }
private:
static v3s16 nodepos_old(-32768,-32768,-32768);\r
\r
static float dig_time = 0.0;\r
+ static u16 dig_index = 0;\r
\r
if(nodepos != nodepos_old)\r
{\r
}\r
if(g_input->getLeftState())\r
{\r
- dig_time += dtime;\r
- \r
float dig_time_complete = 0.5;\r
MapNode n = client.getNode(nodepos);\r
if(n.d == CONTENT_STONE)\r
dig_time_complete = 1.5;\r
+ \r
+ float dig_time_complete0 = dig_time_complete+client.getAvgRtt()*2;\r
+ if(dig_time_complete0 < 0.0)\r
+ dig_time_complete0 = 0.0;\r
\r
- u16 dig_index = (u16)(3.99*dig_time/dig_time_complete);\r
- if(dig_time > 0.125)\r
+ dig_index = (u16)((float)CRACK_ANIMATION_LENGTH\r
+ * dig_time/dig_time_complete0);\r
+\r
+ if(dig_time > 0.125 && dig_index < CRACK_ANIMATION_LENGTH)\r
{\r
//dstream<<"dig_index="<<dig_index<<std::endl;\r
client.setTempMod(nodepos, NodeMod(NODEMOD_CRACK, dig_index));\r
}\r
+\r
+ dig_time += dtime;\r
}\r
\r
if(g_input->getRightClicked())\r