aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPilzAdam <PilzAdam@gmx.de>2013-01-06 15:32:23 +0100
committerPilzAdam <PilzAdam@gmx.de>2013-01-07 18:39:45 +0100
commit8aa190606e63cd5f27dbab27d2e4c7a70cd1e1ef (patch)
tree64cc05fe49c0b4c928b92aff116ae3ecbe8b3d01
parent0437abbffbcff46e33de14c0baedc676f14e7507 (diff)
downloadminetest-8aa190606e63cd5f27dbab27d2e4c7a70cd1e1ef.tar.gz
minetest-8aa190606e63cd5f27dbab27d2e4c7a70cd1e1ef.tar.bz2
minetest-8aa190606e63cd5f27dbab27d2e4c7a70cd1e1ef.zip
Disable all HP handling if enable_damage is false
-rw-r--r--src/game.cpp3
-rw-r--r--src/server.cpp38
2 files changed, 24 insertions, 17 deletions
diff --git a/src/game.cpp b/src/game.cpp
index c8f1d2187..bed99837d 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -2099,7 +2099,8 @@ void the_game(
{
break;
}
- else if(event.type == CE_PLAYER_DAMAGE)
+ else if(event.type == CE_PLAYER_DAMAGE &&
+ client.getHP() != 0)
{
//u16 damage = event.player_damage.amount;
//infostream<<"Player damage: "<<damage<<std::endl;
diff --git a/src/server.cpp b/src/server.cpp
index f635bc676..0a8288324 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -1368,11 +1368,16 @@ void Server::AsyncRunStep()
/*
Handle player HPs (die if hp=0)
*/
- if(playersao->getHP() == 0 && playersao->m_hp_not_sent)
- DiePlayer(client->peer_id);
+ if(playersao->m_hp_not_sent && g_settings->getBool("enable_damage"))
+ {
+ if(playersao->getHP() == 0)
+ DiePlayer(client->peer_id);
+ else
+ SendPlayerHP(client->peer_id);
+ }
/*
- Send player inventories and HPs if necessary
+ Send player inventories if necessary
*/
if(playersao->m_moved){
SendMovePlayer(client->peer_id);
@@ -1382,9 +1387,6 @@ void Server::AsyncRunStep()
UpdateCrafting(client->peer_id);
SendInventory(client->peer_id);
}
- if(playersao->m_hp_not_sent){
- SendPlayerHP(client->peer_id);
- }
}
}
@@ -2311,7 +2313,8 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
SendInventory(peer_id);
// Send HP
- SendPlayerHP(peer_id);
+ if(g_settings->getBool("enable_damage"))
+ SendPlayerHP(peer_id);
// Send detached inventories
sendDetachedInventories(peer_id);
@@ -2764,17 +2767,20 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
std::istringstream is(datastring, std::ios_base::binary);
u8 damage = readU8(is);
- actionstream<<player->getName()<<" damaged by "
- <<(int)damage<<" hp at "<<PP(player->getPosition()/BS)
- <<std::endl;
+ if(g_settings->getBool("enable_damage"))
+ {
+ actionstream<<player->getName()<<" damaged by "
+ <<(int)damage<<" hp at "<<PP(player->getPosition()/BS)
+ <<std::endl;
- playersao->setHP(playersao->getHP() - damage);
+ playersao->setHP(playersao->getHP() - damage);
- if(playersao->getHP() == 0 && playersao->m_hp_not_sent)
- DiePlayer(peer_id);
+ if(playersao->getHP() == 0 && playersao->m_hp_not_sent)
+ DiePlayer(peer_id);
- if(playersao->m_hp_not_sent)
- SendPlayerHP(peer_id);
+ if(playersao->m_hp_not_sent)
+ SendPlayerHP(peer_id);
+ }
}
else if(command == TOSERVER_PASSWORD)
{
@@ -2850,7 +2856,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
}
else if(command == TOSERVER_RESPAWN)
{
- if(player->hp != 0)
+ if(player->hp != 0 || !g_settings->getBool("enable_damage"))
return;
RespawnPlayer(peer_id);