Skip to content

Commit

Permalink
More bug huntin ™️
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerkiz committed Oct 26, 2024
1 parent ab53e52 commit debcc2f
Show file tree
Hide file tree
Showing 18 changed files with 91 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -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' } },
Expand Down
17 changes: 11 additions & 6 deletions maps/mountain_fortress_v3/breached_wall.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions maps/mountain_fortress_v3/charging_station.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions maps/mountain_fortress_v3/entities.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
16 changes: 10 additions & 6 deletions maps/mountain_fortress_v3/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()
Expand Down Expand Up @@ -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)
Expand All @@ -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

Expand Down
8 changes: 4 additions & 4 deletions maps/mountain_fortress_v3/gui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions maps/mountain_fortress_v3/ic/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions maps/mountain_fortress_v3/ic/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion maps/mountain_fortress_v3/ic/minimap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions maps/mountain_fortress_v3/icw/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions maps/mountain_fortress_v3/icw/linked_chests.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions maps/mountain_fortress_v3/locomotive.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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::
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions maps/mountain_fortress_v3/locomotive/friendly_pet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit debcc2f

Please sign in to comment.