diff options
author | Andrew Ward <rw@rubenwardy.com> | 2018-03-28 16:05:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-28 16:05:18 +0100 |
commit | dfc81983491417c5cd1c99d7db05e421c409379d (patch) | |
tree | 7b0457f0ff86f038cfad1a095d3ab0b6c44f2def /src/network | |
parent | 2323842dd3dd336b087ca3cf9756e0680b3a1244 (diff) | |
download | minetest-dfc81983491417c5cd1c99d7db05e421c409379d.tar.gz minetest-dfc81983491417c5cd1c99d7db05e421c409379d.tar.bz2 minetest-dfc81983491417c5cd1c99d7db05e421c409379d.zip |
Add reasons to on_dieplayer and on_hpchange
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/serverpackethandler.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/network/serverpackethandler.cpp b/src/network/serverpackethandler.cpp index 76a2dc3c2..2d810836b 100644 --- a/src/network/serverpackethandler.cpp +++ b/src/network/serverpackethandler.cpp @@ -812,8 +812,9 @@ void Server::handleCommand_Damage(NetworkPacket* pkt) << (int)damage << " hp at " << PP(playersao->getBasePosition() / BS) << std::endl; - playersao->setHP(playersao->getHP() - damage); - SendPlayerHPOrDie(playersao); + PlayerHPChangeReason reason(PlayerHPChangeReason::FALL); + playersao->setHP(playersao->getHP() - damage, reason); + SendPlayerHPOrDie(playersao, reason); } } @@ -1175,12 +1176,14 @@ void Server::handleCommand_Interact(NetworkPacket* pkt) // If the object is a player and its HP changed if (src_original_hp != pointed_object->getHP() && pointed_object->getType() == ACTIVEOBJECT_TYPE_PLAYER) { - SendPlayerHPOrDie((PlayerSAO *)pointed_object); + SendPlayerHPOrDie((PlayerSAO *)pointed_object, + PlayerHPChangeReason(PlayerHPChangeReason::PLAYER_PUNCH, playersao)); } // If the puncher is a player and its HP changed if (dst_origin_hp != playersao->getHP()) - SendPlayerHPOrDie(playersao); + SendPlayerHPOrDie(playersao, + PlayerHPChangeReason(PlayerHPChangeReason::PLAYER_PUNCH, pointed_object)); } } // action == 0 |