1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-03-25 21:29:06 +02:00

More bug huntin ™️

This commit is contained in:
Gerkiz 2024-10-26 02:06:48 +02:00
parent ab53e522b1
commit debcc2fbe6
18 changed files with 91 additions and 66 deletions

View File

@ -1470,7 +1470,7 @@ stds.factorio_defines = {
}
}
},
controllers = { fields = { 'spectator', 'character', 'god', 'cutscene', 'editor', 'ghost' } },
controllers = { fields = { 'spectator', 'character', 'god', 'cutscene', 'editor', 'ghost', 'remote' } },
deconstruction_item = {
fields = {
entity_filter_mode = { fields = { 'whitelist', 'blacklist' } },

View File

@ -137,12 +137,12 @@ local breach_wall_warning_teleport = function (player, check_trusted)
local message = ({ 'breached_wall.warning_not_trusted_teleport', player.name })
Alert.alert_all_players(40, message)
end
local pos = player.surface.find_non_colliding_position('character', player.force.get_spawn_position(player.surface), 3, 0)
local pos = player.physical_surface.find_non_colliding_position('character', player.force.get_spawn_position(player.physical_surface), 3, 0)
if pos then
player.teleport(pos, player.surface)
player.teleport(pos, player.physical_surface)
else
pos = game.forces.player.get_spawn_position(player.surface)
player.teleport(pos, player.surface)
pos = game.forces.player.get_spawn_position(player.physical_surface)
player.teleport(pos, player.physical_surface)
end
return true
end
@ -157,7 +157,7 @@ local spidertron_too_far =
)
local check_distance_between_player_and_locomotive = function (player)
local surface = player.surface
local surface = player.physical_surface
local position = player.physical_position
local locomotive = Public.get('locomotive')
if not locomotive or not locomotive.valid then
@ -452,10 +452,15 @@ local function on_player_changed_position(event)
if not player or not player.valid then
return
end
if player.controller_type == defines.controllers.remote then
return
end
if player.controller_type == defines.controllers.spectator then
return
end
local surface_name = player.surface.name
local surface_name = player.physical_surface.name
if sub(surface_name, 0, #scenario_name) ~= scenario_name then
return

View File

@ -75,7 +75,7 @@ local function charge(player)
return player.print(module_name .. 'No valid armor to charge was found.', { color = Color.warning })
end
local ents = player.surface.find_entities_filtered { name = 'accumulator', force = player.force, position = player.physical_position, radius = 13 }
local ents = player.physical_surface.find_entities_filtered { name = 'accumulator', force = player.force, position = player.physical_position, radius = 13 }
if not ents or not next(ents) then
return player.print(module_name .. 'No accumulators nearby.', { color = Color.warning })
end
@ -85,7 +85,7 @@ local function charge(player)
if piece.valid and piece.generator_power == 0 then
local energy_needs = piece.max_energy - piece.energy
if energy_needs > 0 then
local energy = discharge_accumulators(player.surface, player.physical_position, player.force, energy_needs)
local energy = discharge_accumulators(player.physical_surface, player.physical_position, player.force, energy_needs)
if energy > 0 then
if piece.energy + energy >= piece.max_energy then
piece.energy = piece.max_energy

View File

@ -498,8 +498,8 @@ local unstuck_player_token =
return
end
local surface = player.surface
local position = surface.find_non_colliding_position('character', player.physical_position, 32, 1)
local surface = player.physical_surface
local position = surface.find_non_colliding_position('stone-furnace', player.physical_position, 32, 1)
if not position then
return
end
@ -1319,7 +1319,7 @@ function Public.unstuck_player(index)
return
end
local surface = player.surface
local surface = player.physical_surface
local position = surface.find_non_colliding_position('character', player.physical_position, 32, 1)
if not position then
return
@ -1494,7 +1494,7 @@ local function on_built_entity(event)
}
)
player.surface.spill_item_stack({ position = position, stack = { name = entity.name, count = 1, quality = 'normal' } })
player.physical_surface.spill_item_stack({ position = position, stack = { name = entity.name, count = 1, quality = 'normal' } })
entity.destroy()
return

View File

@ -1644,11 +1644,15 @@ function Public.on_player_changed_position(event)
return
end
if player.controller_type == defines.controllers.remote then
return
end
if player.controller_type == defines.controllers.spectator then
return
end
if string.sub(player.surface.name, 0, #scenario_name) ~= scenario_name then
if string.sub(player.physical_surface.name, 0, #scenario_name) ~= scenario_name then
return
end
@ -1665,7 +1669,7 @@ function Public.on_player_changed_position(event)
if random(1, 2) == 1 then
show_text('This path is not for players!', p, surface, player)
end
player.surface.create_entity({ name = 'fire-flame', position = player.physical_position })
player.physical_surface.create_entity({ name = 'fire-flame', position = player.physical_position })
player.character.health = player.character.health - tile_damage
if player.character.health == 0 then
player.character.die()
@ -1846,7 +1850,7 @@ function Public.set_player_to_god(player)
return false
end
if string.sub(player.surface.name, 0, #surface.name) == surface.name then
if string.sub(player.physical_surface.name, 0, #surface.name) == surface.name then
local pos = surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0)
if pos then
player.teleport(pos, surface)
@ -1855,11 +1859,11 @@ function Public.set_player_to_god(player)
player.teleport(pos, surface)
end
else
local pos = player.surface.find_non_colliding_position('character', { 0, 0 }, 3, 0)
local pos = player.physical_surface.find_non_colliding_position('character', { 0, 0 }, 3, 0)
if pos then
player.teleport(pos, player.surface)
player.teleport(pos, player.physical_surface)
else
player.teleport({ pos }, player.surface)
player.teleport({ pos }, player.physical_surface)
end
end

View File

@ -340,7 +340,7 @@ local function changed_surface(player)
return
end
if player.surface == main.surface then
if player.physical_surface == main.surface then
local minimap = player.gui.left.icw_main_frame
if main_toggle_button and not main_toggle_button.visible then
main_toggle_button.visible = true
@ -380,7 +380,7 @@ local function changed_surface(player)
info.sprite = 'utility/expand'
info.visible = true
end
elseif player.surface == wagon_surface then
elseif player.physical_surface == wagon_surface then
if main_toggle_button and main_toggle_button.visible then
main_toggle_button.visible = false
end
@ -473,10 +473,10 @@ local function on_gui_click(event)
if not player or not player.valid then
return
end
if not player.surface or not player.surface.valid then
if not player.physical_surface or not player.physical_surface.valid then
return
end
if player.surface ~= locomotive.surface then
if player.physical_surface ~= locomotive.surface then
local minimap = player.gui.left.icw_main_frame
if minimap and minimap.visible then
minimap.visible = false

View File

@ -193,7 +193,7 @@ local function get_entity_from_player_surface(cars, player)
local surface_index = car.surface
local surface = game.surfaces[surface_index]
if validate_entity(surface) then
if car.surface == player.surface.index then
if car.surface == player.physical_surface.index then
return car.entity
end
end
@ -226,7 +226,7 @@ local function get_player_surface(player)
for _, index in pairs(surfaces) do
local surface = game.surfaces[index]
if validate_entity(surface) then
if surface.index == player.surface.index then
if surface.index == player.physical_surface.index then
return true
end
end
@ -404,7 +404,7 @@ local function kick_players_out_of_vehicles(car)
for _, player in pairs(game.connected_players) do
local character = player.character
if validate_entity(character) and character.driving then
if car.surface == player.surface.index then
if car.surface == player.physical_surface.index then
character.driving = false
end
end
@ -477,7 +477,7 @@ local function kick_non_trusted_players_from_surface(car)
Core.iter_connected_players(
function (player)
local is_trusted = trust_system and trust_system.players and trust_system.players[player.name] and trust_system.players[player.name].trusted
if player.surface.index == surface_index and player.index ~= car.owner and not is_trusted then
if player.physical_surface.index == surface_index and player.index ~= car.owner and not is_trusted then
if position then
local new_position = main_surface.find_non_colliding_position('character', position, 3, 0)
if new_position then
@ -806,7 +806,7 @@ function Public.save_car(event)
}
Task.set_timeout_in_ticks(10, remove_car, params)
if restore_on_theft then
local e = player.surface.create_entity({ name = car.name, position = position, force = player.force, create_build_effect_smoke = false })
local e = player.physical_surface.create_entity({ name = car.name, position = position, force = player.force, create_build_effect_smoke = false })
e.health = health
restore_surface(p, e)
elseif p.can_insert({ name = car.name, count = 1 }) then
@ -1408,7 +1408,7 @@ function Public.use_door_with_entity(player, door)
player_data.fallback_position = { car.entity.position.x, car.entity.position.y }
end
if validate_entity(car.entity) and car.entity.surface.name == player.surface.name then
if validate_entity(car.entity) and car.entity.surface.name == player.physical_surface.name then
local surface_index = car.surface
local surface = game.surfaces[surface_index]
if validate_entity(car.entity) and car.owner == player.index then

View File

@ -138,6 +138,10 @@ local function on_gui_closed(event)
return
end
if player.controller_type == defines.controllers.remote then
return
end
if player.controller_type == defines.controllers.spectator then
return
end
@ -165,6 +169,10 @@ local function on_gui_opened(event)
return
end
if player.controller_type == defines.controllers.remote then
return
end
if player.controller_type == defines.controllers.spectator then
return
end

View File

@ -293,7 +293,7 @@ function Public.changed_surface(event)
if diff and diff.visible then
diff.visible = false
end
elseif player.surface.index == surface.index then
elseif player.physical_surface.index == surface.index then
Gui.remove_toolbar(player)
Public.toggle_button(player)
kill_minimap(player)

View File

@ -201,7 +201,7 @@ local function kick_players_out_of_vehicles(wagon)
for _, player in pairs(game.connected_players) do
local character = player.character
if character and character.valid and character.driving then
if wagon.surface == player.surface then
if wagon.surface == player.physical_surface then
character.driving = false
end
end
@ -534,7 +534,7 @@ end
function Public.is_minimap_valid(player, surface)
if validate_entity(player) then
if player.surface ~= surface then
if player.physical_surface ~= surface then
Public.kill_minimap(player)
end
end
@ -788,7 +788,7 @@ function Public.use_cargo_wagon_door_with_entity(icw, player, door)
player_data.fallback_surface = wagon.entity.surface.index
player_data.fallback_position = { wagon.entity.position.x, wagon.entity.position.y }
if wagon.entity.surface.name ~= player.surface.name then
if wagon.entity.surface.name ~= player.physical_surface.name then
local surface = wagon.entity.surface
if not (surface and surface.valid) then
return
@ -802,7 +802,7 @@ function Public.use_cargo_wagon_door_with_entity(icw, player, door)
if not surface_position then
surface.request_to_generate_chunks({ -20, 22 }, 1)
if player.character and player.character.valid and player.character.driving then
if wagon.surface == player.surface then
if wagon.surface == player.physical_surface then
player.character.driving = false
end
end

View File

@ -648,7 +648,7 @@ local function on_built_entity(event, mode, bypass)
return
end
if player.surface.index ~= active_surface_index then
if player.physical_surface.index ~= active_surface_index then
if entity.type ~= 'entity-ghost' then
player.insert({ name = 'linked-chest', count = 1 })
end
@ -738,7 +738,7 @@ local function built_entity_robot(event)
return
end
if player.surface.index ~= active_surface_index then
if player.physical_surface.index ~= active_surface_index then
if entity.type ~= 'entity-ghost' then
player.insert({ name = 'linked-chest', count = 1 })
end

View File

@ -184,19 +184,19 @@ local function hurt_players_outside_of_aura()
Core.iter_connected_players(
function (player)
if sub(player.surface.name, 0, #scenario_name) == scenario_name then
if sub(player.physical_surface.name, 0, #scenario_name) == scenario_name then
local position = player.physical_position
local inside = ((position.x - loco.x) ^ 2 + (position.y - loco.y) ^ 2) < upgrades.locomotive_aura_radius ^ 2
if not inside then
local entity = player.character
if entity and entity.valid then
death_effects(player)
player.surface.create_entity({ name = 'fire-flame', position = position })
player.physical_surface.create_entity({ name = 'fire-flame', position = position })
if random(1, 3) == 1 then
player.surface.create_entity({ name = 'medium-scorchmark', position = position, force = 'neutral' })
player.physical_surface.create_entity({ name = 'medium-scorchmark', position = position, force = 'neutral' })
end
local max_health = floor(player.character.max_health + player.character_health_bonus + player.force.character_health_bonus)
local vehicle = player.vehicle
local vehicle = player.physical_vehicle
if vehicle and vehicle.valid and non_valid_vehicles[vehicle.type] then
player.driving = false
end
@ -263,8 +263,8 @@ local function give_passive_xp(data)
local position = player.physical_position
local inside = ((position.x - loco.x) ^ 2 + (position.y - loco.y) ^ 2) < upgrades.locomotive_aura_radius ^ 2
if player.afk_time < 200 and not RPG.get_last_spell_cast(player) then
if inside or player.surface.index == loco_surface.index then
if player.surface.index == loco_surface.index then
if inside or player.physical_surface.index == loco_surface.index then
if player.physical_surface.index == loco_surface.index then
Public.add_player_to_permission_group(player, 'limited')
elseif ICFunctions.get_player_surface(player) then
Public.add_player_to_permission_group(player, 'limited')
@ -302,12 +302,12 @@ local function give_passive_xp(data)
local active_surface_index = Public.get('active_surface_index')
local surface = game.surfaces[active_surface_index]
if surface and surface.valid then
if player.surface.index == surface.index then
if player.physical_surface.index == surface.index then
Public.add_player_to_permission_group(player, 'main_surface')
end
end
end
elseif player.afk_time > 1800 and player.character and player.surface.index == loco_surface.index and player.get_requester_point() then
elseif player.afk_time > 1800 and player.character and player.physical_surface.index == loco_surface.index and player.get_requester_point() then
player.get_requester_point().enabled = false
end
::pre_exit::
@ -572,11 +572,11 @@ local function on_player_changed_surface(event)
local locomotive_surface = Public.get('loco_surface')
if locomotive_surface and locomotive_surface.valid and player.surface.index == locomotive_surface.index then
if locomotive_surface and locomotive_surface.valid and player.physical_surface.index == locomotive_surface.index then
return Public.add_player_to_permission_group(player, 'limited')
elseif ICFunctions.get_player_surface(player) then
return Public.add_player_to_permission_group(player, 'limited')
elseif player.surface.index == surface.index then
elseif player.physical_surface.index == surface.index then
return Public.add_player_to_permission_group(player, 'main_surface')
end
end

View File

@ -48,13 +48,13 @@ local function shoo(event)
local player = game.players[event.player_index]
if player and player.valid then
if player.surface.index ~= loco_surface.index then
if player.physical_surface.index ~= loco_surface.index then
return
end
end
local locomotive_biter = Public.get('locomotive_biter')
local surface = player.surface
local surface = player.physical_surface
local message = event.message
message = string.lower(message)
for word in string.gmatch(message, '%g+') do

View File

@ -935,6 +935,11 @@ local function gui_opened(event)
if not player or not player.valid then
return
end
if player.controller_type == defines.controllers.remote then
return
end
if player.controller_type == defines.controllers.spectator then
return
end

View File

@ -313,7 +313,7 @@ local function randomness(data)
if harvest_amount > max_spill then
if spill_items_to_surface then
player.surface.spill_item_stack({ position = position, stack = { name = harvest, count = max_spill, quality = 'normal' } })
player.physical_surface.spill_item_stack({ position = position, stack = { name = harvest, count = max_spill, quality = 'normal' } })
else
player.insert({ name = harvest, count = max_spill })
end
@ -322,14 +322,14 @@ local function randomness(data)
harvest_amount = harvest_amount - inserted_count
if harvest_amount > 0 then
if spill_items_to_surface then
player.surface.spill_item_stack({ position = position, stack = { name = harvest, count = harvest_amount, quality = 'normal' } })
player.physical_surface.spill_item_stack({ position = position, stack = { name = harvest, count = harvest_amount, quality = 'normal' } })
else
player.insert({ name = harvest, count = harvest_amount })
end
end
else
if spill_items_to_surface then
player.surface.spill_item_stack({ position = position, stack = { name = harvest, count = harvest_amount, quality = 'normal' } })
player.physical_surface.spill_item_stack({ position = position, stack = { name = harvest, count = harvest_amount, quality = 'normal' } })
else
player.insert({ name = harvest, count = harvest_amount })
end
@ -337,9 +337,9 @@ local function randomness(data)
local particle = particles[harvest]
if data.script_character then
create_particles(player.surface, particle, position, 16, { x = data.script_character.position.x, y = data.script_character.position.y })
create_particles(player.physical_surface, particle, position, 16, { x = data.script_character.position.x, y = data.script_character.position.y })
else
create_particles(player.surface, particle, position, 16, { x = player.physical_position.x, y = player.physical_position.y })
create_particles(player.physical_surface, particle, position, 16, { x = player.physical_position.x, y = player.physical_position.y })
end
end
@ -369,7 +369,7 @@ local function randomness_scrap(data)
if harvest_amount > max_spill then
if spill_items_to_surface then
player.surface.spill_item_stack({ position = position, stack = { name = harvest, count = max_spill, quality = 'normal' } })
player.physical_surface.spill_item_stack({ position = position, stack = { name = harvest, count = max_spill, quality = 'normal' } })
else
player.insert({ name = harvest, count = max_spill })
end
@ -378,23 +378,23 @@ local function randomness_scrap(data)
harvest_amount = harvest_amount - inserted_count
if harvest_amount > 0 then
if spill_items_to_surface then
player.surface.spill_item_stack({ position = position, stack = { name = harvest, count = harvest_amount, quality = 'normal' } })
player.physical_surface.spill_item_stack({ position = position, stack = { name = harvest, count = harvest_amount, quality = 'normal' } })
else
player.insert({ name = harvest, count = harvest_amount })
end
end
else
if spill_items_to_surface then
player.surface.spill_item_stack({ position = position, stack = { name = harvest, count = harvest_amount, quality = 'normal' } })
player.physical_surface.spill_item_stack({ position = position, stack = { name = harvest, count = harvest_amount, quality = 'normal' } })
else
player.insert({ name = harvest, count = harvest_amount })
end
end
local particle = particles[harvest]
if data.script_character then
create_particles(player.surface, particle, position, 64, { x = data.script_character.position.x, y = data.script_character.position.y })
create_particles(player.physical_surface, particle, position, 64, { x = data.script_character.position.x, y = data.script_character.position.y })
else
create_particles(player.surface, particle, position, 64, { x = player.physical_position.x, y = player.physical_position.y })
create_particles(player.physical_surface, particle, position, 64, { x = player.physical_position.x, y = player.physical_position.y })
end
end

View File

@ -339,7 +339,7 @@ local function mystical_chest_reward(player)
if player.gui.screen['reward_system'] then
player.gui.screen['reward_system'].destroy()
end
return player.print('[Rewards] No rewards are available.', {color = Color.fail})
return player.print('[Rewards] No rewards are available.', { color = Color.fail })
end
-- something fancy to reward players
@ -374,6 +374,10 @@ local function container_opened(event)
return
end
if player.controller_type == defines.controllers.remote then
return
end
if player.controller_type == defines.controllers.spectator then
return
end
@ -416,7 +420,7 @@ local function on_gui_click(event)
if data.id == i then
local success, msg = mc_random_rewards[id].func(player)
if not success then
return player.print(msg, {color = Color.fail})
return player.print(msg, { color = Color.fail })
end
break
end

View File

@ -25,7 +25,6 @@ local buffs_window_name = Gui.uid_name()
local on_click_buff_name = Gui.uid_name()
local random = math.random
local floor = math.floor
local scenario_name = Public.scenario_name
local main_frame
local function create_particles(surface, name, position, amount, cause_position)
@ -69,7 +68,7 @@ local spread_particles_token =
end
local particle = event.particle
create_particles(player.surface, particle, player.physical_position, 128)
create_particles(player.physical_surface, particle, player.physical_position, 128)
end
)
@ -199,7 +198,7 @@ local warn_player_sound_token =
player.play_sound { path = 'utility/new_objective', volume_modifier = 0.75 }
create_particles(player.surface, particle, player.physical_position, 128)
create_particles(player.physical_surface, particle, player.physical_position, 128)
end
)
@ -1208,7 +1207,7 @@ local function update_raw()
stateful.collection.gather_time = tick + (10 * 3600)
stateful.collection.gather_time_timer = tick + (10 * 3600)
game.forces.enemy.set_evolution_factor(1, player.surface)
game.forces.enemy.set_evolution_factor(1, player.physical_surface)
play_achievement_unlocked()
local reverse_position = zone_settings.zone_depth * (breached_wall + 1)
local reversed = Public.get_stateful_settings('reversed')

View File

@ -41,12 +41,12 @@ local function on_console_chat(event)
return
end
if player.character.surface.index ~= player.surface.index then return end
if player.character.surface.index ~= player.physical_surface.index then return end
this.player_floaty_chat[player.index] =
rendering.draw_text {
text = event.message,
surface = player.surface,
surface = player.physical_surface,
target = {
entity = player.character,
offset = { -0.05, y_offset },