bool VMapManager::_loadMap(const char* pBasePath, unsigned int pMapId, int x, int y, bool pForceTileLoad) { bool result = false; std::string dirFileName; if(pForceTileLoad || iMapsSplitIntoTiles.containsKey(pMapId)) { dirFileName = getDirFileName(pMapId,x,y); } else { dirFileName = getDirFileName(pMapId); } MapTree* instanceTree; if(!iInstanceMapTrees.containsKey(pMapId)) { instanceTree = new MapTree(pBasePath); iInstanceMapTrees.set(pMapId, instanceTree); } else instanceTree = iInstanceMapTrees.get(pMapId); unsigned int mapTileIdent = MAP_TILE_IDENT(x,y); result = instanceTree->loadMap(dirFileName, mapTileIdent); if(!result) // remove on fail { if(instanceTree->size() == 0) { iInstanceMapTrees.remove(pMapId); delete instanceTree; } } return(result); }
int VMapManager::loadMap(const char* pBasePath, unsigned int pMapId, int x, int y) { bool result = false; std::string dirFileName; if( pMapId >= MAX_MAPS ) return false; if( IsTileMap( pMapId ) ) dirFileName = getDirFileName( pMapId, x, y ); else dirFileName = getDirFileName( pMapId ); MapTree* instanceTree = m_maps[pMapId]; if( instanceTree == NULL ) { instanceTree = new MapTree( pBasePath ); m_maps[pMapId] = instanceTree; } unsigned int mapTileIdent = MAP_TILE_IDENT(x,y); result = instanceTree->loadMap(dirFileName, mapTileIdent); if(!result) // remove on fail { if(instanceTree->size() == 0) { m_maps[pMapId] = NULL; delete instanceTree; } } return(result); }
void VMapManager::unloadMap(unsigned int pMapId, int x, int y) { if( m_maps[pMapId] != NULL ) { MapTree * instanceTree = m_maps[pMapId]; std::string dirFileName; if( IsTileMap( pMapId ) ) dirFileName = getDirFileName( pMapId, x, y ); else dirFileName = getDirFileName( pMapId ); unsigned int mapTileIdent = MAP_TILE_IDENT(x,y); instanceTree->unloadMap(dirFileName, mapTileIdent); if(instanceTree->size() == 0) { m_maps[ pMapId ] = NULL; delete instanceTree; } } }
void VMapManager::_unloadMap(unsigned int pMapId, int x, int y) { if(iInstanceMapTrees.containsKey(pMapId)) { MapTree* instanceTree = iInstanceMapTrees.get(pMapId); std::string dirFileName; if(iMapsSplitIntoTiles.containsKey(pMapId)) { dirFileName = getDirFileName(pMapId,x,y); } else { dirFileName = getDirFileName(pMapId); } unsigned int mapTileIdent = MAP_TILE_IDENT(x,y); instanceTree->unloadMap(dirFileName, mapTileIdent); if(instanceTree->size() == 0) { iInstanceMapTrees.remove(pMapId); delete instanceTree; } } }