- is.read((char*)buf, 2);
- u16 blockcount = readU16(buf);
-
- // Initialize delete queue with all active blocks
- core::map<v3s16, bool> abs_to_delete;
- for(core::map<v3s16, bool>::Iterator
- i = m_active_blocks.getIterator();
- i.atEnd() == false; i++)
- {
- v3s16 p = i.getNode()->getKey();
- /*dstream<<"adding "
- <<"("<<p.x<<","<<p.y<<","<<p.z<<") "
- <<" to abs_to_delete"
- <<std::endl;*/
- abs_to_delete.insert(p, true);
- }
-
- /*dstream<<"Initial delete queue size: "<<abs_to_delete.size()
- <<std::endl;*/
-
- for(u16 i=0; i<blockcount; i++)
- {
- // Read blockpos
- is.read((char*)buf, 6);
- v3s16 p = readV3S16(buf);
- // Get block from somewhere
- MapBlock *block = NULL;
- try{
- block = m_env.getMap().getBlockNoCreate(p);
- }
- catch(InvalidPositionException &e)
- {
- //TODO: Create a dummy block?
- }
- if(block == NULL)
- {
- dstream<<"WARNING: "
- <<"Could not get block at blockpos "
- <<"("<<p.X<<","<<p.Y<<","<<p.Z<<") "
- <<"in TOCLIENT_OBJECTDATA. Ignoring "
- <<"following block object data."
- <<std::endl;
- return;
- }
-
- /*dstream<<"Client updating objects for block "
- <<"("<<p.X<<","<<p.Y<<","<<p.Z<<")"
- <<std::endl;*/
-
- // Insert to active block list
- m_active_blocks.insert(p, true);
-
- // Remove from deletion queue
- if(abs_to_delete.find(p) != NULL)
- abs_to_delete.remove(p);
-
- /*
- Update objects of block
-
- NOTE: Be sure this is done in the main thread.
- */
- block->updateObjects(is, m_server_ser_ver,
- m_device->getSceneManager(), m_env.getDayNightRatio());
- }
-
- /*dstream<<"Final delete queue size: "<<abs_to_delete.size()
- <<std::endl;*/
-
- // Delete objects of blocks in delete queue
- for(core::map<v3s16, bool>::Iterator
- i = abs_to_delete.getIterator();
- i.atEnd() == false; i++)
- {
- v3s16 p = i.getNode()->getKey();
- try
- {
- MapBlock *block = m_env.getMap().getBlockNoCreate(p);
-
- // Clear objects
- block->clearObjects();
- // Remove from active blocks list
- m_active_blocks.remove(p);
- }
- catch(InvalidPositionException &e)
- {
- dstream<<"WARNAING: Client: "
- <<"Couldn't clear objects of active->inactive"
- <<" block "
- <<"("<<p.X<<","<<p.Y<<","<<p.Z<<")"
- <<" because block was not found"
- <<std::endl;
- // Ignore
- }