// parse information, // should throw exception on error? // (cannot continue where expected to..) bool XpkTags::ParseChunks(CIOBuffer *pBuffer) { Clear(); // should make new instance of this instead.. // read&parse file header if (ReadStreamHeader(*pBuffer) == false) { return false; } // read chunks from file ReadChunks(*pBuffer); return true; }
void cLightingThread::LightChunk(cLightingChunkStay & a_Item) { cChunkDef::BlockNibbles BlockLight, SkyLight; ReadChunks(a_Item.m_ChunkX, a_Item.m_ChunkZ); PrepareBlockLight(); CalcLight(m_BlockLight); PrepareSkyLight(); /* // DEBUG: Save chunk data with highlighted seeds for visual inspection: cFile f4; if ( f4.Open(Printf("Chunk_%d_%d_seeds.grab", a_Item.x, a_Item.z), cFile::fmWrite) ) { for (int z = 0; z < cChunkDef::Width * 3; z++) { for (int y = cChunkDef::Height / 2; y >= 0; y--) { unsigned char Seeds [cChunkDef::Width * 3]; memcpy(Seeds, m_BlockTypes + y * BlocksPerYLayer + z * cChunkDef::Width * 3, cChunkDef::Width * 3); for (int x = 0; x < cChunkDef::Width * 3; x++) { if (m_IsSeed1[y * BlocksPerYLayer + z * cChunkDef::Width * 3 + x]) { Seeds[x] = E_BLOCK_DIAMOND_BLOCK; } } f4.Write(Seeds, cChunkDef::Width * 3); } } } //*/ CalcLight(m_SkyLight); /* // DEBUG: Save XY slices of the chunk data and lighting for visual inspection: cFile f1, f2, f3; if ( f1.Open(Printf("Chunk_%d_%d_data.grab", a_Item.x, a_Item.z), cFile::fmWrite) && f2.Open(Printf("Chunk_%d_%d_sky.grab", a_Item.x, a_Item.z), cFile::fmWrite) && f3.Open(Printf("Chunk_%d_%d_glow.grab", a_Item.x, a_Item.z), cFile::fmWrite) ) { for (int z = 0; z < cChunkDef::Width * 3; z++) { for (int y = cChunkDef::Height / 2; y >= 0; y--) { f1.Write(m_BlockTypes + y * BlocksPerYLayer + z * cChunkDef::Width * 3, cChunkDef::Width * 3); unsigned char SkyLight [cChunkDef::Width * 3]; unsigned char BlockLight[cChunkDef::Width * 3]; for (int x = 0; x < cChunkDef::Width * 3; x++) { SkyLight[x] = m_SkyLight [y * BlocksPerYLayer + z * cChunkDef::Width * 3 + x] << 4; BlockLight[x] = m_BlockLight[y * BlocksPerYLayer + z * cChunkDef::Width * 3 + x] << 4; } f2.Write(SkyLight, cChunkDef::Width * 3); f3.Write(BlockLight, cChunkDef::Width * 3); } } } //*/ CompressLight(m_BlockLight, BlockLight); CompressLight(m_SkyLight, SkyLight); m_World->ChunkLighted(a_Item.m_ChunkX, a_Item.m_ChunkZ, BlockLight, SkyLight); if (a_Item.m_CallbackAfter != NULL) { a_Item.m_CallbackAfter->Call(a_Item.m_ChunkX, a_Item.m_ChunkZ); } a_Item.Disable(); delete &a_Item; }