@Override public MainGridWithUiSettings loadMainGrid(PlayerSetting[] playerSettings, EMapStartResources startResources) throws MapLoadException { try (ObjectInputStream ois = new ObjectInputStream(super.getMapDataStream())) { MatchConstants.deserialize(ois); PlayerState[] playerStates = (PlayerState[]) ois.readObject(); GameSerializer gameSerializer = new GameSerializer(); MainGrid mainGrid = gameSerializer.load(ois); mainGrid.initWithPlayerSettings(playerSettings); RescheduleTimer.loadFrom(ois); ois.close(); return new MainGridWithUiSettings(mainGrid, playerStates); } catch (IOException | ClassNotFoundException ex) { throw new MapLoadException(ex); } }
@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 MainGridWithUiSettings loadMainGrid(PlayerSetting[] playerSettings, EMapStartResources startResources) throws MapLoadException { MilliStopWatch watch = new MilliStopWatch(); IMapData mapData = getMapData(); watch.stop("Loading 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); }