diff --git a/scripts/autostart.lic b/scripts/autostart.lic index 5d33d4919..d3ea1bba0 100644 --- a/scripts/autostart.lic +++ b/scripts/autostart.lic @@ -9,10 +9,13 @@ contributors: Athias game: any tags: core - version: 0.71 + version: 0.72 required: Lich >= 4.6.58 changelog: + 0.72 (2026-05-27): + remove legacy DR dependency path (dependency.lic enforces 5.17.2 for DR) + keep respond_to? guards for GS backward compatibility on older lich 0.71 (2026-05-07): Force population of Account.subscription for newer Lich5 when using non-Lich authentication 0.70 (2026-05-07): @@ -150,50 +153,19 @@ if script.vars.empty? end # Check for Lich5 updates and announce if available - if Gem::Version.new(LICH_VERSION) > Gem::Version.new('5.6.2') + if defined?(Lich::Util::Update) Lich::Util::Update.request("--announce") end - # DR: load dependency before other scripts. - # dependency.lic defines the parse_args() bridge that DR scripts need. + # DR: load dependency for its runtime helpers (bankbot, slackbot, hometown). + # Core lich 5.17.2+ provides parse_args, get_settings, map overrides natively. if XMLData.game =~ /^DR/ - if respond_to?(:start_scripts_if_available, true) - Script.run('dependency') if Script.exists?('dependency') && !Script.running?('dependency') - did_something = true - else - # Legacy path: dependency.lic handles everything (script sync, autostarts, map edits) - begin - did_dependency_install = Lich.db.get_first_value("SELECT value FROM lich_settings WHERE name='did_dependency_install';") - rescue SQLite3::BusyException - sleep 0.1 - retry - end - if did_dependency_install.nil? - unless File.exist?("#{SCRIPT_DIR}/dependency.lic") - _respond Lich::Messaging.monsterbold("DR First run detected. Downloading dependency.") - Script.run('repository', 'download dependency') - sleep 1 - end - unless File.exist?("#{SCRIPT_DIR}/hunting-buddy.lic") && File.exist?("#{SCRIPT_DIR}/combat-trainer.lic") && File.exist?("#{SCRIPT_DIR}/get2.lic") && File.exist?("#{SCRIPT_DIR}/dependency.lic") - _respond Lich::Messaging.monsterbold("DR First run detected. Performing dependency install. - Please wait until the process finishes completely before proceeding.") - sleep 0.5 - Script.run('dependency', 'install') - end - begin - Lich.db.execute("INSERT INTO lich_settings(name,value) VALUES('did_dependency_install', 'yes');") - rescue SQLite3::BusyException - sleep 0.1 - retry - end - else - Script.start('dependency') unless Script.running?('dependency') - sleep 1 - end - end + Script.run('dependency') if Script.exists?('dependency') && !Script.running?('dependency') + did_something = true end # YAML-based autostarts, UserVars autostarts, and wayto overrides. - # Game-agnostic -- requires modern Lich with get_settings support. + # Guarded for GS backward compatibility on lich < 5.17. if respond_to?(:get_settings, true) UserVars.autostart_scripts ||= [] all_autostarts = (UserVars.autostart_scripts.to_a + @@ -222,7 +194,7 @@ if script.vars.empty? for script_info in script_list if ['infomon', 'repository', 'dependency'].include?(script_info[:name]) next - elsif script_info[:name] == 'lich5-update' && Gem::Version.new(LICH_VERSION) > Gem::Version.new('5.6.2') + elsif script_info[:name] == 'lich5-update' && defined?(Lich::Util::Update) next elsif script_info[:name] == 'dependency' && XMLData.game =~ /^DR/ respond "\n--- dependency found in autostart list. Attempting to remove it now. If unsuccessful, it can be safely removed with '#{$clean_lich_char}autostart remove --global dependency'" diff --git a/spec/autostart/autostart_spec.rb b/spec/autostart/autostart_spec.rb index edfb4f8b7..fd103a688 100644 --- a/spec/autostart/autostart_spec.rb +++ b/spec/autostart/autostart_spec.rb @@ -123,13 +123,13 @@ def reset! # -- Helper that mirrors the game-agnostic YAML autostart loop ------------ -# Replicates lines 137-158 of autostart.lic. +# Replicates the YAML autostart loop of autostart.lic. # # @param script_mod [Module] mock for Script (running?, exists?, start) # @param map_mod [Module] mock for Map (apply_wayto_overrides) # @param user_vars_mod [Module] mock for UserVars (autostart_scripts) # @param yaml_autostarts [Array, nil] simulated get_settings.autostarts -# @param has_get_settings [Boolean] whether get_settings is available +# @param has_get_settings [Boolean] whether get_settings is available (false on old GS lich) # @param respond_output [Array] collects warning messages # @return [Array, nil] list of started script names, or nil if skipped def run_yaml_autostart_loop(script_mod: MockScript, @@ -177,7 +177,7 @@ def run_generic_autostart_loop(settings_mod: MockSettings, char_settings_mod: MockCharSettings, script_mod: MockScript, xml_data_mod: MockXMLData, - lich_version: "5.7.0", + has_lich_update: true, respond_output: []) for script_list in [settings_mod['scripts'], char_settings_mod['scripts']] if script_list.is_a?(Array) @@ -200,8 +200,7 @@ def run_generic_autostart_loop(settings_mod: MockSettings, end end next - elsif script_info[:name] == 'lich5-update' && - Gem::Version.new(lich_version) > Gem::Version.new('5.6.2') + elsif script_info[:name] == 'lich5-update' && has_lich_update next else next if script_mod.running?(script_info[:name]) @@ -326,12 +325,19 @@ def run_generic_autostart_loop(settings_mod: MockSettings, expect(MockScript.started).to be_empty end - it "skips lich5-update when LICH_VERSION > 5.6.2" do + it "skips lich5-update when Lich::Util::Update is available" do MockSettings['scripts'] = [{ name: 'lich5-update', args: [] }] - run_generic_autostart_loop(lich_version: "5.7.0") + run_generic_autostart_loop(has_lich_update: true) expect(MockScript.started).to be_empty end + + it "does not skip lich5-update on old lich without Lich::Util::Update" do + MockSettings['scripts'] = [{ name: 'lich5-update', args: [] }] + + run_generic_autostart_loop(has_lich_update: false) + expect(MockScript.started).to eq([{ name: 'lich5-update', args: [] }]) + end end describe "DR dependency removal" do @@ -396,7 +402,7 @@ def run_generic_autostart_loop(settings_mod: MockSettings, expect(started).to eq(['esp', 'afk']) end - it "does nothing when get_settings is not available" do + it "does nothing when get_settings is not available (old GS lich)" do started = run_yaml_autostart_loop(yaml_autostarts: ['esp'], has_get_settings: false) expect(started).to be_nil end