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;
}
/*
- Handle player HPs
+ Handle player HPs (die if hp=0)
*/
HandlePlayerHP(player, 0);
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
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)
if(srp->m_respawn_active)
return;
+ if(damage == 0)
+ return;
+
if(player->hp > damage)
{
player->hp -= damage;
SendPlayerHP(player);
+ return;
+ }
+
+ infostream<<"Server::HandlePlayerHP(): Player "
+ <<player->getName()<<" dies"<<std::endl;
+
+ player->hp = 0;
+
+ //TODO: Throw items around
+
+ // Handle players that are not connected
+ if(player->peer_id == PEER_ID_INEXISTENT){
+ RespawnPlayer(player);
+ return;
+ }
+
+ SendPlayerHP(player);
+
+ RemoteClient *client = getClient(player->peer_id);
+ 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
{
- infostream<<"Server::HandlePlayerHP(): Player "
- <<player->getName()<<" dies"<<std::endl;
-
- player->hp = 0;
-
- //TODO: Throw items around
-
- // Handle players that are not connected
- if(player->peer_id == PEER_ID_INEXISTENT){
- RespawnPlayer(player);
- return;
- }
-
- SendPlayerHP(player);
-
- RemoteClient *client = getClient(player->peer_id);
- 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
- {
- RespawnPlayer(player);
- }
+ RespawnPlayer(player);
}
}