void Server::SetBlocksNotSent(std::map<v3s16, MapBlock *>& block)
{
- std::list<u16> clients = m_clients.getClientIDs();
+ std::vector<u16> clients = m_clients.getClientIDs();
m_clients.Lock();
// Set the modified blocks unsent for all the clients
- for (std::list<u16>::iterator
- i = clients.begin();
+ for (std::vector<u16>::iterator i = clients.begin();
i != clients.end(); ++i) {
- RemoteClient *client = m_clients.lockedGetClientNoEx(*i);
- if (client != NULL)
+ if (RemoteClient *client = m_clients.lockedGetClientNoEx(*i))
client->SetBlocksNotSent(block);
- }
+ }
m_clients.Unlock();
}
}
else
{
- std::list<u16> clients = m_clients.getClientIDs();
+ std::vector<u16> clients = m_clients.getClientIDs();
- for(std::list<u16>::iterator
- i = clients.begin(); i != clients.end(); ++i)
- {
+ for(std::vector<u16>::iterator
+ i = clients.begin(); i != clients.end(); ++i) {
Player *player = m_env->getPlayer(*i);
if(!player)
continue;
- if(pos_exists){
+
+ if(pos_exists) {
if(player->getPosition().getDistanceFrom(pos) >
params.max_hear_distance)
continue;
dst_clients.push_back(*i);
}
}
+
if(dst_clients.empty())
return -1;
NetworkPacket* pkt = new NetworkPacket(TOCLIENT_REMOVENODE, 6);
*pkt << p;
- std::list<u16> clients = m_clients.getClientIDs();
- for(std::list<u16>::iterator
- i = clients.begin();
+ std::vector<u16> clients = m_clients.getClientIDs();
+ for(std::vector<u16>::iterator i = clients.begin();
i != clients.end(); ++i) {
if(far_players) {
// Get player
float maxd = far_d_nodes*BS;
v3f p_f = intToFloat(p, BS);
- std::list<u16> clients = m_clients.getClientIDs();
- for(std::list<u16>::iterator
- i = clients.begin();
- i != clients.end(); ++i)
- {
+ std::vector<u16> clients = m_clients.getClientIDs();
+ for(std::vector<u16>::iterator i = clients.begin();
+ i != clients.end(); ++i) {
- if(far_players)
- {
+ if(far_players) {
// Get player
- Player *player = m_env->getPlayer(*i);
- if(player)
- {
+ if(Player *player = m_env->getPlayer(*i)) {
// If player is far away, only set modified blocks not sent
v3f player_pos = player->getPosition();
- if(player_pos.getDistanceFrom(p_f) > maxd)
- {
+ if(player_pos.getDistanceFrom(p_f) > maxd) {
far_players->push_back(*i);
continue;
}
void Server::setBlockNotSent(v3s16 p)
{
- std::list<u16> clients = m_clients.getClientIDs();
+ std::vector<u16> clients = m_clients.getClientIDs();
m_clients.Lock();
- for(std::list<u16>::iterator
- i = clients.begin();
- i != clients.end(); ++i)
- {
+ for(std::vector<u16>::iterator i = clients.begin();
+ i != clients.end(); ++i) {
RemoteClient *client = m_clients.lockedGetClientNoEx(*i);
client->SetBlockNotSent(p);
}
{
ScopeProfiler sp(g_profiler, "Server: selecting blocks for sending");
- std::list<u16> clients = m_clients.getClientIDs();
+ std::vector<u16> clients = m_clients.getClientIDs();
m_clients.Lock();
- for(std::list<u16>::iterator
- i = clients.begin();
- i != clients.end(); ++i)
- {
+ for(std::vector<u16>::iterator i = clients.begin();
+ i != clients.end(); ++i) {
RemoteClient *client = m_clients.lockedGetClientNoEx(*i, CS_Active);
if (client == NULL)
Print out action
*/
{
- if(player != NULL && reason != CDR_DENY)
- {
+ if(player != NULL && reason != CDR_DENY) {
std::ostringstream os(std::ios_base::binary);
- std::list<u16> clients = m_clients.getClientIDs();
+ std::vector<u16> clients = m_clients.getClientIDs();
- for(std::list<u16>::iterator
- i = clients.begin();
- i != clients.end(); ++i)
- {
+ for(std::vector<u16>::iterator i = clients.begin();
+ i != clients.end(); ++i) {
// Get player
Player *player = m_env->getPlayer(*i);
if(!player)
continue;
+
// Get name of player
- os<<player->getName()<<" ";
+ os << player->getName() << " ";
}
- actionstream<<player->getName()<<" "
- <<(reason==CDR_TIMEOUT?"times out.":"leaves game.")
- <<" List of players: "<<os.str()<<std::endl;
+ actionstream << player->getName() << " "
+ << (reason == CDR_TIMEOUT ? "times out." : "leaves game.")
+ << " List of players: " << os.str() << std::endl;
}
}
{
// Information about clients
bool first = true;
os<<L", clients={";
- std::list<u16> clients = m_clients.getClientIDs();
- for(std::list<u16>::iterator i = clients.begin();
- i != clients.end(); ++i)
- {
+ std::vector<u16> clients = m_clients.getClientIDs();
+ for(std::vector<u16>::iterator i = clients.begin();
+ i != clients.end(); ++i) {
// Get player
Player *player = m_env->getPlayer(*i);
// Get name of player
name = narrow_to_wide(player->getName());
// Add name to information string
if(!first)
- os<<L", ";
+ os << L", ";
else
first = false;
- os<<name;
+ os << name;
}
- os<<L"}";
+ os << L"}";
if(((ServerMap*)(&m_env->getMap()))->isSavingEnabled() == false)
os<<std::endl<<L"# Server: "<<" WARNING: Map saving is disabled.";
if(g_settings->get("motd") != "")
void Server::reportPrivsModified(const std::string &name)
{
- if(name == ""){
- std::list<u16> clients = m_clients.getClientIDs();
- for(std::list<u16>::iterator
- i = clients.begin();
- i != clients.end(); ++i){
+ if(name == "") {
+ std::vector<u16> clients = m_clients.getClientIDs();
+ for(std::vector<u16>::iterator i = clients.begin();
+ i != clients.end(); ++i) {
Player *player = m_env->getPlayer(*i);
reportPrivsModified(player->getName());
}