1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-01-18 03:21:47 +02:00

Fix desync risk

This commit is contained in:
Matthew Heguy 2019-02-27 21:30:56 -05:00
parent e613301d8d
commit 32baf80cd1

View File

@ -6,7 +6,7 @@ local Game = require 'utils.game'
local math = require 'utils.math'
local Server = require 'features.server'
local Command = require 'utils.command'
local Color = require 'resources.color_presets'
-- local Color = require 'resources.color_presets' -- commented to avoid lint error (secondary to desync risk)
local Ranks = require 'resources.ranks'
local insert = table.insert
@ -19,8 +19,8 @@ local duration_slider_max = duration_max / duration_step
local tick_duration_step = duration_step * 60
local inv_tick_duration_step = 1 / tick_duration_step
local normal_color = Color.white
local focus_color = Color.dark_orange
-- local normal_color = Color.white -- commented to avoid lint error (secondary to desync risk)
-- local focus_color = Color.dark_orange -- commented to avoid lint error (secondary to desync risk)
local polls = {}
local polls_counter = {0}
@ -242,12 +242,12 @@ local function redraw_poll_viewer_content(data)
local question_label = question_flow.add {type = 'label', caption = poll.question}
question_label.style.height = 32
question_label.style.font_color = focus_color
-- question_label.style.font_color = focus_color -- commented to avoid desync risk
question_label.style.font = 'default-listbox'
local grid = poll_viewer_content.add {type = 'table', column_count = 2}
local answer = voters[player.index]
-- local answer = voters[player.index] -- commented to avoid lint error (secondary to desync risk)
local vote_buttons = {}
for i, a in pairs(answers) do
local vote_button_flow = grid.add {type = 'flow'}
@ -273,10 +273,10 @@ local function redraw_poll_viewer_content(data)
vote_button_style.left_padding = 0
vote_button_style.right_padding = 0
if answer == a then
vote_button_style.font_color = focus_color
vote_button_style.disabled_font_color = focus_color
end
-- if answer == a then -- block commented to avoid desync risk
-- vote_button_style.font_color = focus_color
-- vote_button_style.disabled_font_color = focus_color
-- end
Gui.set_data(vote_button, {answer = a, data = data})
vote_buttons[i] = vote_button
@ -770,22 +770,22 @@ local function vote(event)
vote_button.caption = previous_vote_button_count
vote_button.tooltip = previous_vote_button_tooltip
if p.index == player_index then
local vote_button_style = vote_button.style
vote_button_style.font_color = normal_color
vote_button_style.disabled_font_color = normal_color
end
-- if p.index == player_index then
-- local vote_button_style = vote_button.style -- block commented to avoid desync risk
-- vote_button_style.font_color = normal_color
-- vote_button_style.disabled_font_color = normal_color
-- end
end
local vote_button = vote_buttons[vote_index]
vote_button.caption = vote_button_count
vote_button.tooltip = vote_button_tooltip
if p.index == player_index then
local vote_button_style = vote_button.style
vote_button_style.font_color = focus_color
vote_button_style.disabled_font_color = focus_color
end
-- if p.index == player_index then -- block commented to avoid desync risk
-- local vote_button_style = vote_button.style
-- vote_button_style.font_color = focus_color
-- vote_button_style.disabled_font_color = focus_color
-- end
end
end
end