private void loadMapData() {
		String mapName = new String(getMapName(), charset);
		map = new Map(getMapWidth(), getMapHeight(), mapName, getMapFileName(), getMapHash(),
				getHeightData(), getBuildableData(), getWalkableData());
		if (!enableBWTA) {
			return;
		}
		
		// get region and choke point data
		File bwtaFile = new File("mapData" + File.separator + map.getHash() + ".jbwta");
		String mapHash = map.getHash();
		File mapDir = bwtaFile.getParentFile();
		if (mapDir != null) {
			mapDir.mkdirs();
		}
		boolean analyzed = bwtaFile.exists();
		int[] regionMapData = null;
		int[] regionData = null;
		int[] chokePointData = null;
		int[] baseLocationData = null;
		HashMap<Integer, int[]> polygons = new HashMap<Integer, int[]>();
		
		// run BWTA
		if (!analyzed) {
			analyzeTerrain();
			regionMapData = getRegionMap();
			regionData = getRegions();
			chokePointData = getChokePoints();
			baseLocationData = getBaseLocations();
			for (int index = 0; index < regionData.length; index += Region.numAttributes) {
				int id = regionData[index];
				polygons.put(id, getPolygon(id));
			}
			
			// sometimes BWTA seems to crash on analyse. Make sure we are definitely in the same map
			if (!mapHash.equals(map.getHash())) {
				System.err.println("Error: Map changed during analysis! BWTA file not saved.");
				System.exit(1);
			}
			
			// store the results to a local file (bwta directory)
			try {
				BufferedWriter writer = new BufferedWriter(new FileWriter(bwtaFile));
				
				writeMapData(writer, regionMapData);
				writeMapData(writer, regionData);
				writeMapData(writer, chokePointData);
				writeMapData(writer, baseLocationData);
				for (int id : polygons.keySet()) {
					writer.write("" + id + ",");
					writeMapData(writer, polygons.get(id));
				}
				
				writer.close();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		// load from file
		else {
			try {
				BufferedReader reader = new BufferedReader(new FileReader(bwtaFile));
				
				regionMapData = readMapData(reader);
				regionData = readMapData(reader);
				chokePointData = readMapData(reader);
				baseLocationData = readMapData(reader);
				// polygons (first integer is ID)
				int[] polygonData;
				while ((polygonData = readMapData(reader)) != null) {
					int[] coordinateData = Arrays.copyOfRange(polygonData, 1, polygonData.length);
					
					polygons.put(polygonData[0], coordinateData);
				}
				
				reader.close();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		
		map.initialize(regionMapData, regionData, polygons, chokePointData, baseLocationData);
	}