diff --git a/packages/lib/src/factorio/exchange_string.ts b/packages/lib/src/factorio/exchange_string.ts index 3749fd6a..38d2a36a 100644 --- a/packages/lib/src/factorio/exchange_string.ts +++ b/packages/lib/src/factorio/exchange_string.ts @@ -239,7 +239,9 @@ function readPollution(state: MapReaderState) { pollution_with_max_forest_damage: readOptional(state, readDouble), pollution_per_tree_damage: readOptional(state, readDouble), pollution_restored_per_tree_damage: readOptional(state, readDouble), - max_pollution_to_restore_trees: readOptional(state, readDouble), + ...state.versionAtLeast(2, 1, 18) ? {} : { + max_pollution_to_restore_trees: readOptional(state, readDouble), // removed v2.1.18 + }, enemy_attack_pollution_consumption_modifier: readOptional(state, readDouble), }; } diff --git a/test/integration/clusterio.js b/test/integration/clusterio.js index 8508482f..08ee24b7 100644 --- a/test/integration/clusterio.js +++ b/test/integration/clusterio.js @@ -1289,8 +1289,11 @@ describe("Integration of Clusterio", function() { const isV2 = version > lib.integerPartialVersion("2.0"); const isV2_1 = version > lib.integerPartialVersion("2.1"); const isV2_1_13 = version >= lib.integerPartialVersion("2.1.13"); + const isV2_1_18 = version >= lib.integerPartialVersion("2.1.18"); let exchangeString = testStrings.modified; - if (isV2_1_13) { + if (isV2_1_18) { + exchangeString = testStrings.modified_v2_1_18; + } else if (isV2_1_13) { exchangeString = testStrings.modified_v2_1_13; } else if (isV2_1) { exchangeString = testStrings.modified_v2_1; diff --git a/test/lib/factorio/exchange_string.js b/test/lib/factorio/exchange_string.js index 9ea118dc..fda40834 100644 --- a/test/lib/factorio/exchange_string.js +++ b/test/lib/factorio/exchange_string.js @@ -78,6 +78,26 @@ describe("lib/factorio/exchange_string", function() { }); }); + it("should parse v2.1.17 strings", function() { + assert.deepEqual(lib.readMapExchangeString(testStrings.modified_v2_1_17), { + version: [2, 1, 17, 0], + unknown: 0, + map_gen_settings: testSettings.modified_v2_1_map_gen_settings, + map_settings: testSettings.modified_v2_1_13_map_settings, + checksum: 1073352633, + }); + }); + + it("should parse post v2.1.18 strings", function() { + assert.deepEqual(lib.readMapExchangeString(testStrings.modified_v2_1_18), { + version: [2, 1, 18, 4], + unknown: 0, + map_gen_settings: testSettings.modified_v2_1_map_gen_settings, + map_settings: testSettings.modified_v2_1_18_map_settings, + checksum: 1437579271, + }); + }); + it("should handle malformed strings", function() { assert.throws( () => lib.readMapExchangeString("<>"), diff --git a/test/lib/factorio/test_settings.js b/test/lib/factorio/test_settings.js index c1d397f4..b902e90d 100644 --- a/test/lib/factorio/test_settings.js +++ b/test/lib/factorio/test_settings.js @@ -622,6 +622,14 @@ export const modified_v2_1_13_map_settings = { }, }; +export const modified_v2_1_18_map_settings = { + ...modified_v2_1_13_map_settings, + "pollution": Object.fromEntries( + Object.entries(modified_v2_1_13_map_settings.pollution) + .filter(([key]) => key !== "max_pollution_to_restore_trees") + ), +}; + export const modified_space_age_map_gen_settings = { autoplace_controls: { "aquilo_crude_oil": { frequency: 1, size: 1, richness: 1 }, diff --git a/test/lib/factorio/test_strings.js b/test/lib/factorio/test_strings.js index 331993e9..36fa5116 100644 --- a/test/lib/factorio/test_strings.js +++ b/test/lib/factorio/test_strings.js @@ -100,3 +100,35 @@ JYkZpmFakZGd1AkjtxhSQjYziizPKvHmmTPmUDWuYoiVKOgP57RB9yS 0Dvo1NMEfJJWw1i+YLmuywM1C1jwbPKaGnjffEMETl1yE9Qxu/9C7rp u3nVP+RQebGLpzeY4SxwbkUKGDDtjU/J9P3/nrIfNHXdPAWgFF7JHkZ 0L+YLmXPjcc3XoAz1D69BVjk1sULxb83nuUA<<<`; + +export const modified_v2_1_17 = ` +>>>eNp1U89rE0EUftMmNYnVRoiCIjWHHkRICNFTkezoRTx4ELxKnGwm +unS7087uVqsHc/DgQRCkF73o1YpexIO3gBd7k/oPVOrB3lopUkSI8zI +7kzXBB+/x7fd+v2EngMAxUDKdcQXzAbqO0YIrlpa4rAjJld/SeVfGbV +4Rnp9iaYEHfHG10mIhBlOA3sCV86QIdIWerTAdsHjFC5uu73U66Y5ZK +dyFMM2cCCMmIy+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