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); }