}
try
{
- Address addr = getServer(L)->getPeerAddress(player->peer_id);
+ Address addr = getServer(L)->getPeerAddress(player->getPeerId());
std::string ip_str = addr.serializeString();
lua_pushstring(L, ip_str.c_str());
return 1;
Address addr;
try
{
- addr = getServer(L)->getPeerAddress(player->peer_id);
+ addr = getServer(L)->getPeerAddress(player->getPeerId());
} catch(const con::PeerNotFoundException &) {
dstream << FUNCTION_NAME << ": peer was not found" << std::endl;
lua_pushnil(L); // error
return 1; \
}
- ERET(getServer(L)->getClientConInfo(player->peer_id,con::MIN_RTT,&min_rtt))
- ERET(getServer(L)->getClientConInfo(player->peer_id,con::MAX_RTT,&max_rtt))
- ERET(getServer(L)->getClientConInfo(player->peer_id,con::AVG_RTT,&avg_rtt))
- ERET(getServer(L)->getClientConInfo(player->peer_id,con::MIN_JITTER,&min_jitter))
- ERET(getServer(L)->getClientConInfo(player->peer_id,con::MAX_JITTER,&max_jitter))
- ERET(getServer(L)->getClientConInfo(player->peer_id,con::AVG_JITTER,&avg_jitter))
+ ERET(getServer(L)->getClientConInfo(player->getPeerId(), con::MIN_RTT, &min_rtt))
+ ERET(getServer(L)->getClientConInfo(player->getPeerId(), con::MAX_RTT, &max_rtt))
+ ERET(getServer(L)->getClientConInfo(player->getPeerId(), con::AVG_RTT, &avg_rtt))
+ ERET(getServer(L)->getClientConInfo(player->getPeerId(), con::MIN_JITTER,
+ &min_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,
- &state, &uptime, &ser_vers, &prot_vers,
- &major, &minor, &patch, &vers_string))
+ ERET(getServer(L)->getClientInfo(player->getPeerId(), &state, &uptime, &ser_vers,
+ &prot_vers, &major, &minor, &patch, &vers_string))
lua_newtable(L);
int table = lua_gettop(L);
try
{
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();
getServer(L)->setIpBanned(ip_str, name);
} catch(const con::PeerNotFoundException &) {
lua_pushboolean(L, false); // No such player
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);
return 1;
}
// If failed, cancel
if (!playersao || !player) {
- if (player && player->peer_id != 0) {
+ if (player && player->getPeerId() != PEER_ID_INEXISTENT) {
actionstream << "Server: Failed to emerge player \"" << playername
<< "\" (player allocated to an another client)" << std::endl;
DenyAccess_Legacy(peer_id, L"Another client is connected with this "
// Send information about server to player in chat
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();
actionstream<<player->getName() <<" [" << ip_str << "] joins game. " << std::endl;
/*
{
RemotePlayer *player = m_env->getPlayer(peer_id);
assert(player);
- if(player->peer_id == PEER_ID_INEXISTENT)
+ if(player->getPeerId() == PEER_ID_INEXISTENT)
return;
std::set<std::string> privs;
{
RemotePlayer *player = m_env->getPlayer(peer_id);
assert(player);
- if(player->peer_id == PEER_ID_INEXISTENT)
+ if(player->getPeerId() == PEER_ID_INEXISTENT)
return;
NetworkPacket pkt(TOCLIENT_INVENTORY_FORMSPEC, 0, peer_id);
<<"\" not found"<<std::endl;
return -1;
}
- if(player->peer_id == PEER_ID_INEXISTENT){
+ if (player->getPeerId() == PEER_ID_INEXISTENT) {
infostream<<"Server::playSound: Player \""<<params.to_player
<<"\" not connected"<<std::endl;
return -1;
}
- dst_clients.push_back(player->peer_id);
+ dst_clients.push_back(player->getPeerId());
} else {
std::vector<session_t> clients = m_clients.getClientIDs();
return m_clients.sendToAll(&pkt);
RemotePlayer *p = m_env->getPlayer(check.c_str());
if (p)
- m_clients.send(p->peer_id, 0, &pkt, true);
+ m_clients.send(p->getPeerId(), 0, &pkt, true);
} else {
if (check.empty() || getPlayerName(peer_id) == check)
Send(&pkt);
return ws.str();
}
case RPLAYER_CHATRESULT_KICK:
- DenyAccess_Legacy(player->peer_id,
+ DenyAccess_Legacy(player->getPeerId(),
L"You have been kicked due to message flooding.");
return L"";
case RPLAYER_CHATRESULT_OK:
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)
peer_id_to_avoid_sending = PEER_ID_INEXISTENT;
RemotePlayer *player = m_env->getPlayer(name.c_str());
if (!player)
return;
- SendPlayerPrivileges(player->peer_id);
+ SendPlayerPrivileges(player->getPeerId());
PlayerSAO *sao = player->getPlayerSAO();
if(!sao)
return;
RemotePlayer *player = m_env->getPlayer(name.c_str());
if (!player)
return;
- SendPlayerInventoryFormspec(player->peer_id);
+ SendPlayerInventoryFormspec(player->getPeerId());
}
void Server::setIpBanned(const std::string &ip, const std::string &name)
return;
}
- if (player->peer_id == PEER_ID_INEXISTENT)
+ if (player->getPeerId() == PEER_ID_INEXISTENT)
return;
- SendChatMessage(player->peer_id, ChatMessage(msg));
+ SendChatMessage(player->getPeerId(), ChatMessage(msg));
}
bool Server::showFormspec(const char *playername, const std::string &formspec,
if (!player)
return false;
- SendShowFormspecMessage(player->peer_id, formspec, formname);
+ SendShowFormspecMessage(player->getPeerId(), formspec, formname);
return true;
}
u32 id = player->addHud(form);
- SendHUDAdd(player->peer_id, id, form);
+ SendHUDAdd(player->getPeerId(), id, form);
return id;
}
delete todel;
- SendHUDRemove(player->peer_id, id);
+ SendHUDRemove(player->getPeerId(), id);
return true;
}
if (!player)
return false;
- SendHUDChange(player->peer_id, id, stat, data);
+ SendHUDChange(player->getPeerId(), id, stat, data);
return true;
}
if (!player)
return false;
- SendHUDSetFlags(player->peer_id, flags, mask);
+ SendHUDSetFlags(player->getPeerId(), flags, mask);
player->hud_flags &= ~mask;
player->hud_flags |= flags;
player->setHotbarItemcount(hotbar_itemcount);
std::ostringstream os(std::ios::binary);
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;
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)
return;
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
return false;
player->setLocalAnimations(animation_frames, frame_speed);
- SendLocalPlayerAnimations(player->peer_id, animation_frames, frame_speed);
+ SendLocalPlayerAnimations(player->getPeerId(), animation_frames, frame_speed);
return true;
}
player->eye_offset_first = first;
player->eye_offset_third = third;
- SendEyeOffset(player->peer_id, first, third);
+ SendEyeOffset(player->getPeerId(), first, third);
return true;
}
return false;
player->setSky(bgcolor, type, params, clouds);
- SendSetSky(player->peer_id, bgcolor, type, params, clouds);
+ SendSetSky(player->getPeerId(), bgcolor, type, params, clouds);
return true;
}
if (!player)
return false;
- SendCloudParams(player->peer_id, density,
+ SendCloudParams(player->getPeerId(), density,
color_bright, color_ambient, height,
thickness, speed);
return true;
return false;
player->overrideDayNightRatio(do_override, ratio);
- SendOverrideDayNightRatio(player->peer_id, do_override, ratio);
+ SendOverrideDayNightRatio(player->getPeerId(), do_override, ratio);
return true;
}
RemotePlayer *player = m_env->getPlayer(playername.c_str());
if (!player)
return;
- peer_id = player->peer_id;
+ peer_id = player->getPeerId();
proto_ver = player->protocol_version;
}
RemotePlayer *player = m_env->getPlayer(playername.c_str());
if (!player)
return -1;
- peer_id = player->peer_id;
+ peer_id = player->getPeerId();
proto_ver = player->protocol_version;
}
RemotePlayer *player = m_env->getPlayer(playername.c_str());
if (!player)
return;
- peer_id = player->peer_id;
+ peer_id = player->getPeerId();
}
m_env->deleteParticleSpawner(id);
RemotePlayer *player = m_env->getPlayer(name);
// 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;
return NULL;
}
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;
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.
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);
}
}
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
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();