From 8f1bd0e00275cdf6e4612a007315b47629e4fddf Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Sat, 7 Sep 2024 22:16:13 +0100 Subject: [PATCH] fix bug with crew not disbanding after loss --- locale/en/pirates.cfg | 2 +- maps/pirates/common.lua | 6 +++--- maps/pirates/crew.lua | 13 ++++++++----- maps/pirates/main.lua | 2 +- maps/pirates/memory.lua | 1 + 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/locale/en/pirates.cfg b/locale/en/pirates.cfg index a3f5ebe0..2711f7eb 100644 --- a/locale/en/pirates.cfg +++ b/locale/en/pirates.cfg @@ -105,7 +105,7 @@ ship_set_off_to_next_island=[font=heading-1]Ship set sail[/font] for the next de crew_continue_on_freeplay=The run now continues on 'Freeplay'. victory_continue_reminder=If you wish to continue the game, click up top. -crew_disband_tick_message=The crew will disband in 20 seconds. +crew_disband_tick_message=The crew will disband in 30 seconds. protected_run_lock_expired=Protection of __1__ crew has expired. Captain role will not be locked anymore when the captain leaves. private_run_lock_expired=Private lock of __1__ crew has expired. Anyone can join this crew now. diff --git a/maps/pirates/common.lua b/maps/pirates/common.lua index 999fe30c..978c0d03 100644 --- a/maps/pirates/common.lua +++ b/maps/pirates/common.lua @@ -24,10 +24,10 @@ Public.private_run_cap = 2 Public.protected_run_cap = 2 -- more precisely protected, but not private run cap Public.minimumCapacitySliderValue = 1 Public.minimum_run_capacity_to_enforce_space_for = 22 + -- auto-disbanding when there are no players left in the crew: -Public.autodisband_ticks = nil --- Public.autodisband_ticks = 30*60*60 --- Public.autodisband_ticks = 30 --the reason this is low is because the comfy server runs very slowly when no-one is on it +-- Public.autodisband_ticks = nil +Public.autodisband_ticks = 60 * 60 * 60 * 24 * 3 -- should not be zero (as this messes with saving and loading a game, which boots the player for a moment.) Also note that the server may run very slowly when no-one is on it. Public.boat_steps_at_a_time = 1 diff --git a/maps/pirates/crew.lua b/maps/pirates/crew.lua index db9ac67d..257a0f43 100644 --- a/maps/pirates/crew.lua +++ b/maps/pirates/crew.lua @@ -135,6 +135,7 @@ function Public.try_lose(loss_reason) memory.game_lost = true memory.crew_disband_tick_message = game.tick + 60*10 memory.crew_disband_tick = game.tick + 60*40 + memory.crew_disband_tick_cannot_be_prevented = true local playtimetext = Utils.time_longform((memory.age or 0)/60) @@ -427,8 +428,8 @@ function Public.join_crew(player, rejoin) Roles.confirm_captain_exists(player) end - if #Common.crew_get_crew_members() == 1 and memory.crew_disband_tick then - memory.crew_disband_tick = nil --to prevent disbanding the crew after saving the game (booting everyone) and loading it again (joining the crew as the only member) + if #Common.crew_get_crew_members() == 1 and memory.crew_disband_tick and not memory.crew_disband_tick_cannot_be_prevented then + memory.crew_disband_tick = nil end if memory.overworldx > 0 then @@ -511,11 +512,13 @@ function Public.leave_crew(player, to_lobby, quiet) Roles.player_left_so_redestribute_roles(player) if #Common.crew_get_crew_members() == 0 then - if Common.autodisband_ticks then + local exists_disband_tick = memory.crew_disband_tick and memory.crew_disband_trick > game.tick + + if Common.autodisband_ticks and not exists_disband_tick then memory.crew_disband_tick = game.tick + Common.autodisband_ticks end - -- memory.crew_disband_tick = game.tick + 60*60*2 --give players time to log back in after a crash or save - if _DEBUG then memory.crew_disband_tick = game.tick + 30*60*60 end + + -- if _DEBUG then memory.crew_disband_tick = game.tick + 30*60*60 end end end diff --git a/maps/pirates/main.lua b/maps/pirates/main.lua index d3af3525..201ae800 100644 --- a/maps/pirates/main.lua +++ b/maps/pirates/main.lua @@ -271,7 +271,7 @@ local function crew_tick() if memory.crew_disband_tick_message < tick then memory.crew_disband_tick_message = nil - local message1 = { 'pirates.crew_disband_tick_message', 30 } + local message1 = { 'pirates.crew_disband_tick_message' } Common.notify_force(memory.force, message1) diff --git a/maps/pirates/memory.lua b/maps/pirates/memory.lua index 80ff0164..794957ee 100644 --- a/maps/pirates/memory.lua +++ b/maps/pirates/memory.lua @@ -102,6 +102,7 @@ function Public.initialise_crew_memory(id) --mostly serves as a dev reference of memory.game_lost = false memory.game_won = false memory.crew_disband_tick = nil + memory.crew_disband_tick_cannot_be_prevented = nil memory.destinationsvisited_indices = nil memory.overworldx = nil memory.overworldy = nil