Make Player::peer_id server-side only and add getters and setters (#6478)

* Make Player::peer_id server-side only and add getters and setters

Player::peer_id has no sense client side, move it to server, make it private and add setter and getter
Also add some PEER_ID_INEXISTENT instead of harcoded 0
This commit is contained in:
Loïc Blot 2017-09-30 12:00:05 +02:00 committed by GitHub
parent f729b5d2bd
commit be10c0893e
8 changed files with 64 additions and 73 deletions

@ -1190,7 +1190,7 @@ void Client::sendReady()
void Client::sendPlayerPos() void Client::sendPlayerPos()
{ {
LocalPlayer *myplayer = m_env.getLocalPlayer(); LocalPlayer *myplayer = m_env.getLocalPlayer();
if(myplayer == NULL) if (!myplayer)
return; return;
ClientMap &map = m_env.getClientMap(); ClientMap &map = m_env.getClientMap();
@ -1216,16 +1216,6 @@ void Client::sendPlayerPos()
myplayer->last_camera_fov = camera_fov; myplayer->last_camera_fov = camera_fov;
myplayer->last_wanted_range = wanted_range; myplayer->last_wanted_range = wanted_range;
//infostream << "Sending Player Position information" << std::endl;
session_t our_peer_id = m_con->GetPeerID();
// Set peer id if not set already
if(myplayer->peer_id == PEER_ID_INEXISTENT)
myplayer->peer_id = our_peer_id;
assert(myplayer->peer_id == our_peer_id);
NetworkPacket pkt(TOSERVER_PLAYERPOS, 12 + 12 + 4 + 4 + 4 + 1 + 1); NetworkPacket pkt(TOSERVER_PLAYERPOS, 12 + 12 + 4 + 4 + 4 + 1 + 1);
writePlayerPos(myplayer, &map, &pkt); writePlayerPos(myplayer, &map, &pkt);
@ -1236,16 +1226,9 @@ void Client::sendPlayerPos()
void Client::sendPlayerItem(u16 item) void Client::sendPlayerItem(u16 item)
{ {
LocalPlayer *myplayer = m_env.getLocalPlayer(); LocalPlayer *myplayer = m_env.getLocalPlayer();
if(myplayer == NULL) if (!myplayer)
return; return;
session_t our_peer_id = m_con->GetPeerID();
// Set peer id if not set already
if(myplayer->peer_id == PEER_ID_INEXISTENT)
myplayer->peer_id = our_peer_id;
assert(myplayer->peer_id == our_peer_id);
NetworkPacket pkt(TOSERVER_PLAYERITEM, 2); NetworkPacket pkt(TOSERVER_PLAYERITEM, 2);
pkt << item; pkt << item;

@ -848,7 +848,7 @@ void PlayerSAO::addedToEnvironment(u32 dtime_s)
ServerActiveObject::addedToEnvironment(dtime_s); ServerActiveObject::addedToEnvironment(dtime_s);
ServerActiveObject::setBasePosition(m_base_position); ServerActiveObject::setBasePosition(m_base_position);
m_player->setPlayerSAO(this); m_player->setPlayerSAO(this);
m_player->peer_id = m_peer_id; m_player->setPeerId(m_peer_id);
m_last_good_position = m_base_position; m_last_good_position = m_base_position;
} }
@ -1359,7 +1359,7 @@ void PlayerSAO::disconnected()
void PlayerSAO::unlinkPlayerSessionAndSave() void PlayerSAO::unlinkPlayerSessionAndSave()
{ {
assert(m_player->getPlayerSAO() == this); assert(m_player->getPlayerSAO() == this);
m_player->peer_id = 0; m_player->setPeerId(PEER_ID_INEXISTENT);
m_env->savePlayer(m_player); m_env->savePlayer(m_player);
m_player->setPlayerSAO(NULL); m_player->setPlayerSAO(NULL);
m_env->removePlayer(m_player); m_env->removePlayer(m_player);

@ -147,8 +147,6 @@ public:
v2s32 local_animations[4]; v2s32 local_animations[4];
float local_animation_speed; float local_animation_speed;
session_t peer_id = PEER_ID_INEXISTENT;
std::string inventory_formspec; std::string inventory_formspec;
PlayerControl control; PlayerControl control;

@ -135,6 +135,10 @@ public:
u16 protocol_version = 0; u16 protocol_version = 0;
session_t getPeerId() const { return m_peer_id; }
void setPeerId(session_t peer_id) { m_peer_id = peer_id; }
private: private:
/* /*
serialize() writes a bunch of text that can contain serialize() writes a bunch of text that can contain
@ -166,4 +170,6 @@ private:
bool m_sky_clouds; bool m_sky_clouds;
CloudParams m_cloud_params; CloudParams m_cloud_params;
session_t m_peer_id = PEER_ID_INEXISTENT;
}; };

@ -1023,7 +1023,7 @@ int ObjectRef::l_is_player_connected(lua_State *L)
NO_MAP_LOCK_REQUIRED; NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1); ObjectRef *ref = checkobject(L, 1);
RemotePlayer *player = getplayer(ref); RemotePlayer *player = getplayer(ref);
lua_pushboolean(L, (player != NULL && player->peer_id != 0)); lua_pushboolean(L, (player != NULL && player->getPeerId() != PEER_ID_INEXISTENT));
return 1; return 1;
} }

@ -124,7 +124,7 @@ int ModApiServer::l_get_player_ip(lua_State *L)
} }
try try
{ {
Address addr = getServer(L)->getPeerAddress(player->peer_id); Address addr = getServer(L)->getPeerAddress(player->getPeerId());
std::string ip_str = addr.serializeString(); std::string ip_str = addr.serializeString();
lua_pushstring(L, ip_str.c_str()); lua_pushstring(L, ip_str.c_str());
return 1; return 1;
@ -150,7 +150,7 @@ int ModApiServer::l_get_player_information(lua_State *L)
Address addr; Address addr;
try try
{ {
addr = getServer(L)->getPeerAddress(player->peer_id); addr = getServer(L)->getPeerAddress(player->getPeerId());
} catch(const con::PeerNotFoundException &) { } catch(const con::PeerNotFoundException &) {
dstream << FUNCTION_NAME << ": peer was not found" << std::endl; dstream << FUNCTION_NAME << ": peer was not found" << std::endl;
lua_pushnil(L); // error lua_pushnil(L); // error
@ -171,16 +171,18 @@ int ModApiServer::l_get_player_information(lua_State *L)
return 1; \ return 1; \
} }
ERET(getServer(L)->getClientConInfo(player->peer_id,con::MIN_RTT,&min_rtt)) ERET(getServer(L)->getClientConInfo(player->getPeerId(), con::MIN_RTT, &min_rtt))
ERET(getServer(L)->getClientConInfo(player->peer_id,con::MAX_RTT,&max_rtt)) ERET(getServer(L)->getClientConInfo(player->getPeerId(), con::MAX_RTT, &max_rtt))
ERET(getServer(L)->getClientConInfo(player->peer_id,con::AVG_RTT,&avg_rtt)) ERET(getServer(L)->getClientConInfo(player->getPeerId(), con::AVG_RTT, &avg_rtt))
ERET(getServer(L)->getClientConInfo(player->peer_id,con::MIN_JITTER,&min_jitter)) ERET(getServer(L)->getClientConInfo(player->getPeerId(), con::MIN_JITTER,
ERET(getServer(L)->getClientConInfo(player->peer_id,con::MAX_JITTER,&max_jitter)) &min_jitter))
ERET(getServer(L)->getClientConInfo(player->peer_id,con::AVG_JITTER,&avg_jitter)) ERET(getServer(L)->getClientConInfo(player->getPeerId(), con::MAX_JITTER,
&max_jitter))
ERET(getServer(L)->getClientConInfo(player->getPeerId(), con::AVG_JITTER,
&avg_jitter))
ERET(getServer(L)->getClientInfo(player->peer_id, ERET(getServer(L)->getClientInfo(player->getPeerId(), &state, &uptime, &ser_vers,
&state, &uptime, &ser_vers, &prot_vers, &prot_vers, &major, &minor, &patch, &vers_string))
&major, &minor, &patch, &vers_string))
lua_newtable(L); lua_newtable(L);
int table = lua_gettop(L); int table = lua_gettop(L);
@ -291,7 +293,7 @@ int ModApiServer::l_ban_player(lua_State *L)
try try
{ {
Address addr = getServer(L)->getPeerAddress( Address addr = getServer(L)->getPeerAddress(
dynamic_cast<ServerEnvironment *>(getEnv(L))->getPlayer(name)->peer_id); dynamic_cast<ServerEnvironment *>(getEnv(L))->getPlayer(name)->getPeerId());
std::string ip_str = addr.serializeString(); std::string ip_str = addr.serializeString();
getServer(L)->setIpBanned(ip_str, name); getServer(L)->setIpBanned(ip_str, name);
} catch(const con::PeerNotFoundException &) { } catch(const con::PeerNotFoundException &) {
@ -323,7 +325,7 @@ int ModApiServer::l_kick_player(lua_State *L)
lua_pushboolean(L, false); // No such player lua_pushboolean(L, false); // No such player
return 1; return 1;
} }
getServer(L)->DenyAccess_Legacy(player->peer_id, utf8_to_wide(message)); getServer(L)->DenyAccess_Legacy(player->getPeerId(), utf8_to_wide(message));
lua_pushboolean(L, true); lua_pushboolean(L, true);
return 1; return 1;
} }

@ -1015,7 +1015,7 @@ PlayerSAO* Server::StageTwoClientInit(session_t peer_id)
// If failed, cancel // If failed, cancel
if (!playersao || !player) { if (!playersao || !player) {
if (player && player->peer_id != 0) { if (player && player->getPeerId() != PEER_ID_INEXISTENT) {
actionstream << "Server: Failed to emerge player \"" << playername actionstream << "Server: Failed to emerge player \"" << playername
<< "\" (player allocated to an another client)" << std::endl; << "\" (player allocated to an another client)" << std::endl;
DenyAccess_Legacy(peer_id, L"Another client is connected with this " DenyAccess_Legacy(peer_id, L"Another client is connected with this "
@ -1057,7 +1057,7 @@ PlayerSAO* Server::StageTwoClientInit(session_t peer_id)
// Send information about server to player in chat // Send information about server to player in chat
SendChatMessage(peer_id, ChatMessage(CHATMESSAGE_TYPE_SYSTEM, getStatusString())); SendChatMessage(peer_id, ChatMessage(CHATMESSAGE_TYPE_SYSTEM, getStatusString()));
} }
Address addr = getPeerAddress(player->peer_id); Address addr = getPeerAddress(player->getPeerId());
std::string ip_str = addr.serializeString(); std::string ip_str = addr.serializeString();
actionstream<<player->getName() <<" [" << ip_str << "] joins game. " << std::endl; actionstream<<player->getName() <<" [" << ip_str << "] joins game. " << std::endl;
/* /*
@ -1872,7 +1872,7 @@ void Server::SendPlayerPrivileges(session_t peer_id)
{ {
RemotePlayer *player = m_env->getPlayer(peer_id); RemotePlayer *player = m_env->getPlayer(peer_id);
assert(player); assert(player);
if(player->peer_id == PEER_ID_INEXISTENT) if(player->getPeerId() == PEER_ID_INEXISTENT)
return; return;
std::set<std::string> privs; std::set<std::string> privs;
@ -1892,7 +1892,7 @@ void Server::SendPlayerInventoryFormspec(session_t peer_id)
{ {
RemotePlayer *player = m_env->getPlayer(peer_id); RemotePlayer *player = m_env->getPlayer(peer_id);
assert(player); assert(player);
if(player->peer_id == PEER_ID_INEXISTENT) if(player->getPeerId() == PEER_ID_INEXISTENT)
return; return;
NetworkPacket pkt(TOCLIENT_INVENTORY_FORMSPEC, 0, peer_id); NetworkPacket pkt(TOCLIENT_INVENTORY_FORMSPEC, 0, peer_id);
@ -1948,12 +1948,12 @@ s32 Server::playSound(const SimpleSoundSpec &spec,
<<"\" not found"<<std::endl; <<"\" not found"<<std::endl;
return -1; return -1;
} }
if(player->peer_id == PEER_ID_INEXISTENT){ if (player->getPeerId() == PEER_ID_INEXISTENT) {
infostream<<"Server::playSound: Player \""<<params.to_player infostream<<"Server::playSound: Player \""<<params.to_player
<<"\" not connected"<<std::endl; <<"\" not connected"<<std::endl;
return -1; return -1;
} }
dst_clients.push_back(player->peer_id); dst_clients.push_back(player->getPeerId());
} else { } else {
std::vector<session_t> clients = m_clients.getClientIDs(); std::vector<session_t> clients = m_clients.getClientIDs();
@ -2501,7 +2501,7 @@ void Server::sendDetachedInventory(const std::string &name, session_t peer_id)
return m_clients.sendToAll(&pkt); return m_clients.sendToAll(&pkt);
RemotePlayer *p = m_env->getPlayer(check.c_str()); RemotePlayer *p = m_env->getPlayer(check.c_str());
if (p) if (p)
m_clients.send(p->peer_id, 0, &pkt, true); m_clients.send(p->getPeerId(), 0, &pkt, true);
} else { } else {
if (check.empty() || getPlayerName(peer_id) == check) if (check.empty() || getPlayerName(peer_id) == check)
Send(&pkt); Send(&pkt);
@ -2765,7 +2765,7 @@ std::wstring Server::handleChat(const std::string &name, const std::wstring &wna
return ws.str(); return ws.str();
} }
case RPLAYER_CHATRESULT_KICK: case RPLAYER_CHATRESULT_KICK:
DenyAccess_Legacy(player->peer_id, DenyAccess_Legacy(player->getPeerId(),
L"You have been kicked due to message flooding."); L"You have been kicked due to message flooding.");
return L""; return L"";
case RPLAYER_CHATRESULT_OK: case RPLAYER_CHATRESULT_OK:
@ -2818,7 +2818,9 @@ std::wstring Server::handleChat(const std::string &name, const std::wstring &wna
if they are using protocol version >= 29 if they are using protocol version >= 29
*/ */
session_t peer_id_to_avoid_sending = (player ? player->peer_id : PEER_ID_INEXISTENT); session_t peer_id_to_avoid_sending =
(player ? player->getPeerId() : PEER_ID_INEXISTENT);
if (player && player->protocol_version >= 29) if (player && player->protocol_version >= 29)
peer_id_to_avoid_sending = PEER_ID_INEXISTENT; peer_id_to_avoid_sending = PEER_ID_INEXISTENT;
@ -2935,7 +2937,7 @@ void Server::reportPrivsModified(const std::string &name)
RemotePlayer *player = m_env->getPlayer(name.c_str()); RemotePlayer *player = m_env->getPlayer(name.c_str());
if (!player) if (!player)
return; return;
SendPlayerPrivileges(player->peer_id); SendPlayerPrivileges(player->getPeerId());
PlayerSAO *sao = player->getPlayerSAO(); PlayerSAO *sao = player->getPlayerSAO();
if(!sao) if(!sao)
return; return;
@ -2950,7 +2952,7 @@ void Server::reportInventoryFormspecModified(const std::string &name)
RemotePlayer *player = m_env->getPlayer(name.c_str()); RemotePlayer *player = m_env->getPlayer(name.c_str());
if (!player) if (!player)
return; return;
SendPlayerInventoryFormspec(player->peer_id); SendPlayerInventoryFormspec(player->getPeerId());
} }
void Server::setIpBanned(const std::string &ip, const std::string &name) void Server::setIpBanned(const std::string &ip, const std::string &name)
@ -2983,10 +2985,10 @@ void Server::notifyPlayer(const char *name, const std::wstring &msg)
return; return;
} }
if (player->peer_id == PEER_ID_INEXISTENT) if (player->getPeerId() == PEER_ID_INEXISTENT)
return; return;
SendChatMessage(player->peer_id, ChatMessage(msg)); SendChatMessage(player->getPeerId(), ChatMessage(msg));
} }
bool Server::showFormspec(const char *playername, const std::string &formspec, bool Server::showFormspec(const char *playername, const std::string &formspec,
@ -3000,7 +3002,7 @@ bool Server::showFormspec(const char *playername, const std::string &formspec,
if (!player) if (!player)
return false; return false;
SendShowFormspecMessage(player->peer_id, formspec, formname); SendShowFormspecMessage(player->getPeerId(), formspec, formname);
return true; return true;
} }
@ -3011,7 +3013,7 @@ u32 Server::hudAdd(RemotePlayer *player, HudElement *form)
u32 id = player->addHud(form); u32 id = player->addHud(form);
SendHUDAdd(player->peer_id, id, form); SendHUDAdd(player->getPeerId(), id, form);
return id; return id;
} }
@ -3027,7 +3029,7 @@ bool Server::hudRemove(RemotePlayer *player, u32 id) {
delete todel; delete todel;
SendHUDRemove(player->peer_id, id); SendHUDRemove(player->getPeerId(), id);
return true; return true;
} }
@ -3036,7 +3038,7 @@ bool Server::hudChange(RemotePlayer *player, u32 id, HudElementStat stat, void *
if (!player) if (!player)
return false; return false;
SendHUDChange(player->peer_id, id, stat, data); SendHUDChange(player->getPeerId(), id, stat, data);
return true; return true;
} }
@ -3045,7 +3047,7 @@ bool Server::hudSetFlags(RemotePlayer *player, u32 flags, u32 mask)
if (!player) if (!player)
return false; return false;
SendHUDSetFlags(player->peer_id, flags, mask); SendHUDSetFlags(player->getPeerId(), flags, mask);
player->hud_flags &= ~mask; player->hud_flags &= ~mask;
player->hud_flags |= flags; player->hud_flags |= flags;
@ -3069,7 +3071,7 @@ bool Server::hudSetHotbarItemcount(RemotePlayer *player, s32 hotbar_itemcount)
player->setHotbarItemcount(hotbar_itemcount); player->setHotbarItemcount(hotbar_itemcount);
std::ostringstream os(std::ios::binary); std::ostringstream os(std::ios::binary);
writeS32(os, hotbar_itemcount); writeS32(os, hotbar_itemcount);
SendHUDSetParam(player->peer_id, HUD_PARAM_HOTBAR_ITEMCOUNT, os.str()); SendHUDSetParam(player->getPeerId(), HUD_PARAM_HOTBAR_ITEMCOUNT, os.str());
return true; return true;
} }
@ -3084,7 +3086,7 @@ void Server::hudSetHotbarImage(RemotePlayer *player, std::string name)
return; return;
player->setHotbarImage(name); player->setHotbarImage(name);
SendHUDSetParam(player->peer_id, HUD_PARAM_HOTBAR_IMAGE, name); SendHUDSetParam(player->getPeerId(), HUD_PARAM_HOTBAR_IMAGE, name);
} }
std::string Server::hudGetHotbarImage(RemotePlayer *player) std::string Server::hudGetHotbarImage(RemotePlayer *player)
@ -3100,7 +3102,7 @@ void Server::hudSetHotbarSelectedImage(RemotePlayer *player, std::string name)
return; return;
player->setHotbarSelectedImage(name); player->setHotbarSelectedImage(name);
SendHUDSetParam(player->peer_id, HUD_PARAM_HOTBAR_SELECTED_IMAGE, name); SendHUDSetParam(player->getPeerId(), HUD_PARAM_HOTBAR_SELECTED_IMAGE, name);
} }
const std::string& Server::hudGetHotbarSelectedImage(RemotePlayer *player) const const std::string& Server::hudGetHotbarSelectedImage(RemotePlayer *player) const
@ -3120,7 +3122,7 @@ bool Server::setLocalPlayerAnimations(RemotePlayer *player,
return false; return false;
player->setLocalAnimations(animation_frames, frame_speed); player->setLocalAnimations(animation_frames, frame_speed);
SendLocalPlayerAnimations(player->peer_id, animation_frames, frame_speed); SendLocalPlayerAnimations(player->getPeerId(), animation_frames, frame_speed);
return true; return true;
} }
@ -3131,7 +3133,7 @@ bool Server::setPlayerEyeOffset(RemotePlayer *player, v3f first, v3f third)
player->eye_offset_first = first; player->eye_offset_first = first;
player->eye_offset_third = third; player->eye_offset_third = third;
SendEyeOffset(player->peer_id, first, third); SendEyeOffset(player->getPeerId(), first, third);
return true; return true;
} }
@ -3143,7 +3145,7 @@ bool Server::setSky(RemotePlayer *player, const video::SColor &bgcolor,
return false; return false;
player->setSky(bgcolor, type, params, clouds); player->setSky(bgcolor, type, params, clouds);
SendSetSky(player->peer_id, bgcolor, type, params, clouds); SendSetSky(player->getPeerId(), bgcolor, type, params, clouds);
return true; return true;
} }
@ -3157,7 +3159,7 @@ bool Server::setClouds(RemotePlayer *player, float density,
if (!player) if (!player)
return false; return false;
SendCloudParams(player->peer_id, density, SendCloudParams(player->getPeerId(), density,
color_bright, color_ambient, height, color_bright, color_ambient, height,
thickness, speed); thickness, speed);
return true; return true;
@ -3170,7 +3172,7 @@ bool Server::overrideDayNightRatio(RemotePlayer *player, bool do_override,
return false; return false;
player->overrideDayNightRatio(do_override, ratio); player->overrideDayNightRatio(do_override, ratio);
SendOverrideDayNightRatio(player->peer_id, do_override, ratio); SendOverrideDayNightRatio(player->getPeerId(), do_override, ratio);
return true; return true;
} }
@ -3196,7 +3198,7 @@ void Server::spawnParticle(const std::string &playername, v3f pos,
RemotePlayer *player = m_env->getPlayer(playername.c_str()); RemotePlayer *player = m_env->getPlayer(playername.c_str());
if (!player) if (!player)
return; return;
peer_id = player->peer_id; peer_id = player->getPeerId();
proto_ver = player->protocol_version; proto_ver = player->protocol_version;
} }
@ -3223,7 +3225,7 @@ u32 Server::addParticleSpawner(u16 amount, float spawntime,
RemotePlayer *player = m_env->getPlayer(playername.c_str()); RemotePlayer *player = m_env->getPlayer(playername.c_str());
if (!player) if (!player)
return -1; return -1;
peer_id = player->peer_id; peer_id = player->getPeerId();
proto_ver = player->protocol_version; proto_ver = player->protocol_version;
} }
@ -3255,7 +3257,7 @@ void Server::deleteParticleSpawner(const std::string &playername, u32 id)
RemotePlayer *player = m_env->getPlayer(playername.c_str()); RemotePlayer *player = m_env->getPlayer(playername.c_str());
if (!player) if (!player)
return; return;
peer_id = player->peer_id; peer_id = player->getPeerId();
} }
m_env->deleteParticleSpawner(id); m_env->deleteParticleSpawner(id);
@ -3489,7 +3491,7 @@ PlayerSAO* Server::emergePlayer(const char *name, session_t peer_id, u16 proto_v
RemotePlayer *player = m_env->getPlayer(name); RemotePlayer *player = m_env->getPlayer(name);
// If player is already connected, cancel // If player is already connected, cancel
if (player && player->peer_id != 0) { if (player && player->getPeerId() != PEER_ID_INEXISTENT) {
infostream<<"emergePlayer(): Player already connected"<<std::endl; infostream<<"emergePlayer(): Player already connected"<<std::endl;
return NULL; return NULL;
} }

@ -408,7 +408,7 @@ ServerMap & ServerEnvironment::getServerMap()
RemotePlayer *ServerEnvironment::getPlayer(const session_t peer_id) RemotePlayer *ServerEnvironment::getPlayer(const session_t peer_id)
{ {
for (RemotePlayer *player : m_players) { for (RemotePlayer *player : m_players) {
if (player->peer_id == peer_id) if (player->getPeerId() == peer_id)
return player; return player;
} }
return NULL; return NULL;
@ -431,8 +431,8 @@ void ServerEnvironment::addPlayer(RemotePlayer *player)
Exception: there can be multiple players with peer_id=0 Exception: there can be multiple players with peer_id=0
*/ */
// If peer id is non-zero, it has to be unique. // If peer id is non-zero, it has to be unique.
if (player->peer_id != 0) if (player->getPeerId() != PEER_ID_INEXISTENT)
FATAL_ERROR_IF(getPlayer(player->peer_id) != NULL, "Peer id not unique"); FATAL_ERROR_IF(getPlayer(player->getPeerId()) != NULL, "Peer id not unique");
// Name has to be unique. // Name has to be unique.
FATAL_ERROR_IF(getPlayer(player->getName()) != NULL, "Player name not unique"); FATAL_ERROR_IF(getPlayer(player->getName()) != NULL, "Player name not unique");
// Add. // Add.
@ -487,7 +487,7 @@ void ServerEnvironment::kickAllPlayers(AccessDeniedCode reason,
const std::string &str_reason, bool reconnect) const std::string &str_reason, bool reconnect)
{ {
for (RemotePlayer *player : m_players) { for (RemotePlayer *player : m_players) {
m_server->DenyAccessVerCompliant(player->peer_id, m_server->DenyAccessVerCompliant(player->getPeerId(),
player->protocol_version, reason, str_reason, reconnect); player->protocol_version, reason, str_reason, reconnect);
} }
} }
@ -1124,7 +1124,7 @@ void ServerEnvironment::step(float dtime)
ScopeProfiler sp(g_profiler, "SEnv: handle players avg", SPT_AVG); ScopeProfiler sp(g_profiler, "SEnv: handle players avg", SPT_AVG);
for (RemotePlayer *player : m_players) { for (RemotePlayer *player : m_players) {
// Ignore disconnected players // Ignore disconnected players
if (player->peer_id == 0) if (player->getPeerId() == PEER_ID_INEXISTENT)
continue; continue;
// Move // Move
@ -1143,7 +1143,7 @@ void ServerEnvironment::step(float dtime)
std::vector<v3s16> players_blockpos; std::vector<v3s16> players_blockpos;
for (RemotePlayer *player: m_players) { for (RemotePlayer *player: m_players) {
// Ignore disconnected players // Ignore disconnected players
if (player->peer_id == 0) if (player->getPeerId() == PEER_ID_INEXISTENT)
continue; continue;
PlayerSAO *playersao = player->getPlayerSAO(); PlayerSAO *playersao = player->getPlayerSAO();