From 2ad31cc5ec671e6bf98b31f0976b31007b304a33 Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Tue, 7 Jul 2020 17:44:04 +0200 Subject: [PATCH] remove unused code --- maps/fish_defender/main.lua | 25 +++++++++++++++---------- maps/fish_defender/table.lua | 16 +--------------- maps/fish_defender/terrain.lua | 8 ++++++-- 3 files changed, 22 insertions(+), 27 deletions(-) diff --git a/maps/fish_defender/main.lua b/maps/fish_defender/main.lua index 92f2c8c4..78fb16df 100644 --- a/maps/fish_defender/main.lua +++ b/maps/fish_defender/main.lua @@ -884,7 +884,8 @@ end local function market_kill_visuals() local market = FDT.get('market') - local surface = FDT.get('active_surface') + local active_surface_index = FDT.get('active_surface_index') + local surface = game.surfaces[active_surface_index] if not surface or not surface.valid then return @@ -897,7 +898,7 @@ local function market_kill_visuals() local m = 32 local m2 = m * 0.005 for i = 1, 1024, 1 do - surface.create_particle( + surface.create_entity( { name = 'branch-particle', position = market.position, @@ -1018,7 +1019,12 @@ end local function on_player_joined_game(event) local player = game.players[event.player_index] local show_floating_killscore = FDT.get('show_floating_killscore') - local active_surface = FDT.get('active_surface') + local active_surface_index = FDT.get('active_surface_index') + local surface = game.surfaces[active_surface_index] + + if player.gui.left['fish_defense_game_lost'] then + player.gui.left['fish_defense_game_lost'].destroy() + end if player.online_time == 0 then player.insert({name = 'pistol', count = 1}) @@ -1031,15 +1037,14 @@ local function on_player_joined_game(event) end end - local surface = active_surface if player.online_time < 2 and surface.is_chunk_generated({0, 0}) then player.teleport( surface.find_non_colliding_position('character', game.forces['player'].get_spawn_position(surface), 50, 1), - 'fish_defender' + surface.name ) else if player.online_time < 2 then - player.teleport(game.forces['player'].get_spawn_position(surface), 'fish_defender') + player.teleport(game.forces['player'].get_spawn_position(surface), surface.name) end end @@ -1225,9 +1230,9 @@ end local function on_tick() local Diff = Difficulty.get() - local active_surface = FDT.get('active_surface') + local active_surface_index = FDT.get('active_surface_index') + local surface = game.surfaces[active_surface_index] local this = FDT.get() - local surface = active_surface if game.tick % 30 == 0 then if this.market then for _, player in pairs(game.connected_players) do @@ -1280,9 +1285,9 @@ end local function on_player_changed_position(event) local player = game.players[event.player_index] - local active_surface = FDT.get('active_surface') + local active_surface_index = FDT.get('active_surface_index') + local surface = game.surfaces[active_surface_index] local map_height = FDT.get('map_height') - local surface = active_surface if player.position.x + player.position.y < 0 then return end diff --git a/maps/fish_defender/table.lua b/maps/fish_defender/table.lua index 9c14cfbd..001c9045 100644 --- a/maps/fish_defender/table.lua +++ b/maps/fish_defender/table.lua @@ -2,21 +2,7 @@ local Global = require 'utils.global' local Event = require 'utils.event' -local this = { - players = {}, - offline_players = {}, - hidden_dimension = { - logistic_research_level = 0, - reset_counter = 1 - }, - power_sources = {}, - refill_turrets = {index = 1}, - magic_crafters = {index = 1}, - magic_fluid_crafters = {index = 1}, - breached_wall = 1, - entity_limits = {}, - traps = {} -} +local this = {} local Public = {} Global.register( diff --git a/maps/fish_defender/terrain.lua b/maps/fish_defender/terrain.lua index 56a0ccba..12232163 100644 --- a/maps/fish_defender/terrain.lua +++ b/maps/fish_defender/terrain.lua @@ -466,9 +466,13 @@ local function plankton_territory(surface, position, seed) end local function process_chunk(left_top) - local active_surface = FDT.get('active_surface') + local active_surface_index = FDT.get('active_surface_index') + local surface = game.surfaces[active_surface_index] local market = FDT.get('market') - local surface = active_surface + + if not surface or not surface.valid then + return + end local seed = game.surfaces[1].map_gen_settings.seed