void Resource::unload() { if (_loadCounter == 1) _unload(); _loadCounter = _useLoadCounter ? _loadCounter - 1 : 0; }
void libaacs_unload(BD_AACS **p) { if (p && *p) { _unload(*p); X_FREE(*p); } }
bool Model::open() { CASCFile f(CascStorage, filename.c_str()); if (f.isEof()) { f.close(); // Do not show this error on console to avoid confusion, the extractor can continue working even if some models fail to load //printf("Error loading model %s\n", filename.c_str()); return false; } _unload(); uint32 m2start = 0; char const* ptr = f.getBuffer(); while (m2start + 4 < f.getSize() && *reinterpret_cast<uint32 const*>(ptr) != '02DM') { ++m2start; ++ptr; if (m2start + sizeof(ModelHeader) > f.getSize()) return false; } memcpy(&header, f.getBuffer() + m2start, sizeof(ModelHeader)); if (header.nBoundingTriangles > 0) { f.seek(m2start); f.seekRelative(header.ofsBoundingVertices); vertices = new Vec3D[header.nBoundingVertices]; f.read(vertices,header.nBoundingVertices*12); for (uint32 i=0; i<header.nBoundingVertices; i++) vertices[i] = fixCoordSystem(vertices[i]); f.seek(m2start); f.seekRelative(header.ofsBoundingTriangles); indices = new uint16[header.nBoundingTriangles]; f.read(indices,header.nBoundingTriangles*2); f.close(); } else { //printf("not included %s\n", filename.c_str()); f.close(); return false; } return true; }
//----------------------------------------------------------------------- void PagingLandScapeData2D::unload() { if (mIsLoaded) { if (mIsModified) _save (); delete[] mHeightData; mHeightData = 0; _unload(); mIsLoaded = false; mIsModified = false; mIsRectModified = false; #ifndef _MAPSPLITTER resetDeformationRectangle (); #endif } }
bool Model::open(StringSet& failedPaths) { MPQFile f(filename.c_str()); ok = !f.isEof(); if (!ok) { f.close(); failedPaths.insert(filename); return false; } _unload(); memcpy(&header, f.getBuffer(), sizeof(ModelHeader)); if (header.nBoundingTriangles > 0) { boundingVertices = (ModelBoundingVertex*)(f.getBuffer() + header.ofsBoundingVertices); vertices = new Vec3D[header.nBoundingVertices]; for (size_t i = 0; i < header.nBoundingVertices; i++) { vertices[i] = fixCoordSystem(boundingVertices[i].pos); } uint16* triangles = (uint16*)(f.getBuffer() + header.ofsBoundingTriangles); nIndices = header.nBoundingTriangles; // refers to the number of int16's, not the number of triangles indices = new uint16[nIndices]; memcpy(indices, triangles, nIndices * 2); f.close(); } else { //printf("not included %s\n", filename.c_str()); f.close(); return false; } return true; }
bool Model::open() { MPQFile f(WorldMpq, filename.c_str()); ok = !f.isEof(); if (!ok) { f.close(); // Do not show this error on console to avoid confusion, the extractor can continue working even if some models fail to load //printf("Error loading model %s\n", filename.c_str()); return false; } _unload(); memcpy(&header, f.getBuffer(), sizeof(ModelHeader)); if (header.nBoundingTriangles > 0) { f.seek(0); f.seekRelative(header.ofsBoundingVertices); vertices = new Vec3D[header.nBoundingVertices]; f.read(vertices, header.nBoundingVertices * 12); for (uint32 i = 0; i < header.nBoundingVertices; i++) { vertices[i] = fixCoordSystem(vertices[i]); } f.seek(0); f.seekRelative(header.ofsBoundingTriangles); indices = new uint16[header.nBoundingTriangles]; f.read(indices, header.nBoundingTriangles * 2); f.close(); } else { //printf("not included %s\n", filename.c_str()); f.close(); return false; } return true; }
bool Model::open(StringSet& failedPaths) { MPQFile f(filename.c_str()); ok = !f.isEof(); if (!ok) { f.close(); failedPaths.insert(filename); return false; } _unload(); memcpy(&header, f.getBuffer(), sizeof(ModelHeader)); if (header.nBoundingTriangles > 0) { f.seek(0); f.seekRelative(header.ofsBoundingVertices); vertices = new Vec3D[header.nBoundingVertices]; f.read(vertices, header.nBoundingVertices * 12); for (uint32 i = 0; i < header.nBoundingVertices; i++) { vertices[i] = fixCoordSystem(vertices[i]); } f.seek(0); f.seekRelative(header.ofsBoundingTriangles); indices = new uint16[header.nBoundingTriangles]; f.read(indices, header.nBoundingTriangles * 2); f.close(); } else { //printf("not included %s\n", filename.c_str()); f.close(); return false; } return true; }
Font::~Font() { _unload(); }
bool Font::read(std::fstream * fileStream) { _unload(); return _read(fileStream); }
//----------------------------------------------------------------------- TextureUnitState::~TextureUnitState() { // Unload ensure all controllers destroyed _unload(); }
MDX_M2_file::~MDX_M2_file() { _unload(); free(); }
bool Model::open(StringSet& failedPaths, int iCoreNumber) { MPQFile f(filename.c_str()); ok = !f.isEof(); if (!ok) { f.close(); failedPaths.insert(filename); return false; } _unload(); bool bBoundingTriangles = false; uint32 uofsBoundingVertices = 0; uint32 uofsBoundingTriangles = 0; uint32 unBoundingVertices = 0; uint32 unBoundingTriangles = 0; if (iCoreNumber == CLIENT_CLASSIC || iCoreNumber == CLIENT_TBC) { memcpy(&headerClassicTBC, f.getBuffer(), sizeof(ModelHeaderClassicTBC)); if (headerClassicTBC.nBoundingTriangles > 0) { bBoundingTriangles = true; uofsBoundingVertices = headerClassicTBC.ofsBoundingVertices; uofsBoundingTriangles = headerClassicTBC.ofsBoundingTriangles; unBoundingVertices = headerClassicTBC.nBoundingVertices; unBoundingTriangles = headerClassicTBC.nBoundingTriangles; } } if (iCoreNumber == CLIENT_WOTLK || iCoreNumber == CLIENT_CATA) { memcpy(&headerOthers, f.getBuffer(), sizeof(ModelHeaderOthers)); if (headerOthers.nBoundingTriangles > 0) { bBoundingTriangles = true; uofsBoundingVertices = headerOthers.ofsBoundingVertices; uofsBoundingTriangles = headerOthers.ofsBoundingTriangles; unBoundingVertices = headerOthers.nBoundingVertices; unBoundingTriangles = headerOthers.nBoundingTriangles; } } if (bBoundingTriangles) { boundingVertices = (ModelBoundingVertex*)(f.getBuffer() + uofsBoundingVertices); vertices = new Vec3D[unBoundingVertices]; for (size_t i = 0; i < unBoundingVertices; i++) { vertices[i] = boundingVertices[i].pos; } uint16* triangles = (uint16*)(f.getBuffer() + uofsBoundingTriangles); nIndices = unBoundingTriangles; // refers to the number of int16's, not the number of triangles indices = new uint16[nIndices]; memcpy(indices, triangles, nIndices * 2); f.close(); } else { //printf("not included %s\n", filename.c_str()); f.close(); return false; } return true; }
void GroundEyeshot::save(xs::DataChunk *pDataChunk) { xs::Stream *pDataStream = 0; HASH_MAP_NAMESPACE::hash_map<std::string,int> mTextures; std::vector<std::string> vTextures; pDataChunk->beginChunk('MTEX',&pDataStream); for(int i = 0;i < m_nTotalGridX;i++) for(int j = 0;j < m_nTotalGridY;j++) { GroundTile *pTile = static_cast<GroundTile*>(getGroundTile(i,j)); uint layerNum = pTile->getTextureLayerNum(); for(uint k = 0;k < layerNum;k++) { std::string textureFileName = pTile->getTextureFileName(k); if(mTextures.find(textureFileName) != mTextures.end()) { } else { vTextures.push_back(textureFileName); mTextures[textureFileName] = vTextures.size() - 1; } } } size_t texNum = vTextures.size(); for(size_t size = 0;size < texNum;size++) { pDataStream->write(vTextures[size].c_str(),vTextures[size].length() + 1); } pDataChunk->endChunk(); xs::DataChunk::stChunk *pTextureIdxChunk = pDataChunk->beginChunk('MTID',&pDataStream); for(int i = 0;i < m_nTotalGridX;i++) for(int j = 0;j < m_nTotalGridY;j++) { uint offset = 0; pDataStream->write(&offset,sizeof(offset)); } pDataChunk->endChunk(); uint *pTextureOffsets = (uint*)pTextureIdxChunk->m_pData; bool bFirstTime = true; uint offset = 0; for(int i = 0;i < m_nTotalGridX;i++) for(int j = 0;j < m_nTotalGridY;j++) { pDataChunk->beginChunk('MTIL',&pDataStream); if(bFirstTime) { offset = pTextureOffsets[j * m_nTotalGridX + i] = pDataChunk->getOffset(); bFirstTime = false; } else { pTextureOffsets[j * m_nTotalGridX + i] = offset; } GroundTile *pTile = static_cast<GroundTile*>(getGroundTile(i,j)); bool bLoaded = pTile->isLoaded(); if(!bLoaded)_load(i,j); pTile->save(pDataStream,mTextures); if(!bLoaded)_unload(i,j); offset += pDataStream->getLength(); offset += CHUNK_MIN_SIZE; pDataChunk->endChunk(); } // 记录远景贴图; if (!m_strDistanceTextureFileName.empty()) { // 这里自定义了一个Chunk名称'MDIS',本来想参考一下其他Chunk名称的定义和使用,但是现有代码中只搜索 // 到了对Chunk名称的使用, 而没有找到定义的地方,因此不排除'MDIS'已经被使用了的可能,这个需要在以 // 后的开发和整理过程中留意; // 2009-06-17; pDataChunk->beginChunk('MDIS',&pDataStream); BYTE cbFileName = (BYTE)(m_strDistanceTextureFileName.length()); pDataStream->write(&cbFileName, sizeof(BYTE)); pDataStream->write(m_strDistanceTextureFileName.c_str(), cbFileName); pDataChunk->endChunk(); } }
int libaacs_open(BD_AACS *p, const char *device, void *file_open_handle, void *file_open_fp, const char *keyfile_path) { int error_code = 0; fptr_p_void open; fptr_p_void open2; fptr_p_void init; fptr_int open_device; fptr_int aacs_get_mkb_version; fptr_p_void aacs_get_disc_id; _libaacs_close(p); *(void **)(&open) = dl_dlsym(p->h_libaacs, "aacs_open"); *(void **)(&open2) = dl_dlsym(p->h_libaacs, "aacs_open2"); *(void **)(&init) = dl_dlsym(p->h_libaacs, "aacs_init"); *(void **)(&aacs_get_mkb_version) = dl_dlsym(p->h_libaacs, "aacs_get_mkb_version"); *(void **)(&aacs_get_disc_id) = dl_dlsym(p->h_libaacs, "aacs_get_disc_id"); *(void **)(&open_device) = dl_dlsym(p->h_libaacs, "aacs_open_device"); if (init && open_device) { p->aacs = init(); DL_CALL(p->h_libaacs, aacs_set_fopen, p->aacs, file_open_handle, file_open_fp); error_code = open_device(p->aacs, device, keyfile_path); } else if (open2) { BD_DEBUG(DBG_BLURAY, "Using old aacs_open2(), no UDF support available\n"); p->aacs = open2(device, keyfile_path, &error_code); /* libmmbd needs dev: for devices */ if (!p->aacs && p->impl_id == IMPL_LIBMMBD && !strncmp(device, "/dev/", 5)) { char *tmp_device = str_printf("dev:%s", device); if (tmp_device) { p->aacs = open2(tmp_device, keyfile_path, &error_code); X_FREE(tmp_device); } } } else if (open) { BD_DEBUG(DBG_BLURAY, "Using old aacs_open(), no verbose error reporting available\n"); p->aacs = open(device, keyfile_path); } else { BD_DEBUG(DBG_BLURAY, "aacs_open() not found\n"); } if (error_code) { /* failed. try next aacs implementation if available. */ BD_AACS *p2 = _load(p->impl_id + 1); if (p2) { if (!libaacs_open(p2, device, file_open_handle, file_open_fp, keyfile_path)) { /* succeed - swap implementations */ _unload(p); *p = *p2; X_FREE(p2); return 0; } /* failed - report original errors */ libaacs_unload(&p2); } } if (p->aacs) { if (aacs_get_mkb_version) { p->mkbv = aacs_get_mkb_version(p->aacs); } if (aacs_get_disc_id) { p->disc_id = (const uint8_t *)aacs_get_disc_id(p->aacs); } return error_code; } return error_code ? error_code : 1; }