]> git.lizzy.rs Git - minetest.git/blobdiff - src/content_sao.cpp
GUIHyperText: Fix bug with UTF8 chars in action name + simplify UTF8 stringw conversi...
[minetest.git] / src / content_sao.cpp
index 43c784b426fe475d267b8e5703c13e78702ba4db..75c3eaf37c87f86c48e81418d99c7325ea4ba6aa 100644 (file)
@@ -653,7 +653,7 @@ u16 LuaEntitySAO::punch(v3f dir,
        if (!damage_handled) {
                if (result.did_punch) {
                        setHP((s32)getHP() - result.damage,
-                               PlayerHPChangeReason(PlayerHPChangeReason::SET_HP));
+                               PlayerHPChangeReason(PlayerHPChangeReason::PLAYER_PUNCH, puncher));
 
                        std::string str = gob_cmd_punched(getHP());
                        // create message and add to list
@@ -663,10 +663,10 @@ u16 LuaEntitySAO::punch(v3f dir,
        }
 
        if (getHP() == 0 && !isGone()) {
-               m_pending_removal = true;
                clearParentAttachment();
                clearChildAttachments();
                m_env->getScriptIface()->luaentity_on_death(m_id, puncher);
+               m_pending_removal = true;
        }
 
        actionstream << puncher->getDescription() << " (id=" << puncher->getId() <<
@@ -675,6 +675,7 @@ u16 LuaEntitySAO::punch(v3f dir,
                        "), damage=" << (old_hp - (s32)getHP()) <<
                        (damage_handled ? " (handled by Lua)" : "") << std::endl;
 
+       // TODO: give Lua control over wear
        return result.wear;
 }
 
@@ -864,7 +865,7 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, RemotePlayer *player_, session_t p
        m_peer_id(peer_id_),
        m_is_singleplayer(is_singleplayer)
 {
-       assert(m_peer_id != 0); // pre-condition
+       SANITY_CHECK(m_peer_id != PEER_ID_INEXISTENT);
 
        m_prop.hp_max = PLAYER_MAX_HP_DEFAULT;
        m_prop.breath_max = PLAYER_MAX_BREATH_DEFAULT;
@@ -1393,7 +1394,7 @@ bool PlayerSAO::setWieldedItem(const ItemStack &item)
 
 void PlayerSAO::disconnected()
 {
-       m_peer_id = 0;
+       m_peer_id = PEER_ID_INEXISTENT;
        m_pending_removal = true;
 }