SHARE
TWEET

Untitled

a guest Feb 25th, 2016 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void Server::sendMetadataChanged(const std::list<v3s16> &meta_updates, float far_d_nodes)
  2. {
  3.     float maxd = far_d_nodes * BS;
  4.     NodeMetadataList *meta_updates_list = new NodeMetadataList();
  5.  
  6.     std::vector<u16> clients = m_clients.getClientIDs();
  7.     for (std::vector<u16>::iterator i = clients.begin();
  8.             i != clients.end(); ++i) {
  9.         meta_updates_list->clear();
  10.         Player *player = m_env->getPlayer(*i);
  11.         m_clients.lock();
  12.         RemoteClient* client = m_clients.lockedGetClientNoEx(*i);
  13.         if (client != 0) {
  14.             if (client->net_proto_version >= 28) {
  15.                 for (std::list<v3s16>::const_iterator i2 = meta_updates.begin();
  16.                         i2 != meta_updates.end(); ++i2) {
  17.                     v3s16 pos = *i2;
  18.                     NodeMetadata *meta = m_env->getMap().getNodeMetadata(pos);
  19.                     if (!meta) {
  20.                         continue;
  21.                     }
  22.                     if (player) {
  23.                         // If player is far away, only set modified blocks not sent
  24.                         v3f player_pos = player->getPosition();
  25.                         if (player_pos.getDistanceFrom(intToFloat(pos, BS)) > maxd) {
  26.                             client->SetBlockNotSent(getNodeBlockPos(pos));
  27.                             continue;
  28.                         }
  29.                     }
  30.                     meta_updates_list->set(pos, meta);
  31.                 }
  32.                 //here will go the packet sending
  33.             } else {
  34.                 // Older clients expect whole blocks, set them not sent
  35.                 for (std::list<v3s16>::const_iterator i2 = meta_updates.begin();
  36.                         i2 != meta_updates.end(); ++i2) {
  37.                     v3s16 pos = *i2;
  38.                     client->SetBlockNotSent(getNodeBlockPos(pos));
  39.                 }
  40.             }
  41.         }
  42.         m_clients.unlock();
  43.     }
  44. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top