Fix sending of player hp (was sent all the time)

This commit is contained in:
Perttu Ahola 2011-12-02 17:19:42 +02:00
parent c2d266efc6
commit 67c21fc42f

@ -1283,6 +1283,8 @@ void Server::AsyncRunStep()
JMutexAutoLock lock(m_env_mutex);
JMutexAutoLock lock2(m_con_mutex);
ScopeProfiler sp(g_profiler, "Server: handle players");
//float player_max_speed = BS * 4.0; // Normal speed
float player_max_speed = BS * 20; // Fast speed
float player_max_speed_up = BS * 20;
@ -1332,7 +1334,7 @@ void Server::AsyncRunStep()
}
/*
Handle player HPs
Handle player HPs (die if hp=0)
*/
HandlePlayerHP(player, 0);
@ -1591,7 +1593,7 @@ void Server::AsyncRunStep()
JMutexAutoLock envlock(m_env_mutex);
JMutexAutoLock conlock(m_con_mutex);
//ScopeProfiler sp(g_profiler, "Server: sending object messages");
ScopeProfiler sp(g_profiler, "Server: sending object messages");
// Key = object id
// Value = data sent by object
@ -3983,6 +3985,7 @@ void Server::BroadcastChatMessage(const std::wstring &message)
void Server::SendPlayerHP(Player *player)
{
SendHP(m_con, player->peer_id, player->hp);
static_cast<ServerRemotePlayer*>(player)->m_hp_not_sent = false;
}
void Server::SendMovePlayer(Player *player)
@ -4381,13 +4384,16 @@ void Server::HandlePlayerHP(Player *player, s16 damage)
if(srp->m_respawn_active)
return;
if(damage == 0)
return;
if(player->hp > damage)
{
player->hp -= damage;
SendPlayerHP(player);
return;
}
else
{
infostream<<"Server::HandlePlayerHP(): Player "
<<player->getName()<<" dies"<<std::endl;
@ -4415,7 +4421,6 @@ void Server::HandlePlayerHP(Player *player, s16 damage)
RespawnPlayer(player);
}
}
}
void Server::RespawnPlayer(Player *player)
{