From 28f5f81288ca4dbec2e533fa62e3e05da5a1c61f Mon Sep 17 00:00:00 2001 From: Mahtra Date: Mon, 28 Oct 2024 13:10:38 +1300 Subject: [PATCH 1/3] [chore] Comment out un-used def, and add other comments --- lib/xmlparser.rb | 47 +++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/lib/xmlparser.rb b/lib/xmlparser.rb index 5c3cdd52d..2195bbd38 100644 --- a/lib/xmlparser.rb +++ b/lib/xmlparser.rb @@ -47,7 +47,7 @@ class XMLParser def initialize @buffer = String.new - @unescape = { 'lt' => '<', 'gt' => '>', 'quot' => '"', 'apos' => "'", 'amp' => '&' } + # @unescape = { 'lt' => '<', 'gt' => '>', 'quot' => '"', 'apos' => "'", 'amp' => '&' } @bold = false @active_tags = Array.new @active_ids = Array.new @@ -188,25 +188,25 @@ def make_scar_gsl @scar_gsl = sprintf("0b0%02b%02b%02b%02b%02b%02b%02b%02b%02b%02b%02b%02b%02b%02b", @injuries['nsys']['scar'], @injuries['leftEye']['scar'], @injuries['rightEye']['scar'], @injuries['back']['scar'], @injuries['abdomen']['scar'], @injuries['chest']['scar'], @injuries['leftHand']['scar'], @injuries['rightHand']['scar'], @injuries['leftLeg']['scar'], @injuries['rightLeg']['scar'], @injuries['leftArm']['scar'], @injuries['rightArm']['scar'], @injuries['neck']['scar'], @injuries['head']['scar']) end - def parse(line) - @buffer.concat(line) - loop { - if (str = @buffer.slice!(/^[^<]+/)) - text(str.gsub(/&(lt|gt|quot|apos|amp)/) { @unescape[$1] }) - elsif (str = @buffer.slice!(/^<\/[^<]+>/)) - element = /^<\/([^\s>\/]+)/.match(str).captures.first - tag_end(element) - elsif (str = @buffer.slice!(/^<[^<]+>/)) - element = /^<([^\s>\/]+)/.match(str).captures.first - attributes = Hash.new - str.scan(/([A-z][A-z0-9_\-]*)=(["'])(.*?)\2/).each { |attr| attributes[attr[0]] = attr[2] } - tag_start(element, attributes) - tag_end(element) if str =~ /\/>$/ - else - break - end - } - end + # def parse(line) + # @buffer.concat(line) + # loop { + # if (str = @buffer.slice!(/^[^<]+/)) + # text(str.gsub(/&(lt|gt|quot|apos|amp)/) { @unescape[$1] }) + # elsif (str = @buffer.slice!(/^<\/[^<]+>/)) + # element = /^<\/([^\s>\/]+)/.match(str).captures.first + # tag_end(element) + # elsif (str = @buffer.slice!(/^<[^<]+>/)) + # element = /^<([^\s>\/]+)/.match(str).captures.first + # attributes = Hash.new + # str.scan(/([A-z][A-z0-9_\-]*)=(["'])(.*?)\2/).each { |attr| attributes[attr[0]] = attr[2] } + # tag_start(element, attributes) + # tag_end(element) if str =~ /\/>$/ + # else + # break + # end + # } + # end DECADE = 10 * 31_536_000 @@ -227,6 +227,8 @@ def parse_psm3_progressbar(kind, attributes) PSM_3_DIALOG_IDS = ["Buffs", "Active Spells", "Debuffs", "Cooldowns"] def tag_start(name, attributes) + # This is called once per element by REXML + # https://ruby-doc.org/stdlib-2.6.1/libdoc/rexml/rdoc/REXML/StreamListener.html begin @active_tags.push(name) @active_ids.push(attributes['id'].to_s) @@ -613,6 +615,8 @@ def tag_start(name, attributes) end def text(text_string) + # This is called once per element with text in it by REXML + # https://ruby-doc.org/stdlib-2.6.1/libdoc/rexml/rdoc/REXML/StreamListener.html begin # fixme: /.*?<\/stream>/m # $_CLIENT_.write(text_string) unless ($frontend != 'suks') or (@current_stream =~ /^(?:spellfront|inv|bounty|society)$/) or @active_tags.any? { |tag| tag =~ /^(?:compDef|inv|component|right|left|spell)$/ } or (@active_tags.include?('stream') and @active_ids.include?('Spells')) or (text_string == "\n" and (@last_tag =~ /^(?:popStream|prompt|compDef|dialogData|openDialog|switchQuickBar|component)$/)) @@ -781,6 +785,9 @@ def text(text_string) end def tag_end(name) + # This is called once per element by REXML + # https://ruby-doc.org/stdlib-2.6.1/libdoc/rexml/rdoc/REXML/StreamListener.html + begin if @game =~ /^DR/ if name == 'compass' and $nav_seen From 0599a28a7acbd6223249626ce3827b57d0e37851 Mon Sep 17 00:00:00 2001 From: Mahtra Date: Mon, 28 Oct 2024 13:15:19 +1300 Subject: [PATCH 2/3] in games.rb --- lib/xmlparser.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/xmlparser.rb b/lib/xmlparser.rb index 2195bbd38..6156568c1 100644 --- a/lib/xmlparser.rb +++ b/lib/xmlparser.rb @@ -227,7 +227,7 @@ def parse_psm3_progressbar(kind, attributes) PSM_3_DIALOG_IDS = ["Buffs", "Active Spells", "Debuffs", "Cooldowns"] def tag_start(name, attributes) - # This is called once per element by REXML + # This is called once per element by REXML in games.rb # https://ruby-doc.org/stdlib-2.6.1/libdoc/rexml/rdoc/REXML/StreamListener.html begin @active_tags.push(name) @@ -615,7 +615,7 @@ def tag_start(name, attributes) end def text(text_string) - # This is called once per element with text in it by REXML + # This is called once per element with text in it by REXML in games.rb # https://ruby-doc.org/stdlib-2.6.1/libdoc/rexml/rdoc/REXML/StreamListener.html begin # fixme: /.*?<\/stream>/m @@ -785,7 +785,7 @@ def text(text_string) end def tag_end(name) - # This is called once per element by REXML + # This is called once per element by REXML in games.rb # https://ruby-doc.org/stdlib-2.6.1/libdoc/rexml/rdoc/REXML/StreamListener.html begin From e30e280ddf15786ed2524d132c2f2586a5c96c03 Mon Sep 17 00:00:00 2001 From: Mahtra Date: Tue, 29 Oct 2024 08:46:15 +1300 Subject: [PATCH 3/3] [games][dr] Add DR requires here --- lich.rbw | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/lich.rbw b/lich.rbw index 099d7fc83..83971b7ca 100755 --- a/lich.rbw +++ b/lich.rbw @@ -57,17 +57,23 @@ for arg in ARGV end end -require 'time' -require 'socket' +require 'base64' +require 'digest/md5' +require 'digest/sha1' +require 'drb/drb' +require 'json' +require 'monitor' +require 'net/http' +require 'ostruct' +require 'resolv' require 'rexml/document' require 'rexml/streamlistener' +require 'socket' require 'stringio' -require 'zlib' -require 'drb/drb' -require 'resolv' -require 'digest/md5' -require 'json' require 'terminal-table' +require 'time' +require 'yaml' +require 'zlib' # TODO: Move all local requires to top of file if defined? LIB_DIR