private void readMapInfo() throws MapLoadException { MapResourceInfo filePartOptional = findAndDecryptFilePartSafe(EOriginalMapFilePartType.MAP_INFO); // - file position int pos = filePartOptional.offset; // ---------------------------------- // - read mapType (single / multiplayer map?) int mapType = readBEIntFrom(pos); pos += 4; if (mapType == 1) { isSinglePlayerMap = true; } else if (mapType == 0) { isSinglePlayerMap = false; } else { throw new MapLoadException("wrong value for 'isSinglePlayerMap' " + Integer.toString(mapType) + " in mapfile!"); } // ---------------------------------- // - read Player count int playerCount = readBEIntFrom(pos); pos += 4; mapData.setPlayerCount(playerCount); // ---------------------------------- // - read start resources int startResourcesValue = readBEIntFrom(pos); this.startResources = EMapStartResources.fromMapValue(startResourcesValue); }
private void readPlayerInfo() throws MapLoadException { MapResourceInfo filePart = findAndDecryptFilePartSafe(EOriginalMapFilePartType.PLAYER_INFO); // - file position int pos = filePart.offset; for (int i = 0; i < mapData.getPlayerCount(); i++) { int nation = readBEIntFrom(pos); pos += 4; int startX = readBEIntFrom(pos); pos += 4; int startY = readBEIntFrom(pos); pos += 4; String playerName = readCStrFrom(pos, 33); pos += 33; mapData.setPlayer(i, startX, startY, nation, playerName); } }
/** * Reads in the Map Data / Landscape and MapObjects like trees */ void readMapData() throws MapLoadException { MapResourceInfo filePart = findAndDecryptFilePartSafe(EOriginalMapFilePartType.AREA); // - file position int pos = filePart.offset; // - height and width are the same int widthHeight = readBEIntFrom(pos); pos += 4; // - init size of MapData mapData.setWidthHeight(widthHeight); // - points to read int dataCount = widthHeight * widthHeight; for (int i = 0; i < dataCount; i++) { mapData.setLandscapeHeight(i, readByteFrom(pos++)); mapData.setLandscape(i, readByteFrom(pos++)); mapData.setMapObject(i, readByteFrom(pos++)); readByteFrom(pos++); // - which Player is the owner of this position mapData.setAccessible(i, mapContent[pos++]); mapData.setResources(i, readHighNibbleFrom(pos), readLowNibbleFrom(pos)); pos++; } }