1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-11-23 22:22:34 +02:00

Mtn v3: fix desync

This commit is contained in:
Gerkiz
2025-11-23 00:51:31 +01:00
parent 74aec924cd
commit cf1a914b90
6 changed files with 32 additions and 30 deletions

View File

@@ -89,11 +89,11 @@ notify_full_inventory_2=Your inventory is full. Join the warrior club today! Pum
new_items_at_market=New items have been unlocked at the locomotive market!
discharge_unlocked=Discharge defense has now been unlocked at the market!
artillery_unlocked=Artillery has now been unlocked at the market!
crafting_bonus=__1__ unlocked the last missing piece for the mystical chest!\n[color=yellow]Crafting speed bonus has been applied for 15 minutes![/color]
mining_bonus=__1__ unlocked the last missing piece for the mystical chest!\n[color=yellow]Mining speed bonus has been applied for 15 minutes![/color]
crafting_bonus=__1__ unlocked the last missing piece for the mystical chest!\n[color=yellow]Crafting speed bonus has been applied for 30 minutes![/color]
mining_bonus=__1__ unlocked the last missing piece for the mystical chest!\n[color=yellow]Mining speed bonus has been applied for 30 minutes![/color]
mining_bonus_end=Mining speed bonus has ended!
crafting_bonus_end=Crafting speed bonus has ended!
movement_bonus=__1__ unlocked the last missing piece for the mystical chest!\n[color=yellow]Movement speed bonus has been applied for 15 minutes![/color]
movement_bonus=__1__ unlocked the last missing piece for the mystical chest!\n[color=yellow]Movement speed bonus has been applied for 30 minutes![/color]
movement_bonus_end=Movement speed bonus has ended!
coin_bonus=__1__ unlocked the last missing piece for the mystical chest!\n[color=yellow]Coins has been distributed![/color]
xp_bonus=__1__ unlocked the last missing piece for the mystical chest!\n[color=yellow]XP has been granted to Global pool![/color]

View File

@@ -415,7 +415,7 @@ function Public.move_players(current_task)
end
local starting_planet = Public.get_planet()
current_task.message = 'Moved players to initial surface!'
current_task.delay = game.tick + 100
current_task.delay = game.tick + 1
current_task.state_id = 1
current_task.starting_planet = starting_planet
current_task.state = 'pre_init_task'
@@ -425,6 +425,12 @@ function Public.pre_init_task(current_task)
local this = Public.get()
game.speed = 1
local active_surface_index = Public.get('active_surface_index')
local surface = game.surfaces[active_surface_index]
if surface and surface.valid then
game.delete_surface(surface.name)
end
current_task.done = nil
current_task.step = 1
@@ -541,9 +547,10 @@ end
function Public.clear_fortress(current_task)
local surface = game.surfaces[current_task.starting_planet]
if surface then
surface.clear()
surface.request_to_generate_chunks({ x = -20, y = -22 }, 1)
surface.force_generate_chunk_requests()
game.delete_surface(surface.name)
-- surface.request_to_generate_chunks({ x = -20, y = -22 }, 1)
-- surface.force_generate_chunk_requests()
Public.set('active_surface_index', nil)
end
current_task.state = 'create_custom_fortress_surface'
@@ -553,11 +560,7 @@ function Public.clear_fortress(current_task)
end
function Public.create_custom_fortress_surface(current_task)
local fortress = game.surfaces[current_task.starting_planet]
if fortress then
fortress.clear()
end
Public.set('active_surface_index', Public.create_surface())
Public.set('active_surface_index', Public.create_surface(true))
local active_surface_index = Public.get('active_surface_index')
WD.set('surface_index', active_surface_index)
@@ -788,8 +791,7 @@ function Public.to_fortress(current_task)
local adjusted_zones = Public.get('adjusted_zones')
local position
local wd = WD.get()
wd.game_lost = false
WD.set('game_lost', false)
if adjusted_zones.reversed then
game.forces.player.set_spawn_position({ -27, -25 }, surface)

View File

@@ -144,18 +144,20 @@ function Public.soft_reset_map(old_surface)
this.soft_reset_counter = this.soft_reset_counter + 1
local surface = old_surface or game.surfaces.fortress
surface.clear(true)
-- surface.request_to_generate_chunks({ 0, 0 }, 1)
-- surface.force_generate_chunk_requests()
if surface and surface.valid then
surface.clear(true)
-- surface.request_to_generate_chunks({ 0, 0 }, 1)
-- surface.force_generate_chunk_requests()
local radius = 512
local area = { { x = -radius, y = -radius }, { x = radius, y = radius } }
for _, entity in pairs(surface.find_entities_filtered { area = area, type = 'logistic-robot' }) do
entity.destroy()
end
local radius = 512
local area = { { x = -radius, y = -radius }, { x = radius, y = radius } }
for _, entity in pairs(surface.find_entities_filtered { area = area, type = 'logistic-robot' }) do
entity.destroy()
end
for _, entity in pairs(surface.find_entities_filtered { area = area, type = 'construction-robot' }) do
entity.destroy()
for _, entity in pairs(surface.find_entities_filtered { area = area, type = 'construction-robot' }) do
entity.destroy()
end
end
local message = table.concat({ mapkeeper .. ' Welcome to Mtn Fortress!' })

View File

@@ -31,7 +31,7 @@ local function exclude_surface(surface, state)
end
function Public.create_surface()
function Public.create_surface(recreate)
exclude_surface(game.surfaces.nauvis)
local map_gen_settings =
@@ -72,7 +72,7 @@ function Public.create_surface()
local planets = Public.get_planets()
if Public.is_modded then
if not this.active_surface_index then
if not this.active_surface_index or recreate then
this.active_surface_index = game.planets[starting_planet].create_surface().index
else
this.active_surface_index = Public.soft_reset_map(game.surfaces[starting_planet], map_gen_settings).index

View File

@@ -745,6 +745,7 @@ function Public.reset_main_table()
table.insert(corpses_raffle, e.name)
end
end
this.corpses_raffle = corpses_raffle
for _, planet in pairs(game.planets) do
local platforms = planet.get_space_platforms('player')
@@ -759,7 +760,6 @@ function Public.reset_main_table()
end
end
this.corpses_raffle = corpses_raffle
this.enforce_wave_200_before_collapse = true

View File

@@ -27,9 +27,7 @@ local function call_handlers(handlers, event)
for i = 1, #handlers do
if _DEBUG then
local handler = handlers[i]
if handler then
handler(event)
end
handler(event)
else
xpcall(handlers[i], handler_error, event)
end