aboutsummaryrefslogtreecommitdiff
path: root/src/server.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-12-01 23:33:48 +0200
committerPerttu Ahola <celeron55@gmail.com>2011-12-01 23:33:48 +0200
commitaf322405454191846507b91251d655c2b0aa864b (patch)
tree06213c35a56ecbf3ad6e8b509052e1ccd23cb783 /src/server.cpp
parentee0d3bacbce612c1abc6016cb7b0d684df25b820 (diff)
downloadminetest-af322405454191846507b91251d655c2b0aa864b.tar.gz
minetest-af322405454191846507b91251d655c2b0aa864b.tar.bz2
minetest-af322405454191846507b91251d655c2b0aa864b.zip
Players are more like objects + related stuff
Diffstat (limited to 'src/server.cpp')
-rw-r--r--src/server.cpp31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/server.cpp b/src/server.cpp
index eebf96901..2dceb805b 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -1432,6 +1432,11 @@ void Server::AsyncRunStep()
}
/*
+ Handle player HPs
+ */
+ HandlePlayerHP(player, 0);
+
+ /*
Send player inventories and HPs if necessary
*/
if(player->m_inventory_not_sent){
@@ -2230,8 +2235,8 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
}
// Add PlayerSAO
- PlayerSAO *sao = new PlayerSAO(m_env, player->getPosition(), player);
- m_env->addActiveObject(sao);
+ player->m_removed = false;
+ m_env->addActiveObject(player);
/*
Answer with a TOCLIENT_INIT
@@ -2983,6 +2988,9 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
actionstream<<player->getName()<<" respawns at "
<<PP(player->getPosition()/BS)<<std::endl;
+
+ srp->m_removed = false;
+ m_env->addActiveObject(srp);
}
else if(command == TOSERVER_INTERACT)
{
@@ -4523,6 +4531,11 @@ void Server::SendTextures(u16 peer_id)
void Server::HandlePlayerHP(Player *player, s16 damage)
{
+ ServerRemotePlayer *srp = static_cast<ServerRemotePlayer*>(player);
+
+ if(srp->m_respawn_active)
+ return;
+
if(player->hp > damage)
{
player->hp -= damage;
@@ -4549,6 +4562,8 @@ void Server::HandlePlayerHP(Player *player, s16 damage)
if(client->net_proto_version >= 3)
{
SendDeathscreen(m_con, player->peer_id, false, v3f(0,0,0));
+ srp->m_removed = true;
+ srp->m_respawn_active = true;
}
else
{
@@ -4561,6 +4576,7 @@ void Server::RespawnPlayer(Player *player)
{
player->hp = 20;
ServerRemotePlayer *srp = static_cast<ServerRemotePlayer*>(player);
+ srp->m_respawn_active = false;
bool repositioned = scriptapi_on_respawnplayer(m_lua, srp);
if(!repositioned){
v3f pos = findSpawnPos(m_env->getServerMap());
@@ -4983,16 +4999,9 @@ void Server::handlePeerChange(PeerChange &c)
}
}
- // Remove PlayerSAO
+ // Remove from environment
if(player != NULL)
- {
- PlayerSAO *sao = player->getSAO();
- if(sao){
- sao->setPlayer(NULL);
- sao->m_removed = true;
- }
- player->setSAO(NULL);
- }
+ player->m_removed = true;
// Set player client disconnected
if(player != NULL)