Parse the line from the level.lst file, populating the levelInfo object with the info found. @param gameMode the game mode @param inputLine The line to be parsed @param lineNum The number of the line being parsed.
(GameMode gameMode, String inputLine, int lineNum, URI source, String xpTable)
| 52 | * @param lineNum The number of the line being parsed. |
| 53 | */ |
| 54 | public static String parseLine(GameMode gameMode, String inputLine, int lineNum, URI source, String xpTable) |
| 55 | { |
| 56 | if (gameMode == null) |
| 57 | { |
| 58 | return ""; |
| 59 | } |
| 60 | |
| 61 | // Deal with the start of a new XPTable definition |
| 62 | if (inputLine.startsWith("XPTABLE:")) |
| 63 | { |
| 64 | String value = inputLine.substring(8); |
| 65 | if (value.indexOf('\t') >= 0) |
| 66 | { |
| 67 | value = value.substring(0, value.indexOf('\t')); |
| 68 | } |
| 69 | value = value.trim(); |
| 70 | if (value.equals("")) |
| 71 | { |
| 72 | Logging.errorPrint("Error parsing level line \"" + inputLine + "\": empty XPTABLE value."); |
| 73 | } |
| 74 | else |
| 75 | { |
| 76 | gameMode.addXPTableName(value); |
| 77 | return value; |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | // Provide a default fallback table name for backwards compatibility |
| 82 | if (xpTable.equals("")) |
| 83 | { |
| 84 | xpTable = "Default"; |
| 85 | gameMode.addXPTableName(xpTable); |
| 86 | } |
| 87 | |
| 88 | final LevelInfo levelInfo = new LevelInfo(); |
| 89 | final StringTokenizer colToken = new StringTokenizer(inputLine, SystemLoader.TAB_DELIM); |
| 90 | |
| 91 | Map<String, LstToken> tokenMap = TokenStore.inst().getTokenMap(LevelLstToken.class); |
| 92 | while (colToken.hasMoreTokens()) |
| 93 | { |
| 94 | final String colString = colToken.nextToken().trim(); |
| 95 | |
| 96 | final int idxColon = colString.indexOf(':'); |
| 97 | String key = ""; |
| 98 | try |
| 99 | { |
| 100 | key = colString.substring(0, idxColon); |
| 101 | } |
| 102 | catch (StringIndexOutOfBoundsException e) |
| 103 | { |
| 104 | // TODO Handle Exception |
| 105 | } |
| 106 | LevelLstToken token = (LevelLstToken) tokenMap.get(key); |
| 107 | |
| 108 | if (token != null) |
| 109 | { |
| 110 | final String value = colString.substring(idxColon + 1); |
| 111 | LstUtils.deprecationCheck(token, levelInfo.getLevelString(), source, value); |