From dcb493e90507dc200391eef87952ecbea1a3b756 Mon Sep 17 00:00:00 2001 From: James Panther <4462786+jpanther@users.noreply.github.com> Date: Wed, 6 Mar 2019 17:05:45 +1100 Subject: [PATCH] Prevent Yuoki Industries icons from causing a desync - Fixes #82 --- changelog.txt | 5 +++++ config.lua | 2 ++ control.lua | 10 ++++++---- info.json | 2 +- prototypes/entity/signs-icons.lua | 4 ++-- prototypes/third-party/alien-biomes.lua | 2 +- prototypes/third-party/config.lua | 17 +++++++++++++++-- 7 files changed, 32 insertions(+), 10 deletions(-) diff --git a/changelog.txt b/changelog.txt index 8226c17..7ab5d2f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,9 @@ --------------------------------------------------------------------------------------------------- +Version: 0.9.4 +Date: 06. 03. 2019 + Added: + - Detection of Yuoki Industries modded items to prevent multiplayer desync when placing signs +--------------------------------------------------------------------------------------------------- Version: 0.9.3 Date: 05. 03. 2019 Added: diff --git a/config.lua b/config.lua index 085dd0f..6edb168 100644 --- a/config.lua +++ b/config.lua @@ -137,6 +137,8 @@ DECT.CONFIG.BASE_TILES = {"dry-dirt", "dirt-1", "dirt-2", "dirt-3", "dirt-4", "d DECT.CONFIG.BASE_WATER_TILES = {"water", "deepwater", "water-green", "deepwater-green"} DECT.CONFIG.BASE_TREES = {"tree-01", "tree-02", "tree-03", "tree-04", "tree-05", "tree-06", "tree-07", "tree-08", "tree-09", "dead-dry-hairy-tree", "dead-grey-trunk", "dead-tree-desert", "dry-hairy-tree", "dry-tree"} DECT.CONFIG.BASE_ROCKS = {"rock-huge", "rock-big", "sand-rock-big"} +DECT.CONFIG.SIGN_CATEGORIES = {"item", "fluid", "tool", "ammo", "armor", "capsule", "gun", "module"} +DECT.CONFIG.SIGN_BLACKLIST = {"barrel", "loader", "simple%-entity", "player%-port", "computer", "coin", "small%-plane", "railgun", "vehicle%-machine%-gun", "tank%-machine%-gun", "factory%-1%-", "factory%-2%-", "factory%-3%-", "signpost", "dect%-signal%-", "infinity%-chest", "infinity%-pipe", "heat%-interface", "pollution", "escape%-pod%-power", "dummy%-steel%-axe", "atlas", "dect%-sign", "dect%-base"} DECT.CONFIG.ALIEN_BIOMES = { "mineral-purple-dirt-1", "mineral-purple-dirt-2", "mineral-purple-dirt-3", "mineral-purple-dirt-4", "mineral-purple-dirt-5", "mineral-purple-dirt-6", "mineral-purple-sand-1", "mineral-purple-sand-2", "mineral-purple-sand-3", "mineral-violet-dirt-1", "mineral-violet-dirt-2", "mineral-violet-dirt-3", "mineral-violet-dirt-4", "mineral-violet-dirt-5", "mineral-violet-dirt-6", "mineral-violet-sand-1", "mineral-violet-sand-2", "mineral-violet-sand-3", diff --git a/control.lua b/control.lua index 8ca9679..508015e 100644 --- a/control.lua +++ b/control.lua @@ -57,7 +57,8 @@ local function init_icons() for _, prototype in pairs(game.entity_prototypes) do if prototype.type == "simple-entity" then if prototype.name:find("dect%-icon") then - table.insert(icons, {name=prototype.name, type=prototype.order}) + local orig_prototype = prototype.name:gsub("dect%-icon%-", "") + table.insert(icons, {name=prototype.name, type=prototype.order, prototype=orig_prototype}) end end end @@ -237,7 +238,6 @@ local function create_sign_gui(player) global.sign_gui[player.index] = player.gui.left.add({type="frame", name="dect-gui-sign", caption={"dect-gui.sign-title"}, direction="vertical"}) local gui_scroll = global.sign_gui[player.index].add({type="scroll-pane", name="dect-gui-scroll", vertical_scroll_policy="auto", horizontal_scroll_policy="never"}) local gui_table = gui_scroll.add({type="table", name="dect-icons-table", column_count=8, style="dect-icon-table"}) - local gui_cancel = global.sign_gui[player.index].add({type="button", name="dect-gui-button-cancel", caption={"dect-gui.sign-cancel"}, style="red_button"}) for _, icon in pairs(global.icons) do local match = false for _, child in pairs(gui_table.children_names) do @@ -246,10 +246,12 @@ local function create_sign_gui(player) end end if not match then - local prototype = icon.name:gsub("dect%-icon%-", "") - gui_table.add({type="sprite-button", name=icon.name, sprite="entity/"..icon.name, style="dect-icon-button", tooltip={"", prototype}}) + if player.gui.is_valid_sprite_path("entity/"..icon.name) then + gui_table.add({type="sprite-button", name=icon.name, sprite="entity/"..icon.name, style="dect-icon-button", tooltip={"", icon.prototype}}) + end end end + local gui_cancel = global.sign_gui[player.index].add({type="button", name="dect-gui-button-cancel", caption={"dect-gui.sign-cancel"}, style="red_button"}) end -- Destroy the sign GUI diff --git a/info.json b/info.json index de8fac0..6d18805 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "name": "Dectorio", - "version": "0.9.3", + "version": "0.9.4", "title": "Dectorio", "author": "PantherX", "contact": "", diff --git a/prototypes/entity/signs-icons.lua b/prototypes/entity/signs-icons.lua index 7aaea7a..c3e6326 100644 --- a/prototypes/entity/signs-icons.lua +++ b/prototypes/entity/signs-icons.lua @@ -2,8 +2,8 @@ if DECT.ENABLED["signs"] then - local categories = {"item", "fluid", "tool", "ammo", "armor", "capsule", "gun", "mining-tool", "module"} - local blacklist = {"barrel", "loader", "simple%-entity", "player%-port", "computer", "coin", "small%-plane", "railgun", "vehicle%-machine%-gun", "tank%-machine%-gun", "factory%-1%-", "factory%-2%-", "factory%-3%-", "signpost", "dect%-signal%-", "infinity%-chest", "infinity%-pipe", "heat%-interface", "pollution", "escape%-pod%-power", "dummy%-steel%-axe"} + local categories = DECT.CONFIG.SIGN_CATEGORIES + local blacklist = DECT.CONFIG.SIGN_BLACKLIST for _, cat in pairs(categories) do if data.raw[cat] then diff --git a/prototypes/third-party/alien-biomes.lua b/prototypes/third-party/alien-biomes.lua index c18b37a..64aa6ab 100644 --- a/prototypes/third-party/alien-biomes.lua +++ b/prototypes/third-party/alien-biomes.lua @@ -1,6 +1,6 @@ -- third-party/alien-biomes -if DECT.ENABLED["landscaping"] and settings.startup["alien-biomes-terrain-scale"] then +if DECT.ENABLED["landscaping"] and mods["alien-biomes"] then local alien_biomes = DECT.CONFIG.ALIEN_BIOMES diff --git a/prototypes/third-party/config.lua b/prototypes/third-party/config.lua index 85241fd..fc30bc7 100644 --- a/prototypes/third-party/config.lua +++ b/prototypes/third-party/config.lua @@ -1,6 +1,19 @@ -- third-party/config --- Config changes for Alien Biomes -if settings.startup["alien-biomes-terrain-scale"] then +-- Alien Biomes +if mods["alien-biomes"] then + -- Only supports blue water tiles DECT.CONFIG.BASE_WATER_TILES = {"water", "deepwater"} + -- Remove the tile icons from signs + table.insert(DECT.CONFIG.SIGN_BLACKLIST, "dect%-alien%-biomes") +end + +-- Yuoki Industries +if mods["Yuoki"] or mods["yi_railway"] then + -- Causes multiplayer desyncs when using icon sprites on signs + log("Yuoki Industries detected, blacklisting sign icons.") + local yuoki_blacklist = {"y_", "y%-", "ye_", "yi_", "yie_", "yir_", "z_yira_", "ypfw_"} + for _, item in pairs(yuoki_blacklist) do + table.insert(DECT.CONFIG.SIGN_BLACKLIST, item) + end end