From 6afaaff4aa387744db35b4cfd99b6b2f2f7c4a1d Mon Sep 17 00:00:00 2001 From: Patrick 'Quezler' Mounier Date: Thu, 9 Nov 2023 15:49:03 +0100 Subject: [PATCH] Fix recursive lagspike when adding the mod to a save that already has a large amount of discovered planets --- mods/glutenfree-se-tinted-pyramids/info.json | 2 +- .../scripts/handler.lua | 22 +++---------------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/mods/glutenfree-se-tinted-pyramids/info.json b/mods/glutenfree-se-tinted-pyramids/info.json index 6472f9f8..322f7705 100644 --- a/mods/glutenfree-se-tinted-pyramids/info.json +++ b/mods/glutenfree-se-tinted-pyramids/info.json @@ -3,7 +3,7 @@ "title": "Space Exploration - tinted pyramids", "description": "Tints unlooted pyramids in the color of the module.", "category": "cheats", - "version": "1.0.14", + "version": "1.0.15", "author": "Quezler", "factorio_version": "1.1", "dependencies": [ diff --git a/mods/glutenfree-se-tinted-pyramids/scripts/handler.lua b/mods/glutenfree-se-tinted-pyramids/scripts/handler.lua index d384bb41..ab7463ec 100644 --- a/mods/glutenfree-se-tinted-pyramids/scripts/handler.lua +++ b/mods/glutenfree-se-tinted-pyramids/scripts/handler.lua @@ -185,25 +185,9 @@ function Handler.on_post_gui_opened(event) row.row_flow.flags.caption = string.gsub(caption .. '', "se%-pyramid%-a]", "se-pyramid-a-tinted-" .. color .."]") else - local old_zone = nil - local old_position = nil - - -- return the player to the same remote view position afterwards - if remote.call("space-exploration", "remote_view_is_active", {player=player}) then - old_zone = remote.call("space-exploration", "get_zone_from_surface_index", {surface_index = player.surface_index}) - old_position = player.position - end - - -- remote view can force-generate a zone - local zone = remote.call("space-exploration", "get_zone_from_zone_index", {zone_index = row.tags.zone_index}) - remote.call("space-exploration", "remote_view_start", {player=player, zone_name = zone.name}) - - -- get the player back where he started - if old_zone then - remote.call("space-exploration", "remote_view_start", {player=player, zone_name = old_zone.name, position = old_position}) - else - remote.call("space-exploration", "remote_view_stop", {player=player}) - end + local surface = remote.call("space-exploration", "zone_get_make_surface", {zone_index = row.tags.zone_index}) + local render_distance = 32 * 8 -- pre render the spawn chunks as though a player pressed "view surface" themselves + player.force.chart(surface, {{x = -render_distance, y = -render_distance}, {x = render_distance, y = render_distance}}) end end end