ops/factorio/multiworld: add debugrenameworld

This commit is contained in:
Luke Granger-Brown 2022-02-05 17:40:03 +00:00
parent ee8ec5263a
commit e005a5fd6e
2 changed files with 567 additions and 580 deletions

View file

@ -46,8 +46,13 @@ achievement disabling flag.
This is intended for use for admins to import existing save files as new
surfaces.
Note that once you've done so, you'll need to use the `/debugresetworldstate`
command in order to properly set up the extra metadata required by Multiworld.
Note that once you've done so, you'll need to use the `/debugrenameworld` or
`/debugresetworldstate` commands in order to properly set up the extra metadata
required by Multiworld.
### `/debugrenameworld <OLD NAME> <NEW NAME>` - rename a surface (admins only)
This is useful for renaming worlds imported by the `/debugeditor`.
### `/debugresetworldstate <WORLD NAME>` - reset book-keeping metadata for a world (admins only)

View file

@ -334,21 +334,6 @@ local function reset_inventories(surface, p)
global.inventories[surface.name] = {}
end
local function reset_locations(surface, p)
if global.locations == nil then
global.locations = {}
end
if global.locations[surface.name] ~= nil then
p('Destroying locations for surface ' .. surface.name, c)
for player_idx, location in pairs(global.locations[surface.name]) do
p(' .. ' .. game.players[player_idx].name .. ' (' .. location.x ..
', ' .. location.y .. ')', c)
-- We don't do anything here, this is just for logging purposes.
end
end
global.locations[surface.name] = {}
end
local function destroy_world(name, p)
local surface = get_surface_by_name(name)
if surface == nil then
@ -369,7 +354,6 @@ local function destroy_world(name, p)
game.delete_surface(surface)
reset_inventories(surface, p)
reset_locations(surface, p)
end
local function create_world(name, map_gen_settings, p)
@ -385,7 +369,6 @@ local function create_world(name, map_gen_settings, p)
local force = game.create_force(force_name_for_surface(surface))
reset_inventories(surface, p)
reset_locations(surface, p)
end
local function destroyworld_command(cmd)
@ -515,7 +498,6 @@ local function debugresetworldstate_command(cmd)
local force = game.create_force(force_name_for_surface(surface))
reset_inventories(surface, p)
reset_locations(surface, p)
local force = force_for_surface(surface)
local player_owned_entities = surface.find_entities_filtered {