diff --git a/src/materials.cpp b/src/materials.cpp index 3f88f9d4..d2d37ebf 100644 --- a/src/materials.cpp +++ b/src/materials.cpp @@ -104,9 +104,9 @@ HittingProperties getHittingProperties(const MaterialProperties *mp, time_from_last_punch); // If digging time would be 1 second, 2 hearts go in 1 second. - s16 hp = 2.0 * 2.0 / digprop.time + 0.5; + s16 hp = 2.0 * 2.0 / digprop.time; // Wear is the same as for digging a single node - s16 wear = (float)digprop.wear + 0.5; + s16 wear = (float)digprop.wear; return HittingProperties(hp, wear); } diff --git a/src/server.cpp b/src/server.cpp index 8fbc0f79..11c11b25 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -2964,7 +2964,8 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) <punch(srp); + pointed_object->punch(srp, srp->m_time_from_last_punch); + srp->m_time_from_last_punch = 0; } } // action == 0 diff --git a/src/serverremoteplayer.cpp b/src/serverremoteplayer.cpp index 900cc543..1681900e 100644 --- a/src/serverremoteplayer.cpp +++ b/src/serverremoteplayer.cpp @@ -31,11 +31,11 @@ ServerRemotePlayer::ServerRemotePlayer(ServerEnvironment *env): ServerActiveObject(env, v3f(0,0,0)), m_last_good_position(0,0,0), m_last_good_position_age(0), - m_additional_items(), m_inventory_not_sent(false), m_hp_not_sent(false), m_respawn_active(false), m_is_in_environment(false), + m_time_from_last_punch(0), m_position_not_sent(false) { } @@ -43,9 +43,12 @@ ServerRemotePlayer::ServerRemotePlayer(ServerEnvironment *env, v3f pos_, u16 pee const char *name_): Player(env->getGameDef()), ServerActiveObject(env, pos_), + m_last_good_position(0,0,0), + m_last_good_position_age(0), m_inventory_not_sent(false), m_hp_not_sent(false), m_is_in_environment(false), + m_time_from_last_punch(0), m_position_not_sent(false) { setPosition(pos_); @@ -93,6 +96,8 @@ bool ServerRemotePlayer::unlimitedTransferDistance() const void ServerRemotePlayer::step(float dtime, bool send_recommended) { + m_time_from_last_punch += dtime; + if(send_recommended == false) return; @@ -157,9 +162,14 @@ void ServerRemotePlayer::punch(ServerActiveObject *puncher, HittingProperties hitprop = getHittingProperties(&mp, &tp, time_from_last_punch); + actionstream<<"Player "<getDescription()<<", damage "<damageWieldedItem(hitprop.wear); - + + if(hitprop.hp != 0) { std::ostringstream os(std::ios::binary); // command (1 = punched) diff --git a/src/serverremoteplayer.h b/src/serverremoteplayer.h index 15a9ebc3..bdc3bba2 100644 --- a/src/serverremoteplayer.h +++ b/src/serverremoteplayer.h @@ -74,7 +74,8 @@ class ServerRemotePlayer : public Player, public ServerActiveObject void rightClick(ServerActiveObject *clicker); void setPos(v3f pos); void moveTo(v3f pos, bool continuous); - virtual std::string getDescription(){return getName();} + virtual std::string getDescription() + {return std::string("player ")+getName();} virtual void getWieldDiggingProperties(ToolDiggingProperties *dst); virtual void damageWieldedItem(u16 amount); @@ -93,6 +94,8 @@ class ServerRemotePlayer : public Player, public ServerActiveObject bool m_hp_not_sent; bool m_respawn_active; bool m_is_in_environment; + // Incremented by step(), read and reset by Server + float m_time_from_last_punch; private: bool m_position_not_sent; diff --git a/src/tooldef.h b/src/tooldef.h index c30579cb..68a89489 100644 --- a/src/tooldef.h +++ b/src/tooldef.h @@ -38,7 +38,7 @@ struct ToolDiggingProperties float dd_crumbliness; float dd_cuttability; - ToolDiggingProperties(float full_punch_interval_=1.0, + ToolDiggingProperties(float full_punch_interval_=2.0, float a=0.75, float b=0, float c=0, float d=0, float e=0, float f=50, float g=0, float h=0, float i=0, float j=0); };