From ace0dc00c7848d8be085cbdb9dc32e7bc94c2d1c Mon Sep 17 00:00:00 2001 From: kabou Date: Wed, 30 Mar 2022 11:22:33 +0200 Subject: [PATCH] Remove `settlements_in_world` and `settlements.txt` The global(!) table settlements_in_world` has no use, but is serialized and saved to a file `settlements.txt` every time during generation of a new village, adding more lag. This commit removes all related code: * Remove all instances of `settlements_in_world`. * Remove `settlements.load()` and `settlements.save()`. --- mods/MAPGEN/mcl_villages/buildings.lua | 4 ---- mods/MAPGEN/mcl_villages/const.lua | 5 ----- mods/MAPGEN/mcl_villages/init.lua | 1 - mods/MAPGEN/mcl_villages/utils.lua | 23 ----------------------- 4 files changed, 33 deletions(-) diff --git a/mods/MAPGEN/mcl_villages/buildings.lua b/mods/MAPGEN/mcl_villages/buildings.lua index a690290633..c014bb07af 100644 --- a/mods/MAPGEN/mcl_villages/buildings.lua +++ b/mods/MAPGEN/mcl_villages/buildings.lua @@ -93,10 +93,6 @@ function settlements.create_site_plan(maxp, minp, pr) -- go build settlement around center if not center_surface then return false end - -- add settlement to list - table.insert(settlements_in_world, center_surface) - -- save list to file - settlements.save() -- initialize all settlement_info table local count_buildings, number_of_buildings, number_built = settlements.initialize_settlement_info(pr) -- first building is townhall in the center diff --git a/mods/MAPGEN/mcl_villages/const.lua b/mods/MAPGEN/mcl_villages/const.lua index eb7806209d..65f43f3445 100644 --- a/mods/MAPGEN/mcl_villages/const.lua +++ b/mods/MAPGEN/mcl_villages/const.lua @@ -65,11 +65,6 @@ settlements.schematic_table = { {name = "well", mts = schem_path.."well.mts", hwidth = 6, hdepth = 8, hheight = 6, hsize = 10, max_num = 0.045, rplc = basic_pseudobiome_villages }, } --- --- list of settlements, load on server start up --- -settlements_in_world = {} --- -- -- maximum allowed difference in height for building a sttlement -- diff --git a/mods/MAPGEN/mcl_villages/init.lua b/mods/MAPGEN/mcl_villages/init.lua index 7e460990e0..a899b3234c 100644 --- a/mods/MAPGEN/mcl_villages/init.lua +++ b/mods/MAPGEN/mcl_villages/init.lua @@ -10,7 +10,6 @@ dofile(settlements.modpath.."/paths.lua") -- -- load settlements on server -- -settlements_in_world = settlements.load() settlements.grundstellungen() diff --git a/mods/MAPGEN/mcl_villages/utils.lua b/mods/MAPGEN/mcl_villages/utils.lua index 993de11c42..22453a8ab5 100644 --- a/mods/MAPGEN/mcl_villages/utils.lua +++ b/mods/MAPGEN/mcl_villages/utils.lua @@ -88,29 +88,6 @@ function settlements.check_distance(settlement_info, building_pos, building_size return true end ------------------------------------------------------------------------------- --- save list of generated settlements -------------------------------------------------------------------------------- -function settlements.save() - local file = io.open(minetest.get_worldpath().."/settlements.txt", "w") - if file then - file:write(minetest.serialize(settlements_in_world)) - file:close() - end -end -------------------------------------------------------------------------------- --- load list of generated settlements -------------------------------------------------------------------------------- -function settlements.load() - local file = io.open(minetest.get_worldpath().."/settlements.txt", "r") - if file then - local table = minetest.deserialize(file:read("*all")) - if type(table) == "table" then - return table - end - end - return {} -end -------------------------------------------------------------------------------- -- fill chests ------------------------------------------------------------------------------- function settlements.fill_chest(pos, pr)