@Override public MapFileHeader getFileHeader() { if (isMapOK) { return new MapFileHeader( MapFileHeader.MapType.NORMAL, getMapName(), getMapId(), getDescription(), (short) mapContent.widthHeight, (short) mapContent.widthHeight, (short) getMinPlayers(), (short) getMaxPlayers(), getCreationDate(), getImage()); } return null; }
@Override public MainGridWithUiSettings loadMainGrid(PlayerSetting[] playerSettings) throws MapLoadException { return loadMainGrid(playerSettings, EMapStartResources.HIGH_GOODS); }
@Override public MainGridWithUiSettings loadMainGrid(PlayerSetting[] playerSettings, EMapStartResources startResources) throws MapLoadException { MilliStopWatch watch = new MilliStopWatch(); loadMapContent(startResources, playerSettings); OriginalMapFileContent mapData = mapContent.mapData; mapData.calculateBlockedPartitions(); watch.stop("Loading original map data required"); byte numberOfPlayers = (byte) getMaxPlayers(); if (playerSettings == null || CommonConstants.ACTIVATE_ALL_PLAYERS) { playerSettings = new PlayerSetting[numberOfPlayers]; for (int i = 0; i < numberOfPlayers; i++) { playerSettings[i] = new PlayerSetting((byte) i); } } MainGrid mainGrid = new MainGrid(getMapId(), getMapName(), mapData, playerSettings); PlayerState[] playerStates = new PlayerState[numberOfPlayers]; for (byte playerId = 0; playerId < numberOfPlayers; playerId++) { playerStates[playerId] = new PlayerState(playerId, new UIState(mapData.getStartPoint(playerId))); } return new MainGridWithUiSettings(mainGrid, playerStates); }
@Override public String getMapId() { return mapContent.getChecksum() + getMapName(); }
public OriginalMapLoader(IListedMap listedMap) throws MapLoadException { this.listedMap = listedMap; fileName = listedMap.getFileName(); creationDate = getCreationDateFrom(listedMap); try { mapContent = new OriginalMapFileContentReader(listedMap.getInputStream()); } catch (IOException e) { throw new MapLoadException(e); } if (!CommonConstants.DISABLE_ORIGINAL_MAPS_CHECKSUM && !mapContent.isChecksumValid()) { throw new MapLoadException("Checksum of original map (" + fileName + ") is not valid!"); } // - read all important information from file mapContent.loadMapResources(); mapContent.readBasicMapInformation(MapFileHeader.PREVIEW_IMAGE_SIZE, MapFileHeader.PREVIEW_IMAGE_SIZE); // - free the DataBuffer mapContent.freeBuffer(); isMapOK = true; }
public static MapLoader getLoaderForListedMap(IListedMap listedMap) throws MapLoadException { if ((checkExtention(listedMap.getFileName(), MapLoader.MAP_EXTENSION_ORIGINAL)) || (checkExtention(listedMap.getFileName(), MapLoader.MAP_EXTENSION_ORIGINAL_MAP_EDITOR))) { // - original Siedler 3 Map return new OriginalMapLoader(listedMap); } else { // - Siedler 3 Remake Savegame or Map MapFileHeader header = RemakeMapLoader.loadHeader(listedMap); switch (header.getType()) { case NORMAL: return new FreshMapLoader(listedMap, header); case SAVED_SINGLE: return new SavegameLoader(listedMap, header); default: throw new MapLoadException("Unkown EMapType: " + header.getType()); } } }