// // ReadAllLumps // // Returns number of entries read. // static int ReadAllLumps(void) { lump_t *cur, *L; int count = 0; for (cur=wad.dir_head; cur; cur=cur->next) { count++; if (cur->flags & LUMP_READ_ME) ReadLumpData(cur); if (cur->lev_info && ! (cur->lev_info->flags & LEVEL_IS_GL)) { for (L=cur->lev_info->children; L; L=L->next) { count++; if (L->flags & LUMP_READ_ME) ReadLumpData(L); } } } return count; }
CBspFile::CBspFile(Framework::CStream& inputStream) { uint8 signature[4]; inputStream.Read(signature, 4); if(memcmp(signature, "IBSP", 4)) { throw std::runtime_error("Invalid BSP. Bad signature."); } uint32 version = inputStream.Read32(); assert(version == 0x2E); DIRENTRY dirEntries[DIRENTRY_COUNT]; for(unsigned int i = 0; i < DIRENTRY_COUNT; i++) { dirEntries[i].offset = inputStream.Read32(); dirEntries[i].length = inputStream.Read32(); } ReadLumpData(inputStream, dirEntries[LUMP_ENTITIES], m_entities); ReadLumpData(inputStream, dirEntries[LUMP_PLANES], m_planes); ReadLumpData(inputStream, dirEntries[LUMP_NODES], m_nodes); ReadLumpData(inputStream, dirEntries[LUMP_LEAVES], m_leaves); ReadLumpData(inputStream, dirEntries[LUMP_LEAFFACES], m_leafFaces); ReadLumpData(inputStream, dirEntries[LUMP_TEXTURES], m_textures); ReadLumpData(inputStream, dirEntries[LUMP_VERTICES], m_vertices); ReadLumpData(inputStream, dirEntries[LUMP_MESHVERTICES], m_meshVertices); ReadLumpData(inputStream, dirEntries[LUMP_EFFECTS], m_effects); ReadLumpData(inputStream, dirEntries[LUMP_FACES], m_faces); ReadLumpData(inputStream, dirEntries[LUMP_LIGHTMAPS], m_lightMaps); //Read VISDATA { inputStream.Seek(dirEntries[LUMP_VISDATA].offset, Framework::STREAM_SEEK_SET); m_visData.vectorCount = inputStream.Read32(); m_visData.vectorSize = inputStream.Read32(); uint32 visDataSize = m_visData.vectorCount * m_visData.vectorSize; m_visData.vectors.resize(visDataSize); inputStream.Read(&m_visData.vectors[0], visDataSize); } }