summaryrefslogtreecommitdiff
path: root/src/serverenvironment.cpp
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2017-09-30 12:00:05 +0200
committerGitHub <noreply@github.com>2017-09-30 12:00:05 +0200
commitbe10c0893e2e6d1852a027abccc4cd3cdc85a140 (patch)
treeeabfe8164007c420326f52bfc7e13e9be0f6bfb6 /src/serverenvironment.cpp
parentf729b5d2bdc65ce3c51f1004c58cb93a37504b49 (diff)
downloadminetest-be10c0893e2e6d1852a027abccc4cd3cdc85a140.tar.gz
minetest-be10c0893e2e6d1852a027abccc4cd3cdc85a140.tar.bz2
minetest-be10c0893e2e6d1852a027abccc4cd3cdc85a140.zip
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
Diffstat (limited to 'src/serverenvironment.cpp')
-rw-r--r--src/serverenvironment.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/serverenvironment.cpp b/src/serverenvironment.cpp
index e20d58673..aed1dc22f 100644
--- a/src/serverenvironment.cpp
+++ b/src/serverenvironment.cpp
@@ -408,7 +408,7 @@ ServerMap & ServerEnvironment::getServerMap()
RemotePlayer *ServerEnvironment::getPlayer(const session_t peer_id)
{
for (RemotePlayer *player : m_players) {
- if (player->peer_id == peer_id)
+ if (player->getPeerId() == peer_id)
return player;
}
return NULL;
@@ -431,8 +431,8 @@ void ServerEnvironment::addPlayer(RemotePlayer *player)
Exception: there can be multiple players with peer_id=0
*/
// If peer id is non-zero, it has to be unique.
- if (player->peer_id != 0)
- FATAL_ERROR_IF(getPlayer(player->peer_id) != NULL, "Peer id not unique");
+ if (player->getPeerId() != PEER_ID_INEXISTENT)
+ FATAL_ERROR_IF(getPlayer(player->getPeerId()) != NULL, "Peer id not unique");
// Name has to be unique.
FATAL_ERROR_IF(getPlayer(player->getName()) != NULL, "Player name not unique");
// Add.
@@ -487,7 +487,7 @@ void ServerEnvironment::kickAllPlayers(AccessDeniedCode reason,
const std::string &str_reason, bool reconnect)
{
for (RemotePlayer *player : m_players) {
- m_server->DenyAccessVerCompliant(player->peer_id,
+ m_server->DenyAccessVerCompliant(player->getPeerId(),
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);
for (RemotePlayer *player : m_players) {
// Ignore disconnected players
- if (player->peer_id == 0)
+ if (player->getPeerId() == PEER_ID_INEXISTENT)
continue;
// Move
@@ -1143,7 +1143,7 @@ void ServerEnvironment::step(float dtime)
std::vector<v3s16> players_blockpos;
for (RemotePlayer *player: m_players) {
// Ignore disconnected players
- if (player->peer_id == 0)
+ if (player->getPeerId() == PEER_ID_INEXISTENT)
continue;
PlayerSAO *playersao = player->getPlayerSAO();