aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSmallJoker <mk939@ymail.com>2015-03-11 20:52:47 +0100
committerest31 <MTest31@outlook.com>2015-06-15 00:10:13 +0200
commitbb5f830d1653927cf6f712fc241006f00e1b70e8 (patch)
tree392d97680ef48031a268433a8996f2bc91b2f8fd /src
parentecdfbfc8dc1bc62acce0b041b5a3349f886843ec (diff)
downloadminetest-bb5f830d1653927cf6f712fc241006f00e1b70e8.tar.gz
minetest-bb5f830d1653927cf6f712fc241006f00e1b70e8.tar.bz2
minetest-bb5f830d1653927cf6f712fc241006f00e1b70e8.zip
Ignore punches with no damage in the actionstream
Diffstat (limited to 'src')
-rw-r--r--src/content_sao.cpp41
1 files changed, 18 insertions, 23 deletions
diff --git a/src/content_sao.cpp b/src/content_sao.cpp
index 318dd367a..984d2ffa3 100644
--- a/src/content_sao.cpp
+++ b/src/content_sao.cpp
@@ -419,19 +419,19 @@ int LuaEntitySAO::punch(v3f dir,
ServerActiveObject *puncher,
float time_from_last_punch)
{
- if(!m_registered){
+ if (!m_registered){
// Delete unknown LuaEntities when punched
m_removed = true;
return 0;
}
// It's best that attachments cannot be punched
- if(isAttached())
+ if (isAttached())
return 0;
ItemStack *punchitem = NULL;
ItemStack punchitem_static;
- if(puncher){
+ if (puncher) {
punchitem_static = puncher->getWieldedItem();
punchitem = &punchitem_static;
}
@@ -442,31 +442,26 @@ int LuaEntitySAO::punch(v3f dir,
punchitem,
time_from_last_punch);
- if(result.did_punch)
- {
+ if (result.did_punch) {
setHP(getHP() - result.damage);
+ if (result.damage > 0) {
+ std::string punchername = puncher ? puncher->getDescription() : "nil";
- std::string punchername = "nil";
-
- if ( puncher != 0 )
- punchername = puncher->getDescription();
-
- actionstream<<getDescription()<<" punched by "
- <<punchername<<", damage "<<result.damage
- <<" hp, health now "<<getHP()<<" hp"<<std::endl;
-
- {
- std::string str = gob_cmd_punched(result.damage, getHP());
- // create message and add to list
- ActiveObjectMessage aom(getId(), true, str);
- m_messages_out.push(aom);
+ actionstream << getDescription() << " punched by "
+ << punchername << ", damage " << result.damage
+ << " hp, health now " << getHP() << " hp" << std::endl;
}
- if(getHP() == 0)
- m_removed = true;
+ std::string str = gob_cmd_punched(result.damage, getHP());
+ // create message and add to list
+ ActiveObjectMessage aom(getId(), true, str);
+ m_messages_out.push(aom);
}
+ if (getHP() == 0)
+ m_removed = true;
+
m_env->getScriptIface()->luaentity_Punch(m_id, puncher,
time_from_last_punch, toolcap, dir);
@@ -475,10 +470,10 @@ int LuaEntitySAO::punch(v3f dir,
void LuaEntitySAO::rightClick(ServerActiveObject *clicker)
{
- if(!m_registered)
+ if (!m_registered)
return;
// It's best that attachments cannot be clicked
- if(isAttached())
+ if (isAttached())
return;
m_env->getScriptIface()->luaentity_Rightclick(m_id, clicker);
}