mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-16 02:47:48 +02:00
debug and desync fixes
This commit is contained in:
parent
eef1c3f57a
commit
f76af8c582
@ -1015,6 +1015,10 @@ Gui.on_click(
|
||||
function(event)
|
||||
local player = event.player
|
||||
local data = Gui.get_data(event.element)
|
||||
if not data or not data.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local frame = data.frame
|
||||
local poll = data.previous_data
|
||||
|
||||
|
@ -15,7 +15,6 @@ require 'utils.datastore.jail_data'
|
||||
require 'utils.datastore.quickbar_data'
|
||||
require 'utils.datastore.message_on_join_data'
|
||||
require 'utils.datastore.player_tag_data'
|
||||
require 'utils.profiler'
|
||||
require 'chatbot'
|
||||
require 'commands'
|
||||
require 'antigrief'
|
||||
@ -88,10 +87,10 @@ require 'modules.autostash'
|
||||
--require 'maps.biter_battles.biter_battles'
|
||||
|
||||
--![[A map that imitating MF, defending rocket silos instead of trains]]--
|
||||
-- require 'maps.amap.main'
|
||||
--require 'maps.amap.main'
|
||||
|
||||
--![[Guide a Train through rough terrain, while defending it from the biters]]--
|
||||
-- require 'maps.mountain_fortress_v3.main'
|
||||
--require 'maps.mountain_fortress_v3.main'
|
||||
--require 'maps.mountain_fortress_v2.main'
|
||||
--require 'maps.mountain_fortress'
|
||||
|
||||
@ -236,6 +235,7 @@ require 'modules.autostash'
|
||||
|
||||
if _DUMP_ENV then
|
||||
require 'utils.dump_env'
|
||||
require 'utils.profiler'
|
||||
end
|
||||
|
||||
local function on_player_created(event)
|
||||
|
@ -351,7 +351,12 @@ local function update_gui()
|
||||
if valid then
|
||||
if success then
|
||||
if target and target.valid then
|
||||
local main = target.get_main_inventory().get_contents()
|
||||
local main = target.get_main_inventory()
|
||||
if not main then
|
||||
return
|
||||
end
|
||||
|
||||
main = main.get_contents()
|
||||
local armor = target.get_inventory(defines.inventory.character_armor).get_contents()
|
||||
local guns = target.get_inventory(defines.inventory.character_guns).get_contents()
|
||||
local ammo = target.get_inventory(defines.inventory.character_ammo).get_contents()
|
||||
|
@ -14,6 +14,10 @@ commands.add_command(
|
||||
return
|
||||
end
|
||||
|
||||
if (player.name ~= 'Gerkiz' and not _DEBUG) then
|
||||
return
|
||||
end
|
||||
|
||||
DebugView.open_debug(player)
|
||||
end
|
||||
)
|
||||
|
@ -5,13 +5,16 @@ local Public = {}
|
||||
|
||||
local pages = {
|
||||
require 'utils.debug.public_global_view',
|
||||
require 'utils.debug.global_view',
|
||||
require 'utils.debug.gui_data_view',
|
||||
require 'utils.debug.package_view',
|
||||
require 'utils.debug._g_view',
|
||||
require 'utils.debug.event_view'
|
||||
require 'utils.debug.global_view'
|
||||
}
|
||||
|
||||
if _DEBUG then
|
||||
pages[#pages + 1] = require 'utils.debug.gui_data_view'
|
||||
pages[#pages + 1] = require 'utils.debug.package_view'
|
||||
pages[#pages + 1] = require 'utils.debug._g_view'
|
||||
pages[#pages + 1] = require 'utils.debug.event_view'
|
||||
end
|
||||
|
||||
local main_frame_name = Gui.uid_name()
|
||||
local close_name = Gui.uid_name()
|
||||
local tab_name = Gui.uid_name()
|
||||
|
@ -125,6 +125,10 @@ Gui.on_click(
|
||||
|
||||
local top_panel = element.parent.parent
|
||||
local data = Gui.get_data(top_panel)
|
||||
if not data or not data.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local text_box = data.text_box
|
||||
|
||||
local variable_type = type(variable)
|
||||
|
@ -123,6 +123,9 @@ Gui.on_click(
|
||||
function(event)
|
||||
local element = event.element
|
||||
local data = Gui.get_data(element)
|
||||
if not data or not data.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local input_text_box = data.input_text_box
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
local Event = require 'utils.event_core'
|
||||
local Token = require 'utils.token'
|
||||
|
||||
local Global = {
|
||||
names = {}
|
||||
}
|
||||
local Global = {}
|
||||
local concat = table.concat
|
||||
|
||||
local names = {}
|
||||
Global.names = names
|
||||
|
||||
function Global.register(tbl, callback)
|
||||
if _LIFECYCLE ~= _STAGE.control then
|
||||
error('can only be called during the control stage', 2)
|
||||
@ -14,7 +15,7 @@ function Global.register(tbl, callback)
|
||||
local filepath = debug.getinfo(2, 'S').source:match('^.+/currently%-playing/(.+)$'):sub(1, -5)
|
||||
local token = Token.register_global(tbl)
|
||||
|
||||
Global.names[token] = concat {token, ' - ', filepath}
|
||||
names[token] = concat {token, ' - ', filepath}
|
||||
|
||||
Event.on_load(
|
||||
function()
|
||||
@ -32,7 +33,7 @@ function Global.register_init(tbl, init_handler, callback)
|
||||
local filepath = debug.getinfo(2, 'S').source:match('^.+/currently%-playing/(.+)$'):sub(1, -5)
|
||||
local token = Token.register_global(tbl)
|
||||
|
||||
Global.names[token] = concat {token, ' - ', filepath}
|
||||
names[token] = concat {token, ' - ', filepath}
|
||||
|
||||
Event.on_init(
|
||||
function()
|
||||
|
@ -5,16 +5,12 @@ local SpamProtection = require 'utils.spam_protection'
|
||||
|
||||
local tostring = tostring
|
||||
local next = next
|
||||
local concat = table.concat
|
||||
|
||||
local Gui = {}
|
||||
|
||||
local data = {}
|
||||
local element_map = {}
|
||||
|
||||
local names = {}
|
||||
Gui.names = names
|
||||
|
||||
Gui.token =
|
||||
Global.register(
|
||||
{data = data, element_map = element_map},
|
||||
@ -28,16 +24,7 @@ local on_visible_handlers = {}
|
||||
local on_pre_hidden_handlers = {}
|
||||
|
||||
function Gui.uid_name()
|
||||
local info = debug.getinfo(2, 'Sl')
|
||||
local filepath = info.source:match('^.+/currently%-playing/(.+)$'):sub(1, -5)
|
||||
local line = info.currentline
|
||||
|
||||
local token = tostring(Token.uid())
|
||||
|
||||
local name = concat {token, ' - ', filepath, ':line:', line}
|
||||
names[token] = name
|
||||
|
||||
return token
|
||||
return tostring(Token.uid())
|
||||
end
|
||||
|
||||
function Gui.uid()
|
||||
@ -54,9 +41,7 @@ function Gui.set_data(element, value)
|
||||
return
|
||||
end
|
||||
|
||||
local index = element.index
|
||||
values[index] = nil
|
||||
element_map[index] = nil
|
||||
values[element.index] = nil
|
||||
|
||||
if next(values) == nil then
|
||||
data[player_index] = nil
|
||||
@ -67,9 +52,7 @@ function Gui.set_data(element, value)
|
||||
data[player_index] = values
|
||||
end
|
||||
|
||||
local index = element.index
|
||||
values[index] = value
|
||||
element_map[index] = element
|
||||
values[element.index] = value
|
||||
end
|
||||
end
|
||||
local set_data = Gui.set_data
|
||||
@ -266,11 +249,61 @@ Gui.on_player_show_top = custom_handler_factory(on_visible_handlers)
|
||||
-- Adds a player field to the event table.
|
||||
Gui.on_pre_player_hide_top = custom_handler_factory(on_pre_hidden_handlers)
|
||||
|
||||
function Gui.data()
|
||||
return data
|
||||
if _DEBUG then
|
||||
local concat = table.concat
|
||||
|
||||
local names = {}
|
||||
Gui.names = names
|
||||
|
||||
function Gui.uid_name()
|
||||
local info = debug.getinfo(2, 'Sl')
|
||||
local filepath = info.source:match('^.+/currently%-playing/(.+)$'):sub(1, -5)
|
||||
local line = info.currentline
|
||||
|
||||
local token = tostring(Token.uid())
|
||||
|
||||
local name = concat {token, ' - ', filepath, ':line:', line}
|
||||
names[token] = name
|
||||
|
||||
return token
|
||||
end
|
||||
|
||||
function Gui.set_data(element, value)
|
||||
local player_index = element.player_index
|
||||
local values = data[player_index]
|
||||
|
||||
if value == nil then
|
||||
if not values then
|
||||
return
|
||||
end
|
||||
|
||||
local index = element.index
|
||||
values[index] = nil
|
||||
element_map[index] = nil
|
||||
|
||||
if next(values) == nil then
|
||||
data[player_index] = nil
|
||||
end
|
||||
else
|
||||
if not values then
|
||||
values = {}
|
||||
data[player_index] = values
|
||||
end
|
||||
|
||||
local index = element.index
|
||||
values[index] = value
|
||||
element_map[index] = element
|
||||
end
|
||||
end
|
||||
set_data = Gui.set_data
|
||||
|
||||
function Gui.data()
|
||||
return data
|
||||
end
|
||||
|
||||
function Gui.element_map()
|
||||
return element_map
|
||||
end
|
||||
end
|
||||
|
||||
function Gui.element_map()
|
||||
return element_map
|
||||
end
|
||||
return Gui
|
||||
|
@ -741,6 +741,21 @@ function Public.get_server_name()
|
||||
return start_data.server_name or ''
|
||||
end
|
||||
|
||||
--- Gets the server's name and matches it against a string.
|
||||
-- This is the current server's name, in the case the save has been loaded on multiple servers.
|
||||
-- @param string
|
||||
-- @return string
|
||||
function Public.check_server_name(string)
|
||||
if start_data.server_name then
|
||||
local server_name = start_data.server_name
|
||||
local str = string.match(server_name, string)
|
||||
if str then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
--- Gets the server's start time as a unix epoch timestamp. nil if not known.
|
||||
-- @return number?
|
||||
function Public.get_start_time()
|
||||
|
Loading…
Reference in New Issue
Block a user