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/server.cpp | |
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/server.cpp')
-rw-r--r-- | src/server.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/server.cpp b/src/server.cpp index 8be223f74..ca2743ad2 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -1029,7 +1029,8 @@ PlayerSAO* Server::StageTwoClientInit(session_t peer_id) if (playersao->isDead()) SendDeathscreen(peer_id, false, v3f(0,0,0)); else - SendPlayerHPOrDie(playersao); + SendPlayerHPOrDie(playersao, + PlayerHPChangeReason(PlayerHPChangeReason::SET_HP)); // Send Breath SendPlayerBreath(playersao); @@ -1392,7 +1393,7 @@ void Server::SendMovement(session_t peer_id) Send(&pkt); } -void Server::SendPlayerHPOrDie(PlayerSAO *playersao) +void Server::SendPlayerHPOrDie(PlayerSAO *playersao, const PlayerHPChangeReason &reason) { if (!g_settings->getBool("enable_damage")) return; @@ -1403,7 +1404,7 @@ void Server::SendPlayerHPOrDie(PlayerSAO *playersao) if (is_alive) SendPlayerHP(peer_id); else - DiePlayer(peer_id); + DiePlayer(peer_id, reason); } void Server::SendHP(session_t peer_id, u16 hp) @@ -2493,7 +2494,7 @@ void Server::sendDetachedInventories(session_t peer_id) Something random */ -void Server::DiePlayer(session_t peer_id) +void Server::DiePlayer(session_t peer_id, const PlayerHPChangeReason &reason) { PlayerSAO *playersao = getPlayerSAO(peer_id); // In some rare cases this can be NULL -- if the player is disconnected @@ -2505,10 +2506,10 @@ void Server::DiePlayer(session_t peer_id) << playersao->getPlayer()->getName() << " dies" << std::endl; - playersao->setHP(0); + playersao->setHP(0, reason); // Trigger scripted stuff - m_script->on_dieplayer(playersao); + m_script->on_dieplayer(playersao, reason); SendPlayerHP(peer_id); SendDeathscreen(peer_id, false, v3f(0,0,0)); @@ -2523,7 +2524,8 @@ void Server::RespawnPlayer(session_t peer_id) << playersao->getPlayer()->getName() << " respawns" << std::endl; - playersao->setHP(playersao->accessObjectProperties()->hp_max); + playersao->setHP(playersao->accessObjectProperties()->hp_max, + PlayerHPChangeReason(PlayerHPChangeReason::RESPAWN)); playersao->setBreath(playersao->accessObjectProperties()->breath_max); bool repositioned = m_script->on_respawnplayer(playersao); |