Skip to content

Commit

Permalink
Prevent Yuoki Industries icons from causing a desync - Fixes #82
Browse files Browse the repository at this point in the history
  • Loading branch information
jpanther committed Mar 6, 2019
1 parent ab33129 commit dcb493e
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 10 deletions.
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 2 additions & 0 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 6 additions & 4 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion info.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Dectorio",
"version": "0.9.3",
"version": "0.9.4",
"title": "Dectorio",
"author": "PantherX",
"contact": "",
Expand Down
4 changes: 2 additions & 2 deletions prototypes/entity/signs-icons.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion prototypes/third-party/alien-biomes.lua
Original file line number Diff line number Diff line change
@@ -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

Expand Down
17 changes: 15 additions & 2 deletions prototypes/third-party/config.lua
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit dcb493e

Please sign in to comment.