void WorldModelHandler::ProcessInternal( ChunkedData* subChunks )
{
    if (!IsSane())
        return;
    Chunk* wmoReferencesChunk = subChunks->GetChunkByName("MCRW");
    if (!wmoReferencesChunk)
        return;
    FILE* stream = wmoReferencesChunk->GetStream();
    uint32 refCount = wmoReferencesChunk->Length / 4;
    for (uint32 i = 0; i < refCount; i++)
    {
        int32 index;
        if (fread(&index, sizeof(int32), 1, stream) != 1)
            printf("WorldModelDefinition::Read: Error reading data, expected 1, read 0\n");

        if (index < 0 || uint32(index) >= _definitions->size())
            continue;

        WorldModelDefinition wmo = (*_definitions)[index];

        if (_drawn.find(wmo.UniqueId) != _drawn.end())
            continue;
        _drawn.insert(wmo.UniqueId);

        if (wmo.MwidIndex >= _paths->size())
            continue;

        std::string path = (*_paths)[wmo.MwidIndex];
        WorldModelRoot* model = Cache->WorldModelCache.Get(path);
        if (!model)
        {
            model = new WorldModelRoot(path);
            Cache->WorldModelCache.Insert(path, model);
        }

        Vertices.reserve(1000);
        Triangles.reserve(1000);

        InsertModelGeometry(Vertices, Triangles, wmo, model);
    }
}
Exemple #2
0
void _3dsLoader::readMaterialMapFile(Chunk &currentChunk, Material &material) const
{
	ASSERT(currentChunk.getID()==MATMAPFILE, "Expected chunk ID MATMAPFILE");

	const size_t size = currentChunk.getSize() - currentChunk.tell();
	char *relativeFileName = new char[size];
	currentChunk.read(relativeFileName, size);

	const string chunkFile = currentChunk.getFilename();
	const string path = File::getPath(chunkFile);
	const string absoluteFileName = pathAppend(path, relativeFileName);

	TRACE("3DS current file: " + chunkFile);
	TRACE("3DS current path: " + path);
	TRACE(string("3DS material: ") + relativeFileName);
	TRACE("Reading 3DS material from: " + absoluteFileName);

	material.loadTexture(absoluteFileName, 0);

	delete[] relativeFileName;
}
Exemple #3
0
/*
 * NAME:	str->new()
 * DESCRIPTION:	make a new string with length 0.
 */
str *pps_new(char *buf, int sz)
{
    str *sb;

    sb = schunk.alloc();
    sb->buffer = buf;
    sb->buffer[0] = '\0';
    sb->size = sz;
    sb->len = 0;

    return sb;
}
void WorldModelHandler::ReadModelPaths()
{
    Chunk* mwid = Source->ObjectData->GetChunkByName("MWID");
    Chunk* mwmo = Source->ObjectData->GetChunkByName("MWMO");
    if (!mwid || !mwmo)
        return;

    uint32 paths = mwid->Length / 4;
    _paths = new std::vector<std::string>;
    _paths->reserve(paths);
    for (uint32 i = 0; i < paths; i++)
    {
        FILE* stream = mwid->GetStream();
        fseek(stream, i * 4, SEEK_CUR);
        uint32 offset;
        fread(&offset, sizeof(uint32), 1, stream);
        FILE* dataStream = mwmo->GetStream();
        fseek(dataStream, offset + mwmo->Offset, SEEK_SET);
        _paths->push_back(Utils::ReadString(dataStream));
    }
}
Exemple #5
0
void ChunkGenerator::setBiomes(Map& m, Chunk chunk, int x, int z, int biomeNoise) {
  BiomeType type = chunk.getBiomeType();

  double frequency = getFrequency(type);
  int lowerBound = getLowerBound(type);
  int upperBound = getUpperBound(type);

  for(int xi = x * 16; xi < (x * 16) + 16; xi++) {
    // Blöcke von oben nach unten (in Blockkoordinaten)
    for(int zj = z * 16; zj < (z * 16) + 16; zj++) {




      // Simplex Noise:
      double simpNoise;
      int noise;
      // Wenn Biom Mountains oder Hillside
      if(70 <= biomeNoise && biomeNoise <= 126){
        // Umrechnen von Intervall [70,126] in [-1.25,1.25] für Gaußsche Glockenkurve
        double term = ((1.75 * biomeNoise - (-1.75) * biomeNoise + 126 * (-1.75) - 1.75 * 70) / (126.0 - 70.0));
        // Multiplikation von Simplex Noise mit Gaußscher Glockenkurve für einen weicheren Biomübergang an den Bergen
        simpNoise = exp(-1 * term * term) * SimplexNoise::noise(frequency * xi, frequency * zj, m_seed);
        // Umrechnen von Intervall [-1,1] in Intervall [c,d]
        noise = SimplexNoise::noiseInt(lowerBound, upperBound, simpNoise) - 9;
        if(type == BiomeType::WaterHillside) {
          noise -= 10;
        } 
        if(m_setWater == false) {
          noise += 3;
        }
      }
      else {
        // Berechne Werte im Intervall [-1,1] mit Simplex Noise
        simpNoise = SimplexNoise::noise(frequency * xi, frequency * zj, m_seed);
        // Umrechnen von Intervall [-1,1] in Intervall [c,d]
        noise = SimplexNoise::noiseInt(lowerBound, upperBound, simpNoise) + 1;
      }

      // xi und zj umrechnen
      int xii = xi%16;
	    int zjj = zj%16;
	    if(xii < 0) {
	      xii += 16;
	    }
	    if(zjj % 16 < 0) {
	      zjj += 16;
	    }

      setBlockHeight(m, type, x, z, xii, zjj, noise, biomeNoise);
    }
  }
}
Exemple #6
0
void loadChunk(Chunk chunk, bool alive){
    for(int y=LEVEL_HEIGHT-1; y > 0 ; y--){
        for(int x=0; x < LEVEL_WIDTH; x++){
            if(chunk.get(y, x)){
                Entity myEntity = *new Entity(chunk.tileGlobalX(y, x),-(chunk.tileGlobalY(y,x)),TILE_X,TILE_Y);
                if (rand() % 100 < 20){
                    myEntity.type = BPLATFORM;
                    myEntity.sprite = SheetSprite(spriteSheetTexture, 0.0f/914.0f, 432.0f/936.0f, 70.0f/914.0f, 70.0f/936.0f, 0.2);
                }
                else{
                    myEntity.type = PLATFORM;
                    myEntity.sprite = SheetSprite(spriteSheetTexture, 504.0f/914.0f, 288.0f/936.0f, 70.0f/914.0f, 70.0f/936.0f, 0.2);
                }
                
                myEntity.isStatic = true;
                myEntity.isAlive = alive;
                entities.push_back(myEntity);
            }
        }
    }
}
void WorldModelHandler::ReadModelPaths()
{
    Chunk* mwid = Source->ObjectData->GetChunkByName("MWID");
    Chunk* mwmo = Source->ObjectData->GetChunkByName("MWMO");
    if (!mwid || !mwmo)
        return;

    uint32 paths = mwid->Length / 4;
    _paths = new std::vector<std::string>;
    _paths->reserve(paths);
    for (uint32 i = 0; i < paths; i++)
    {
        Stream* stream = mwid->GetStream();
        stream->Seek(i * 4, SEEK_CUR);
        uint32 offset = stream->Read<uint32>();

        Stream* dataStream = mwmo->GetStream();
        dataStream->Seek(offset + mwmo->Offset, SEEK_SET);
        _paths->push_back(dataStream->ReadString());
    }
}
	void ChunkManager::chunkDownloaded(unsigned int i)
	{
		if (i >= (Uint32)d->chunks.size())
			return;

		Chunk* c = d->chunks[i];
		if (!c->isExcluded())
		{
			// update the index file
			bitset.set(i,true);
			d->todo.set(i,false);
			d->recalc_chunks_left = true;
			d->writeIndexFileEntry(c);
			c->setStatus(Chunk::ON_DISK);
			tor.updateFilePercentage(i,*this);
		}
		else
		{
			Out(SYS_DIO|LOG_IMPORTANT) << "Warning: attempted to save a chunk which was excluded" << endl;
		}
	}
Exemple #9
0
 void Encode(const Chunk& data)
 {
   const std::size_t samples = data.size();
   float** const buffer = VorbisApi->vorbis_analysis_buffer(&State, samples);
   for (std::size_t pos = 0; pos != samples; ++pos)
   {
     const Sample in = data[pos];
     buffer[0][pos] = ToFloat(in.Left());
     buffer[1][pos] = ToFloat(in.Right());
   }
   CheckVorbisCall(VorbisApi->vorbis_analysis_wrote(&State, samples), THIS_LINE);
 }
void Player::checkChunk()
{
	glm::vec3 currentChunkPosition = ChunkManager::instance()->getCurrentChunk(m_currentPosition);

	if (currentChunkPosition != m_chunkPosition)
	{
		Chunk c;
		bool gotChunk = ChunkManager::instance()->getChunkHandle(currentChunkPosition, c);

		if (gotChunk)
		{
			m_chunkPosition = currentChunkPosition;
			m_chunkPositions = c.getBlockPositions();
			m_chunkPositionsFoliage = c.getFoliageBlockPositions();

			// If gravity was not enabled, well then enable it
			if(!m_ready)
				m_ready = true;
		}
	}
}
Exemple #11
0
    std::vector<char> buildData(Chunk& chunk) const
    {
        Cell::PooledStack cellStack(chunk.acquire());
        Data::PooledStack dataStack(chunk.pool().dataPool());
        for (Cell& cell : cellStack) dataStack.push(cell.acquire());
        cellStack.release();

        const std::size_t pointSize(chunk.schema().pointSize());

        std::vector<char> data;
        data.reserve(
                dataStack.size() * pointSize +
                buildTail(chunk, dataStack.size()).size());

        for (const char* d : dataStack)
        {
            data.insert(data.end(), d, d + pointSize);
        }

        return data;
    }
Exemple #12
0
MojErr MojBuffer::consolidate()
{
	if (m_chunks.size() > 1) {
		// calc total size
		MojSize size = 0;
		for (ChunkList::ConstIterator i = m_chunks.begin(); i != m_chunks.end(); ++i) {
			size += (*i)->dataSize();
		}
		// alloc chunk big enoug to hold it all
		Chunk* chunk = allocChunk(size);
		MojAllocCheck(chunk);
		// copy alldata to new chunk
		for (ChunkList::ConstIterator i = m_chunks.begin(); i != m_chunks.end(); ++i) {
			chunk->write((*i)->data(), (*i)->dataSize());
		}
		// replace existing chunks with new one
		clear();
		m_chunks.pushBack(chunk);
	}
	return MojErrNone;
}
Vector3 toObstacle( const Vector3& v )
{
	// restrict to looking in the current chunk
	Chunk * chunk = ChunkManager::instance().cameraSpace()->findChunkFromPoint( v );
	if (chunk == NULL)
		return v;

	// look up for clusest thing above
	Vector3 pos(v);
	Vector3 end(v);
	end.y += 400.f;

	const BoundingBox& chunkBox = chunk->boundingBox();
	bool cliped = chunkBox.clip(pos, end);

	Vector3 groundPos = toObstacle(end, Vector3(0.f, -1.f, 0.f));
	if (groundPos != pos)
		return groundPos;

	return v;
}
    size_t BitmapEncoding::Bitmap::decompress(void const* src, size_t size, Chunk& chunk)
    {
        size_t chunkSize = chunk.getSize();
        TypeId type = chunk.getAttributeDesc().getType();        
        _elementSize = TypeLibrary::getType(type).byteSize();

        if(_elementSize == 0 || _elementSize > 8 || chunk.isSparse() || !chunk.getArrayDesc().isImmutable() || chunk.getAttributeDesc().isNullable())
        {
            _bitmapElements = chunkSize;
            _elementSize = 1;
        }
        else
        {
            _bitmapElements = chunkSize / _elementSize;
        }


        if(!_bitmapElements) { return chunkSize; }

        uint8_t* dst = (uint8_t*)chunk.getData();
        ByteInputItr in((uint8_t *)src, size);
        uint32_t bmLength = ceil(_bitmapElements / 8.0);
        uint32_t individualBMLength = bmLength + _elementSize; // value + bm
        assert(individualBMLength);
        uint32_t bitmaps = size / individualBMLength;

        boost::scoped_array<uint8_t> bitmapArr(new uint8_t[bmLength]);
        boost::scoped_array<uint8_t> baseValueArr(new uint8_t[_elementSize]);

        uint8_t *bitmap = bitmapArr.get();
        uint8_t *baseValue = baseValueArr.get();

        for(uint32_t i = 0; i < bitmaps; ++i)
        {
            if(in.getArray(baseValue, _elementSize) == -1) { return 0; }
            if(in.getArray(bitmap, bmLength)== -1) { return 0; } 
            decodeBitmap(baseValue, bitmap, dst);
        }
        return chunkSize;
    }
Exemple #15
0
void verifyChunkMD5(vector<File> &files) {
  try {
    while (true) {
      Chunk * c = chunksToComputeMD5.consume();
      if (files[c->parentFileIndex].matchStatus == File::Status::FAILED_TO_MATCH_REMOTE_FILE) {
        // We have already marked file as a non-match, don't waste time reading more chunks from it
        c->log("File status == FAILED_TO_MATCH_REMOTE_FILE, Skipping the MD5 compute...");
        chunksSkipped.produce(c);
      } else {
        c->log("Computing MD5...");
        string computedMD5 = c->computeMD5();
        if (c->expectedMD5 != computedMD5) {
          c->log("MISMATCH between expected MD5 '" + c->expectedMD5 + "', and computed MD5 '" + computedMD5 + "' ... marking the file as Mismatch");
          files[c->parentFileIndex].matchStatus = File::Status::FAILED_TO_MATCH_REMOTE_FILE;
          chunksFailed.produce(c);
        } else {
          c->log("Expected and computed MD5 match!");
          chunksFinished.produce(c);
        }
      }
    }
  } catch (boost::thread_interrupted &ti) {
    return;
  }
}
Exemple #16
0
// World editing
void Player::DestroyBlock()
{
	if (m_blockSelection)
	{
		Chunk* pChunk = m_pChunkManager->GetChunkFromPosition(m_blockSelectionPos.x, m_blockSelectionPos.y, m_blockSelectionPos.z);

		if (pChunk != NULL)
		{
			int blockX, blockY, blockZ;
			vec3 blockPos;
			bool active = m_pChunkManager->GetBlockActiveFrom3DPosition(m_blockSelectionPos.x, m_blockSelectionPos.y, m_blockSelectionPos.z, &blockPos, &blockX, &blockY, &blockZ, &pChunk);
			if (active)
			{
				float r;
				float g;
				float b;
				float a;
				pChunk->GetColour(blockX, blockY, blockZ, &r, &g, &b, &a);

				pChunk->StartBatchUpdate();
				pChunk->SetColour(blockX, blockY, blockZ, 0);
				pChunk->StopBatchUpdate();

				m_pChunkManager->CreateBlockDestroyParticleEffect(r, g, b, a, m_blockSelectionPos);

				// Create the collectible block item
				BlockType blockType = pChunk->GetBlockType(blockX, blockY, blockZ);
				m_pChunkManager->CreateCollectibleBlock(blockType, m_blockSelectionPos);
			}
		}

		m_blockSelection = false;
	}
}
Exemple #17
0
void WireRenderer::removedBlock(const BLOCK_WDATA block, int local_x, int local_y, int local_z, Chunk &c)
{
    //Removal of a unpowered redstone wire doesn't change anything
    if(getPOWERSTATE(block) == false)
        return;

    //But now there may be different circuits, so check them seperately
    if(getBLOCK(c.getGlobalBlockRelative(local_x - 1, local_y, local_z)) == BLOCK_REDSTONE_WIRE && !isActiveLeft(local_x - 1, local_y, local_z, c))
        setCircuitState(false, local_x - 1, local_y, local_z, c);

    if(getBLOCK(c.getGlobalBlockRelative(local_x + 1, local_y, local_z)) == BLOCK_REDSTONE_WIRE && !isActiveLeft(local_x + 1, local_y, local_z, c))
        setCircuitState(false, local_x + 1, local_y, local_z, c);

    if(getBLOCK(c.getGlobalBlockRelative(local_x, local_y - 1, local_z)) == BLOCK_REDSTONE_WIRE && !isActiveLeft(local_x, local_y - 1, local_z, c))
        setCircuitState(false, local_x, local_y - 1, local_z, c);

    if(getBLOCK(c.getGlobalBlockRelative(local_x, local_y + 1, local_z)) == BLOCK_REDSTONE_WIRE && !isActiveLeft(local_x, local_y + 1, local_z, c))
        setCircuitState(false, local_x, local_y + 1, local_z, c);

    if(getBLOCK(c.getGlobalBlockRelative(local_x, local_y, local_z - 1)) == BLOCK_REDSTONE_WIRE && !isActiveLeft(local_x, local_y, local_z - 1, c))
        setCircuitState(false, local_x, local_y, local_z - 1, c);

    if(getBLOCK(c.getGlobalBlockRelative(local_x, local_y, local_z + 1)) == BLOCK_REDSTONE_WIRE && !isActiveLeft(local_x, local_y, local_z + 1, c))
        setCircuitState(false, local_x, local_y, local_z + 1, c);
}
Exemple #18
0
Chunk * FixedAllocator::VicinityFind( void * p ) const
{
    if ( chunks_.empty() ) return NULL;
    assert(deallocChunk_);

    const std::size_t chunkLength = numBlocks_ * blockSize_;
    Chunk * lo = deallocChunk_;
    Chunk * hi = deallocChunk_ + 1;
    const Chunk * loBound = &chunks_.front();
    const Chunk * hiBound = &chunks_.back() + 1;

    // Special case: deallocChunk_ is the last in the array
    if (hi == hiBound) hi = NULL;

    for (;;)
    {
        if (lo)
        {
            if ( lo->HasBlock( p, chunkLength ) ) return lo;
            if ( lo == loBound )
            {
                lo = NULL;
                if ( NULL == hi ) break;
            }
            else --lo;
        }

        if (hi)
        {
            if ( hi->HasBlock( p, chunkLength ) ) return hi;
            if ( ++hi == hiBound )
            {
                hi = NULL;
                if ( NULL == lo ) break;
            }
        }
    }

    return NULL;
}
Exemple #19
0
void FreeList<Chunk>::remove_chunk(Chunk*fc) {
   assert_proper_lock_protection();
   assert(head() != NULL, "Remove from empty list");
   assert(fc != NULL, "Remove a NULL chunk");
   assert(size() == fc->size(), "Wrong list");
   assert(head() == NULL || head()->prev() == NULL, "list invariant");
   assert(tail() == NULL || tail()->next() == NULL, "list invariant");

   Chunk* prevFC = fc->prev();
   Chunk* nextFC = fc->next();
   if (nextFC != NULL) {
     // The chunk fc being removed has a "next".  Set the "next" to the
     // "prev" of fc.
     nextFC->link_prev(prevFC);
   } else { // removed tail of list
     link_tail(prevFC);
   }
   if (prevFC == NULL) { // removed head of list
     link_head(nextFC);
     assert(nextFC == NULL || nextFC->prev() == NULL,
       "Prev of head should be NULL");
   } else {
     prevFC->link_next(nextFC);
     assert(tail() != prevFC || prevFC->next() == NULL,
       "Next of tail should be NULL");
   }
   decrement_count();
   assert(((head() == NULL) + (tail() == NULL) + (count() == 0)) % 3 == 0,
          "H/T/C Inconsistency");
   // clear next and prev fields of fc, debug only
   NOT_PRODUCT(
     fc->link_prev(NULL);
     fc->link_next(NULL);
   )
Exemple #20
0
bool Image::insertChunk ( const Chunk &chunk )
{
	if ( chunk.getVolume() == 0 ) {
		LOG( Runtime, error )
				<< "Cannot insert empty Chunk (Size is " << chunk.getSizeAsString() << ").";
		return false;
	}

	if ( ! chunk.isValid() ) {
		LOG( Runtime, error )
				<< "Cannot insert invalid chunk. Missing properties: " << chunk.getMissing();
		return false;
	}

	if( clean ) {
		LOG( Runtime, warning ) << "Inserting into already indexed images is inefficient. You should not do that.";

		// re-gather all properties of the chunks from the image
		BOOST_FOREACH( boost::shared_ptr<Chunk> &ref, lookup ) {
			ref->join( *this );
		}
	}
Exemple #21
0
Chunk* ISegment::toChunk(size_t index, BaseRepresentation *ctxrep)
{
    Chunk *chunk;
    try
    {
        chunk = getChunk(getUrlSegment().toString(index, ctxrep));
        if (!chunk)
            return NULL;
    }
    catch (int)
    {
        return NULL;
    }

    if(startByte != endByte)
    {
        chunk->setStartByte(startByte);
        chunk->setEndByte(endByte);
    }

    return chunk;
}
void SpaceNodeConnection::handleRead(const Chunk& chunk, const Sirikata::Network::Stream::PauseReceiveCallback& pause) {
    mHandleReadStage->started();

    // Parse
    ObjectMessage* msg = new ObjectMessage();
    bool parse_success = msg->ParseFromArray(&(*chunk.begin()), chunk.size());
    if (!parse_success) {
        LOG_INVALID_MESSAGE(session, error, chunk);
        delete msg;
        return;
    }

    TIMESTAMP_START(tstamp, msg);

    // Mark as received
    TIMESTAMP_END(tstamp, Trace::OH_NET_RECEIVED);

    // NOTE: We can't record drops here or we incur a lot of overhead in parsing...
    // Session messages need to be reliable, we force them through
    bool session_msg = (msg->dest_port() == OBJECT_PORT_SESSION);
    bool pushed = receive_queue.push(msg, session_msg);

    if (pushed) {
        // handleConnectionRead() could be called from any thread/strand. Everything that is not
        // thread safe that could result from a new message needs to happen in the main strand,
        // so just post the whole handler there.
        if (receive_queue.wentNonEmpty())
            mReceiveCB(this);
    }
    else {
        TIMESTAMP_END(tstamp, Trace::OH_DROPPED_AT_RECEIVE_QUEUE);
        TRACE_DROP(OH_DROPPED_AT_RECEIVE_QUEUE);
        delete msg;
    }

    mHandleReadStage->finished();

    // No matter what, we've "handled" the data, either for real or by dropping.
}
Exemple #23
0
void readChunks() {
    try {
        while (true) {
            Chunk * c = chunksToRead.consume();

            c->log("Reading...");
            c->read();

            c->log("Finished reading");
            chunksToCompress.produce(c);

            // Sleep for tiny amount of time, to make sure we yield to other threads.
            // Note: boost::this_thread::yield() is not a valid interruption point,
            //       so we have to use sleep()
            boost::this_thread::sleep(boost::posix_time::microseconds(100));
        }
    } catch(std::bad_alloc &e) {
        boost::call_once(bad_alloc_once, boost::bind(&handle_bad_alloc, e));
    } catch (boost::thread_interrupted &ti) {
        return;
    }
}
void WorldModelGroup::ReadMaterials()
{
    Chunk* chunk = SubData->GetChunkByName("MOPY");
    if (!chunk)
        return;

    FILE* stream = chunk->GetStream();
    uint32 triangleCount = chunk->Length / 2;
    TriangleFlags.reserve(triangleCount);
    TriangleMaterials.reserve(triangleCount);
    for (uint32 i = 0; i < triangleCount; i++)
    {
        uint8 tmp;
        if (fread(&tmp, sizeof(uint8), 1, stream) != 1)
            printf("WorldModelGroup::ReadMaterials: Error reading data, expected 1, read 0\n");
        TriangleFlags.push_back(tmp);
        // Read again for material.
        if (fread(&tmp, sizeof(uint8), 1, stream) != 1)
            printf("WorldModelGroup::ReadMaterials: Error reading data, expected 1, read 0\n");
        TriangleMaterials.push_back(tmp);
    }
}
Exemple #25
0
void GameWorld::createChunks(int sizex, int sizey)
{

	leftChunk = 0;
	topChunk = 0;
	botChunk = sizey-1;
	rightChunk = sizex - 1;

	for (int i = 0; i < sizex; i++)
	{
		for (int j = 0; j < sizey; j++)
		{
			Chunk *newChunk = new Chunk();			
			newChunk->load(i, j, true);
			//newChunk->generateTiles();
			Chunks.push_back(newChunk);
		}
	}

	TerrainCenter.x =( sizex*ChunkSize*TileSize)/2 ;
	TerrainCenter.y = (sizey*ChunkSize*TileSize) / 2;
}
Exemple #26
0
//Add compressed chunk to list/map
//  Return false if chunk could not be added
bool World::addChunkZip(int32_t X, int8_t Y, int32_t Z,
    uint8_t size_X, uint8_t size_Y, uint8_t size_Z,
    uint32_t ziplength, uint8_t *zipped, bool unzip)
{
    bool result=false;
    
    Chunk* chunk = new Chunk(size_X, size_Y, size_Z, X, Y, Z);
    if (chunk) {
        chunk->copyZip(ziplength, zipped);
        addChunkUpdate(chunk);
        
        //byte_array and block_array are still NULL!
        if (unzip) {
            result = chunk->unzip(false);
            chunk->unpackBlocks(false);
        } else {
            result=true;
        }
        
    }
    return result;
}
void CustomizationIdManager::readObject(IffStream* iffStream) {
	iffStream->openForm('CIDM');
	iffStream->openForm('0001');

	Chunk* data = iffStream->openChunk('DATA');

	while (data->hasData()) {
		int id = data->readShort();
		String var;
		data->readString(var);

		customizationIds.put(var, id);
		reverseIds.put(id, var);
	}

	iffStream->closeChunk('DATA');

	iffStream->closeForm('0001');
	iffStream->closeForm('CIDM');

	info("loaded " + String::valueOf(customizationIds.size()) + " customization ids", true);
}
Exemple #28
0
void RamLogger::Log(const char* aMsg)
{
    Chunk* chunk = NULL;
    if (iChunks.size() > 0) {
        chunk = iChunks[iChunks.size()-1];
        if (chunk->BytesRemaining() == 0) {
            chunk = NULL;
        }
    }
    if (chunk == NULL) {
        chunk = NewChunk();
    }
    const TUint len = (TUint)strlen(aMsg);
    const char* p = aMsg;
    for (;;) {
        p += chunk->Append(p);
        if (p >= aMsg+len) {
            break;
        }
        chunk = NewChunk();
    }
}
Exemple #29
0
Map::Map()
{
	for (int x = 0; x < MAP_WIDTH; x++)
	{
		auto chunkX = mChunks.find(x);
		if (chunkX == mChunks.end())
		{
			std::unordered_map<int, Chunk*> newChunkX;
			mChunks.insert({ x,  newChunkX });

			chunkX = mChunks.find(x);
		}

		for (int z = 0; z < MAP_DEPTH; z++)
		{
			Chunk* chunk = new Chunk();
			chunk->update(x, z, nullptr, nullptr, nullptr, nullptr);

			chunkX->second.insert({ z,  chunk });
		}
	}
}
Exemple #30
0
void ChunkManager::Render() {
	if (m_textureId != -1) {
		m_renderer->BindTextureToShader(m_textureId, 0);
	}
	m_renderer->PushMatrix();
		m_chunkMapMutex.lock();
		std::map<ChunkCoordKey, Chunk*>::iterator it;
		for (it = m_chunkMap.begin(); it != m_chunkMap.end(); ++it) {
			Chunk* chunk = it->second;
			if (chunk->IsLoaded()) {

				glm::vec3 chunkCenter = chunk->GetCenter();
				float chunkSize = Chunk::CHUNK_SIZE * Chunk::BLOCK_RENDER_SIZE;

				if (m_renderer->CubeInFrustum(chunkCenter, chunkSize, chunkSize, chunkSize)) {
					chunk->Render();
				}
			}
		}
		m_chunkMapMutex.unlock();
	m_renderer->PopMatrix();
}