Log in

View Full Version : Ruby 1.9.1 and Lich



BigWorm
01-29-2011, 04:12 PM
I recently upgraded my ubuntu netbook from Ruby 1.87 to 1.9.1. First of all, the performance improvements are immediately obvious. Previously with 1.8.7, when I would log in, I would have to wait nearly a minute for all my favorites to finish running and the full lich environment to start. Now, it is only a matter of a few seconds. I rarely see ruby using more than 10% CPU now, whereas in the past it was constantly redlining the processor.

While I had to compile the gnome2/gtk2 bindings myself to get the GUI stuff to work, this wasn't that much of a problem. Now, the lich GUI, narost, bigshot, etc all work great. My only problem is that UberBarWiz is broken and doesn't work at all.

I looked into UberBarWiz and it appears the problem is caused by uberbarwiz relying on a behavior of eval that has changed. Previously, local variables could be defined inside an eval and were thereafter available throughout the calling scope. However, in Ruby 1.9.1, a design decision was made to isolate the scrope of evals. So now a variable defined inside an eval only exists during that eval and cannot be referenced after the eval call. This breaks code like this:



setupprogress.each do |progress|
eval("uberBar_progress_#{progress[0]} = Gtk::ProgressBar.new")
eval("uberBar_progress_style_#{progress[0]} = Gtk::Style.new")
eval("uberBar_progress_style_#{progress[0]}.set_bg(Gtk::STATE_NORMAL, #{progress[2].join('*255, ')}*255)")
eval("uberBar_progress_style_#{progress[0]}.set_fg(Gtk::STATE_NORMAL, #{progress[3].join('*255, ')}*255)")
eval("uberBar_progress_style_#{progress[0]}.set_bg(Gtk::STATE_PRELIGHT, #{progress[4].join('*255, ')}*255)")
eval("uberBar_progress_style_#{progress[0]}.set_fg(Gtk::STATE_PRELIGHT, #{progress[5].join('*255, ')}*255)")
eval("uberBar_progress_#{progress[0]}.set_style uberBar_progress_style_#{progress[0]}")
eval("uberBar_progress_#{progress[0]}.height_request = #{progress[1][3]}")
eval("uberBar_progress_#{progress[0]}.width_request = #{progress[1][2]}")
eval("uberBar_layout.put(uberBar_progress_#{progress[0]}, #{progress[1][0]}, #{progress[1][1]})")
end


since it expects the variables it defines like uberBar_progress_exp to be available throughout the script. Unfortunately, similar code blocks are found through uberbarwiz, so it will require some surgery to get working in 1.9.1.

I fixed two eval blocks and that seems to have taken care of the issue. I have tested with Ruby 1.8.7 and 1.9.1 with a couple different characters on a couple different machines, but it wouldn't hurt to get some more testing before I try to get this into the repo.

Beyond this problem with uberbarwiz and the string issue with Windows and 1.9.1, did anyone have any other problems with Ruby 1.9.1 and Lich?

BigWorm
01-29-2011, 04:20 PM
Updated uberbarwiz:


=begin

So I was thinkin to myself the other day,
'Hey, I want an uberbar for Wizard, and I think other people do too.'
So here it is. Stay classy San Diego.
;e fizzle = File.open("#{$lich_dir}IconDEAD.png", 'rb') ; respond [fizzle.read].pack('m').gsub("\n", "")

=end

if $SAFE > 0
echo "error: This script needs to be trusted to work. (;trust #{script.name.downcase})"
exit
end

no_kill_all
no_pause_all
hide_me
debug = false
wait_while { XMLData.next_level_text !~ /(experience|until next level)/ or !XMLData.next_level_value.integer? }
#$test_nlt = "10000000 experience"

#defining all my variables... I hate variables... there's - too many of them!
window_close = false

uberBar_label_table = uberBar_layout = uberBar_damage = uberBar_table = uberBar = done = window_close = nil
uberBar_damage_nsys_w1 = uberBar_damage_leftArm_w1 = uberBar_damage_rightArm_w1 = uberBar_damage_rightLeg_w1 = uberBar_damage_leftLeg_w1 = uberBar_damage_head_w1 = uberBar_damage_rightFoot_w1 = uberBar_damage_leftFoot_w1 = uberBar_damage_rightHand_w1 = uberBar_damage_leftHand_w1 = uberBar_damage_rightEye_w1 = uberBar_damage_leftEye_w1 = uberBar_damage_back_w1 = uberBar_damage_neck_w1 = uberBar_damage_chest_w1 = uberBar_damage_abdomen_w1 = nil
uberBar_damage_nsys_w2 = uberBar_damage_leftArm_w2 = uberBar_damage_rightArm_w2 = uberBar_damage_rightLeg_w2 = uberBar_damage_leftLeg_w2 = uberBar_damage_head_w2 = uberBar_damage_rightFoot_w2 = uberBar_damage_leftFoot_w2 = uberBar_damage_rightHand_w2 = uberBar_damage_leftHand_w2 = uberBar_damage_rightEye_w2 = uberBar_damage_leftEye_w2 = uberBar_damage_back_w2 = uberBar_damage_neck_w2 = uberBar_damage_chest_w2 = uberBar_damage_abdomen_w2 = nil
uberBar_damage_nsys_w3 = uberBar_damage_leftArm_w3 = uberBar_damage_rightArm_w3 = uberBar_damage_rightLeg_w3 = uberBar_damage_leftLeg_w3 = uberBar_damage_head_w3 = uberBar_damage_rightFoot_w3 = uberBar_damage_leftFoot_w3 = uberBar_damage_rightHand_w3 = uberBar_damage_leftHand_w3 = uberBar_damage_rightEye_w3 = uberBar_damage_leftEye_w3 = uberBar_damage_back_w3 = uberBar_damage_neck_w3 = uberBar_damage_chest_w3 = uberBar_damage_abdomen_w3 = nil
uberBar_damage_nsys_s1 = uberBar_damage_leftArm_s1 = uberBar_damage_rightArm_s1 = uberBar_damage_rightLeg_s1 = uberBar_damage_leftLeg_s1 = uberBar_damage_head_s1 = uberBar_damage_rightFoot_s1 = uberBar_damage_leftFoot_s1 = uberBar_damage_rightHand_s1 = uberBar_damage_leftHand_s1 = uberBar_damage_rightEye_s1 = uberBar_damage_leftEye_s1 = uberBar_damage_back_s1 = uberBar_damage_neck_s1 = uberBar_damage_chest_s1 = uberBar_damage_abdomen_s1 = nil
uberBar_damage_nsys_s2 = uberBar_damage_leftArm_s2 = uberBar_damage_rightArm_s2 = uberBar_damage_rightLeg_s2 = uberBar_damage_leftLeg_s2 = uberBar_damage_head_s2 = uberBar_damage_rightFoot_s2 = uberBar_damage_leftFoot_s2 = uberBar_damage_rightHand_s2 = uberBar_damage_leftHand_s2 = uberBar_damage_rightEye_s2 = uberBar_damage_leftEye_s2 = uberBar_damage_back_s2 = uberBar_damage_neck_s2 = uberBar_damage_chest_s2 = uberBar_damage_abdomen_s2 = nil
uberBar_damage_nsys_s3 = uberBar_damage_leftArm_s3 = uberBar_damage_rightArm_s3 = uberBar_damage_rightLeg_s3 = uberBar_damage_leftLeg_s3 = uberBar_damage_head_s3 = uberBar_damage_rightFoot_s3 = uberBar_damage_leftFoot_s3 = uberBar_damage_rightHand_s3 = uberBar_damage_leftHand_s3 = uberBar_damage_rightEye_s3 = uberBar_damage_leftEye_s3 = uberBar_damage_back_s3 = uberBar_damage_neck_s3 = uberBar_damage_chest_s3 = uberBar_damage_abdomen_s3 = nil
uberBar_label_lxplogin = uberBar_label_lxptotal = uberBar_label_lxppulse = uberBar_label_lroomnum = uberBar_label_xplogin = uberBar_label_xptotal = uberBar_label_xppulse = uberBar_label_roomnum = nil
uberBar_label_align_lxplogin = uberBar_label_align_lxptotal = uberBar_label_align_lxppulse = uberBar_label_align_lroomnum = uberBar_label_align_xplogin = uberBar_label_align_xptotal = uberBar_label_align_xppulse = uberBar_label_roomnum = nil
uberBar_progress_pulse = uberBar_progress_health = uberBar_progress_mana = uberBar_progress_stamina = uberBar_progress_spirit = uberBar_progress_exp = uberBar_progress_mind = uberBar_progress_stance = uberBar_progress_encumb = uberBar_progress_rthard = uberBar_progress_rtcast = nil
uberBar_status_IconSITTING = uberBar_status_IconKNEELING = uberBar_status_IconPRONE = uberBar_status_IconSTANDING = uberBar_status_IconBLEEDING = uberBar_status_IconDEAD = uberBar_status_IconDISEASED = uberBar_status_IconHIDDEN = uberBar_status_IconINVISIBLE = uberBar_status_IconJOINED = uberBar_status_IconPOISONED = uberBar_status_IconSTUNNED = uberBar_status_IconWEBBED = nil
oldHP = oldMP = oldST = oldSP = oldXP = oldMD = oldSN = oldEN = oldIN = oldWO = oldRTs = oldCTs = nowRT = nowCT = oldRM = oldSS = nil
oldRT = oldCT = 0
image_dir = "#{$lich_dir}data#{File::Separator}uberBarWiz#{File ::Separator}"
Dir::mkdir(image_dir) unless File.exists?(image_dir)

# Pre-define more variable since we can't do so in eval block in ruby 1.9+
uberBar_progress_style_rthard = uberBar_progress_style_rtcast = uberBar_progress_style_health = uberBar_progress_style_mana = uberBar_progress_style_stamina = nil
uberBar_progress_style_spirit = uberBar_progress_style_exp = uberBar_progress_style_mind = uberBar_progress_style_stance = uberBar_progress_style_encumb = nil

Settings.load
if variable[2]
Settings[Char.name] = {}
Settings[Char.name]['window_width'] = 167
Settings[Char.name]['window_height'] = 216
Settings[Char.name]['window_position'] = [0, 0]
Settings[Char.name]["health_file"] = variable[1]
Settings[Char.name]["health_locs"] = variable[2]
exit
end

Settings[Char.name] ||= {}
Settings[Char.name]['window_width'] ||= 167
Settings[Char.name]['window_height'] ||= 216
Settings[Char.name]['window_position'] ||= [0, 0]
Settings[Char.name]["health_file"] ||= "#{image_dir}Health.bmp"
Settings[Char.name]["health_locs"] ||= {"leftEye" => [15, 3], "rightEye" => [50, 3], "head" => [33, 28], "neck" => [33, 43], "chest" => [33, 58], "abdomen" => [33, 71], "leftArm" => [12, 43], "rightArm" => [54, 43], "leftHand" => [8, 20], "rightHand" => [56, 20], "leftLeg" => [23, 101], "rightLeg" => [43, 101], "back" => [6, 77], "nsys" => [59, 77], "leftFoot" => [51, 127], "rightFoot" => [16, 127]}

window_width = Settings[Char.name]['window_width']
window_height = Settings[Char.name]['window_height']
window_position = Settings[Char.name]['window_position']
health_file = Settings[Char.name]['health_file']
health_locs = Settings[Char.name]['health_locs']
wound1_file = "#{image_dir}Wound1.png"
wound2_file = "#{image_dir}Wound2.png"
wound3_file = "#{image_dir}Wound3.png"
scar1_file = "#{image_dir}Scar1.png"
scar2_file = "#{image_dir}Scar2.png"
scar3_file = "#{image_dir}Scar3.png"
statusBAR_file = "#{image_dir}StatusBAR.png"
iconSITTING_file = "#{image_dir}IconSITTING.png"
iconKNEELING_file = "#{image_dir}IconKNEELING.png"
iconPRONE_file = "#{image_dir}IconPRONE.png"
iconSTANDING_file = "#{image_dir}IconSTANDING.png"
iconBLEEDING_file = "#{image_dir}IconBLEEDING.png"
iconDEAD_file = "#{image_dir}IconDEAD.png"
iconDISEASED_file = "#{image_dir}IconDISEASED.png"
iconHIDDEN_file = "#{image_dir}IconHIDDEN.png"
iconINVISIBLE_file = "#{image_dir}IconINVISIBLE.png"
iconJOINED_file = "#{image_dir}IconJOINED.png"
iconPOISONED_file = "#{image_dir}IconPOISONED.png"
iconSTUNNED_file = "#{image_dir}IconSTUNNED.png"
iconWEBBED_file = "#{image_dir}IconWEBBED.png"

setupwindow = ["window_col", [240,240,240], [ 0, 0, 0]]
#labelname label x y
setuplabel_loc = [81, 160, 14]
setuplabel = [
["lxplogin", "Login: ", "0, 1, 0, 1"],
["xplogin", "", "1, 2, 0, 1"],
["lxptotal", "XP/hr: ", "0, 1, 1, 2"],
["xptotal", "", "1, 2, 1, 2"],
["lxppulse", "Pulse: ", "0, 1, 2, 3"],
["xppulse", "", "1, 2, 2, 3"]]
#name x y w h normal back normal fore prelight back prelight fore
setupprogress_loc = [81, 16]
setupprogress = [
["rthard", [ 80,150-setupprogress_loc[1]*5, 63, setupprogress_loc[1]+3], [ 0, 0, 0], [207, 0, 0], [207, 0, 0], [255,255,255]],
["rtcast", [143,150-setupprogress_loc[1]*5, 25, setupprogress_loc[1]+3], [ 0, 0, 0], [115,159,207], [115,159,207], [255,255,255]],
["health", [ 80,150-setupprogress_loc[1]*4, 88, setupprogress_loc[1]+3], [ 0, 0, 0], [255,255,255], [128, 0, 0], [255,255,255]],
["mana", [ 80,150-setupprogress_loc[1]*3, 88, setupprogress_loc[1]+3], [ 0, 0, 0], [255,255,255], [ 0, 0,255], [255,255,255]],
["stamina", [ 80,150-setupprogress_loc[1]*2, 88, setupprogress_loc[1]+3], [ 0, 0, 0], [255,255,255], [208,152, 57], [255,255,255]],
["spirit", [ 80,150-setupprogress_loc[1]*1, 88, setupprogress_loc[1]+3], [ 0, 0, 0], [255,255,255], [192,192,192], [255,255,255]],
["exp", [ 0,150+setupprogress_loc[1]*0,168, setupprogress_loc[1]+3], [ 0, 0, 0], [255,255,255], [ 0,128, 0], [255,255,255]],
["mind", [ 0,150+setupprogress_loc[1]*1,168, setupprogress_loc[1]+3], [ 0, 0, 0], [255,255,255], [ 0,128, 0], [255,255,255]],
["stance", [ 0,150+setupprogress_loc[1]*2,168, setupprogress_loc[1]+3], [ 0, 0, 0], [255,255,255], [ 0,128, 0], [255,255,255]],
["encumb", [ 0,150+setupprogress_loc[1]*3,168, setupprogress_loc[1]+3], [ 0, 0, 0], [255,255,255], [ 0,128, 0], [255,255,255]]]
setupstatus_bar = ["StatusBAR", 82, 45]
setupstatus = [
["IconSITTING", setupstatus_bar[1]+56, setupstatus_bar[2]+ 2],
["IconKNEELING", setupstatus_bar[1]+56, setupstatus_bar[2]+ 2],
["IconPRONE", setupstatus_bar[1]+56, setupstatus_bar[2]+ 2],
["IconSTANDING", setupstatus_bar[1]+56, setupstatus_bar[2]+ 2],
["IconBLEEDING", setupstatus_bar[1]+ 2, setupstatus_bar[2]+ 6],
["IconDEAD", setupstatus_bar[1]+56, setupstatus_bar[2]+ 2],
["IconDISEASED", setupstatus_bar[1]+11, setupstatus_bar[2]+ 6],
["IconHIDDEN", setupstatus_bar[1]+28, setupstatus_bar[2]+ 2],
["IconINVISIBLE", setupstatus_bar[1]+28, setupstatus_bar[2]+ 2],
["IconJOINED", setupstatus_bar[1]+39, setupstatus_bar[2]+ 2],
["IconPOISONED", setupstatus_bar[1]+11, setupstatus_bar[2]+ 6],
["IconSTUNNED", setupstatus_bar[1]+20, setupstatus_bar[2]+ 6],
["IconWEBBED", setupstatus_bar[1]+ 2, setupstatus_bar[2]+ 2]]

filelist = [health_file, wound1_file, wound2_file, wound3_file, scar1_file, scar2_file, scar3_file, statusBAR_file, iconSITTING_file, iconKNEELING_file, iconPRONE_file, iconSTANDING_file, iconBLEEDING_file, iconDEAD_file, iconDISEASED_file, iconHIDDEN_file, iconINVISIBLE_file, iconJOINED_file, iconPOISONED_file, iconSTUNNED_file, iconWEBBED_file]
filelist.each do |filey|
if !File.exists?(filey)
respond ""
respond "Can't find the files I need"
respond "Download, trust, and run one of the theme packages from the repository"
respond "UBW-theme-sf, -dude or -sexy"
respond ""
exit
end
end

capped = false
capped = true if Char.level == 100 or XMLData.next_level_text =~ /experience/

# XP watcher variables
firstpulse = true
xpnFirstTime = 0 # Time UB was first run
#pause("0.5s")
xpnNLT = xpnCur = xpnOld = xpnHour = xpnLast = xpnTotal = 0 # Zero total xp to start

areas = ["nsys","leftArm","rightArm","rightLeg","leftLeg","head","rightFoot","leftFoot","rightHand","leftHand","rightEye","leftEye","back","neck","chest","abdomen"]
arean = [["s3", "scar3"], ["s2", "scar2"], ["s1", "scar1"], ["w3", "wound3"], ["w2", "wound2"], ["w1", "wound1"]]

done = false
Gtk.queue {

uberBar = Gtk::Window.new
uberBar.title = "#{Char.name}'s Uberbar"
uberBar.signal_connect('delete_event') { window_close = true }
uberBar.border_width = 0

uberBar_layout = Gtk::Layout.new
uberBar_layout_style = Gtk::Style.new
uberBar_layout_style.set_bg(Gtk::STATE_NORMAL, 0, 0, 0)
uberBar_layout.set_style uberBar_layout_style
uberBar.add uberBar_layout

uberBar_label_style = Gtk::Style.new
uberBar_label_style.set_fg(Gtk::STATE_NORMAL, 255*255, 255*255, 255*255)
uberBar_label_table = Gtk::Table.new 3, 2, true
uberBar_layout.put(uberBar_label_table, 81, -2)

setuplabel.each do |label|
eval("uberBar_label_#{label[0]} = Gtk::Label.new(\"#{label[1]}\")")
eval("uberBar_label_align_#{label[0]} = Gtk::Alignment.new 1, 0, 0, 0")
eval("uberBar_label_align_#{label[0]}.add(uberBar_label_#{label[0]})")
eval("uberBar_label_#{label[0]}.set_style uberBar_label_style")
eval("uberBar_label_table.attach(uberBar_label_align_#{l abel[0]}, #{label[2]})")
end

uberBar_damage = Gtk::Image.new(health_file)
uberBar_layout.put(uberBar_damage, 0, 0)

areas.each do |area|
arean.each do |an|
eval("uberBar_damage_#{area}_#{an[0]} = Gtk::Image.new(#{an[1]}_file)")
end
end
areas.each do |area|
arean.each do |an|
eval("uberBar_layout.put(uberBar_damage_#{area}_#{an[0]}, -50, -50)")
end
end

eval("uberBar_layout.put(Gtk::Image.new(\"#{image_dir}#{setupstatus_bar[0]}.png\"), #{setupstatus_bar[1]}, #{setupstatus_bar[2]})")
setupstatus.each do |ss|
eval("uberBar_status_#{ss[0]} = Gtk::Image.new(\"#{image_dir}#{ss[0]}.png\")")
eval("uberBar_layout.put(uberBar_status_#{ss[0]}, -50, -50)")
end

setupprogress.each do |progress|
eval("uberBar_progress_#{progress[0]} = Gtk::ProgressBar.new")
eval("uberBar_progress_style_#{progress[0]} = Gtk::Style.new")
eval("uberBar_progress_style_#{progress[0]}.set_bg(Gtk::STATE_NORMAL, #{progress[2].join('*255, ')}*255)")
eval("uberBar_progress_style_#{progress[0]}.set_fg(Gtk::STATE_NORMAL, #{progress[3].join('*255, ')}*255)")
eval("uberBar_progress_style_#{progress[0]}.set_bg(Gtk::STATE_PRELIGHT, #{progress[4].join('*255, ')}*255)")
eval("uberBar_progress_style_#{progress[0]}.set_fg(Gtk::STATE_PRELIGHT, #{progress[5].join('*255, ')}*255)")
eval("uberBar_progress_#{progress[0]}.set_style uberBar_progress_style_#{progress[0]}")
eval("uberBar_progress_#{progress[0]}.height_request = #{progress[1][3]}")
eval("uberBar_progress_#{progress[0]}.width_request = #{progress[1][2]}")
eval("uberBar_layout.put(uberBar_progress_#{progress[0]}, #{progress[1][0]}, #{progress[1][1]})")
end

uberBar.show_all
uberBar.resize(window_width.to_i, window_height.to_i)
window_position[0] = [[0, window_position[0].to_i].max, (Gdk.screen_width-window_width.to_i)].min
window_position[1] = [[0, window_position[1].to_i].max, (Gdk.screen_height-window_height.to_i)].min
uberBar.move(window_position[0].to_i, window_position[1].to_i)
uberBar.keep_above = true

done = true
}
wait_while { !done }

before_dying {
done = false
Gtk.queue {
window_width = uberBar.allocation.width
window_height = uberBar.allocation.height
window_position = uberBar.position
uberBar.destroy
done = true
}
wait_until { done }
Settings[Char.name]['window_width'] = window_width
Settings[Char.name]['window_height'] = window_height
Settings[Char.name]['window_position'] = window_position if (window_position.class == Array) and (window_position[0].to_i > -5) and (window_position[1].to_i > -5)
Settings.save
}

loop {
wait_while { oldRT.to_i == checkrt.to_i and oldCT.to_i == checkcastrt.to_i and oldSS == XMLData.indicator.to_s and oldHP == checkhealth and oldMP == checkmana and oldST == checkstamina and oldSP == checkspirit and oldXP == XMLData.next_level_text and oldMD == XMLData.mind_text and oldSN == XMLData.stance_text and oldEN == XMLData.encumbrance_text and oldIN == XMLData.injuries.to_s and window_close == false }
if window_close then exit end
nowTime = Time.now
nowRT = checkrt
nowCT = checkcastrt
doLines = ""

if oldHP != checkhealth then echo "updated health" if debug ; oldHP = checkhealth ; doLines += "uberBar_progress_health.fraction = percenthealth/100.0 ; uberBar_progress_health.text = \"#{checkhealth}/#{maxhealth}\" ; " end
if oldMP != checkmana then echo "updated mana" if debug ; oldMP = checkmana ; doLines += "uberBar_progress_mana.fraction = percentmana/100.0 ; uberBar_progress_mana.text = \"#{checkmana}/#{maxmana}\" ; " end
if oldST != checkstamina then echo "updated stamina" if debug ; oldST = checkstamina ; doLines += "uberBar_progress_stamina.fraction = percentstamina/100.0 ; uberBar_progress_stamina.text = \"#{checkstamina}/#{maxstamina}\" ; " end
if oldSP != checkspirit then echo "updated spirit" if debug ; oldSP = checkspirit ; doLines += "uberBar_progress_spirit.fraction = percentspirit/100.0 ; uberBar_progress_spirit.text = \"#{checkspirit}/#{maxspirit}\" ; " end
if oldMD != XMLData.mind_text then echo "updated mind" if debug ; oldMD = XMLData.mind_text ; doLines += "uberBar_progress_mind.fraction = XMLData.mind_value/100.0 ; uberBar_progress_mind.text = XMLData.mind_text ; " end
if oldSN != XMLData.stance_text then echo "updated stance" if debug ; oldSN = XMLData.stance_text ; doLines += "uberBar_progress_stance.fraction = XMLData.stance_value/100.0 ; uberBar_progress_stance.text = XMLData.stance_text ; " end
if oldEN != XMLData.encumbrance_text then echo "updated encumbr" if debug ; oldEN = XMLData.encumbrance_text ; doLines += "uberBar_progress_encumb.fraction = XMLData.encumbrance_value/100.0 ; uberBar_progress_encumb.text = XMLData.encumbrance_text ; " end
if oldRM != Room.current.id then echo "updated room" if debug ; oldRM = Room.current.id ; doLines += "uberBar_label_roomnum.text = #{Room.current.id}.to_s ; " end
if oldRT != nowRT then echo "updated roundtime" if debug
oldRTs = nowRT if oldRTs == 0
oldRTs = 0 if nowRT == 0
doLines += "uberBar_progress_rthard.fraction = #{nowRT/(oldRTs+0.001)} ; uberBar_progress_rthard.text = \"#{(nowRT+0.999).to_i}\" ; "
oldRT = nowRT
end
if oldCT != nowCT then echo "updated cast roundtime" if debug
oldCTs = nowCT if oldCTs == 0
oldCTs = 0 if nowCT == 0
doLines += "uberBar_progress_rtcast.fraction = #{nowCT/(oldCTs+0.001)} ; uberBar_progress_rtcast.text = \"#{(nowCT+0.999).to_i}\" ; "
oldCT = nowCT
end
if oldSS != XMLData.indicator.to_s then echo "updated status" if debug ; oldSS = XMLData.indicator.to_s
setupstatus.each do |ss|
doLines += "uberBar_layout.move(uberBar_status_#{ss[0]}, -50, -50) ; "
if XMLData.indicator[ss[0]] == "y"
doLines += "uberBar_layout.move(uberBar_status_#{ss[0]}, #{ss[1]}, #{ss[2]}) ; "
end
end
end
if oldIN != XMLData.injuries.to_s then echo "updated wounds" if debug ; oldIN = XMLData.injuries.to_s
woundsev = 0
areas.each do |area|
arean.each do |an|
doLines += "uberBar_layout.move(uberBar_damage_#{area}_#{an[0]}, -50, -50) ; "
end
if eval("Wounds.#{area}") > 0 then woundsev = eval("Wounds.#{area}") ; doLines += "uberBar_layout.move(uberBar_damage_#{area}_w#{woun dsev}, health_locs[\"#{area}\"][0], health_locs[\"#{area}\"][1]) ; "
elsif eval("Scars.#{area}") > 0 then woundsev = eval("Scars.#{area}") ; doLines += "uberBar_layout.move(uberBar_damage_#{area}_s#{woun dsev}, health_locs[\"#{area}\"][0], health_locs[\"#{area}\"][1]) ; "
end
end
end
if oldXP != XMLData.next_level_text then echo "updated exper" if debug ; oldXP = XMLData.next_level_text
xpnNLT = XMLData.next_level_text
if xpnNLT =~ /( experience| until next level)/
xpnCur = xpnNLT.delete(' experience').delete(' until next level').to_i
xpnLast = xpnOld - xpnCur
xpnLast *= -1 if xpnLast < 0
xpnLast = 0 if xpnLast > 2499
else
xpnCur = 0
xpnLast = 0
end
if firstpulse
xpnFirstTime = Time.now - 1
xpnTotal = 0
xpnLast = 0
firstpulse = false
end
if capped
xpnCap = (xpnCur / 2500 + 1) * 2500 - xpnCur
xpnValue = (100 - (xpnCap / 25)) / 100.00
xpnText = "#{xpnCap} until TP"
else
xpnValue = XMLData.next_level_value.to_i / 100.00
xpnText = sprintf("Level: %2s %6s TNL", Char.level, xpnCur)
end
xpnTotal += xpnLast
xpnHour = ((1.00 * xpnTotal) / ((nowTime - xpnFirstTime)/3600.00)).to_i
xpnOld = xpnCur
doLines += "uberBar_progress_exp.fraction = xpnValue ; uberBar_progress_exp.text = xpnText ; uberBar_label_xplogin.text = xpnTotal.to_s ; uberBar_label_xptotal.text = xpnHour.to_s ; uberBar_label_xppulse.text = xpnLast.to_s ; "
end

doLines += "done = true"
done = false
Gtk.queue { eval(doLines) }
wait_while { !done }
}

Alorn15
01-30-2011, 12:30 AM
I am sufficiently intrigued by these performance gains.

First make warned about missing libffi and libyaml... Make test passed 900/901 tests. Installed libs and remade. Failed due to lack of bison. Remaking with bison now. Haven't done anything with ruby-gnome2, hoping my previous build is sufficient.

A little bit concerned about the few but steady warnings c is throwing at me. Stuff like this:

_sdbm.c:425: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result

Using Ubuntu 10.10.

UPDATE:


xxxxx@xxxxx-N-A:~/ruby-1.9.2-p136$ bin/irb
Segmentation fault
xxxxx@xxxxx-N-A:~/ruby-1.9.2-p136$

Heh. I'm going to bed. I'll try 1.9.1 tomorrow.

Jace Solo
02-02-2011, 09:25 AM
Will it work fine with SF?


And is this anything I should worry about at present?
[lnet: EOFError]
C:/Program Files (x86)/Ruby-1.9.1/lib/ruby/1.8/openssl/buffering.rb:133:in `readline'
C:/Program Files (x86)/Ruby-1.9.1/lib/ruby/1.8/rexml/source.rb:160:in `initialize'
[lnet: connection lost]
[lnet: waiting 299 seconds before trying to reconnect...]

BigWorm
02-02-2011, 01:23 PM
Will it work fine with SF?


And is this anything I should worry about at present?
[lnet: EOFError]
C:/Program Files (x86)/Ruby-1.9.1/lib/ruby/1.8/openssl/buffering.rb:133:in `readline'
C:/Program Files (x86)/Ruby-1.9.1/lib/ruby/1.8/rexml/source.rb:160:in `initialize'
[lnet: connection lost]
[lnet: waiting 299 seconds before trying to reconnect...]

Not related to Ruby 1.9.1. Problem with the lnet server.

Alorn15
02-06-2011, 12:46 PM
Finally getting back to this thread...

So the night I was segfaulting, it turns out I was being dumb and prefixing the ruby build to be the same directory that I was making it. Dumb.

Fixed that, then ran into the fact that sourceforge was being hacked, and I had trouble snagging the gtk2 gem.

Waited a day, got gtk2 but decided to trash what I had and go with rvm which is pretty sweet for managing multiple ruby environments. Got everything installed and then learned that certain scripts - including my own - aren't compatible with 1.9.2p136.

Didn't feel like doing any more work, so reverted to 1.8.6. When I feel like doing stuff again I'll check out 1.9.1.

Overlordz
02-06-2011, 07:58 PM
Beyond this problem with uberbarwiz and the string issue with Windows and 1.9.1, did anyone have any other problems with Ruby 1.9.1 and Lich?


I'm in the middle of updating mine from 1.8.6 to 1.9.2. I had to change the Lich code for reading/writing to the registry, since the API it was using had changed. (BTW, there's a much easier to use API for reading/writing to the registry than what Lich is using.)

What's this string issue (and what's the fix)? I finally got in the game and see some errors about multibyte characters coming from LNet.

Tillmen
02-06-2011, 08:25 PM
I'm in the middle of updating mine from 1.8.6 to 1.9.2. I had to change the Lich code for reading/writing to the registry, since the API it was using had changed. (BTW, there's a much easier to use API for reading/writing to the registry than what Lich is using.)

What easier way are you talking about? There was something in Ruby 1.8 specifically for dealing with the Windows registry, but I read that it was buggy and was going to be removed in Ruby 1.9.

Overlordz
02-07-2011, 12:24 AM
What easier way are you talking about? There was something in Ruby 1.8 specifically for dealing with the Windows registry, but I read that it was buggy and was going to be removed in Ruby 1.9.

This is what I have:



require 'win32/registry'

def getKeyValue(hive, key_path, key_name)
reg_obj=hive.open(key_path, Win32::Registry::KEY_READ)
begin
reg_typ, reg_val = reg_obj.read(key_name)
rescue Win32::Registry::Error
puts "key not found : #{key_name}"
end
return reg_val
end

def registry_get(key)
captures = /^(\w*)\\(.*)\\(.*)?$/.match(key).captures
hive = captures[0]
if (hive == "HKEY_LOCAL_MACHINE")
hive = Win32::Registry::HKEY_LOCAL_MACHINE
elsif (hive == "HKEY_CURRENT_USER")
hive = Win32::Registry::HKEY_CURRENT_USER
end
path = captures[1]
value = captures[2]
returnValue = getKeyValue(hive, path, value).sub(/\0.*/, '');
return returnValue
end


And you're right, from a quick Google search it's apparently going to be deprecated sooner or later. Though it's still there in 1.9.2, anyway.

In other news, 1.9.2 has broken enough things to where I'll be reverting back to 1.8. I had to comment out LNet's apparent filtering of weird characters (it was that or figure out wtf they've done with encodings), looking in my satchel with 200 items takes forever, the changes to eval have fucked up more than a few scripts...

And really about the only reason I upgraded was in hopes of automagically fixing the lag I get upon connecting to LNet. No such luck.

Joseph
02-08-2011, 08:00 AM
I have not looked into it much but I would guess that w/ rvm installed a simple addition to the base lich script could let you select which version of ruby is used for each script .. if that makes the swap a bit less painful for those on the development end .. aka not having to rewrite all scripts before you can use any.

Alorn15
02-08-2011, 05:11 PM
Lich is a single ruby process, so I don't think it would be possible to use different versions of ruby for different scripts.

Overlordz
02-08-2011, 08:14 PM
And really about the only reason I upgraded was in hopes of automagically fixing the lag I get upon connecting to LNet. No such luck.

So I tracked down what was redlining my rubyw.exe and making Lich freeze up for ~30 seconds. It was this line in LNet



OpenSSL::PKey::RSA.new(512)


And I've noticed it only does it the first time, seems like some initialization thing. So I copied that line into lich.rbw and BADA BING bada boom, LNet connects right away now. And, it's not even like I'm moving the delay to when Lich itself loads, Lich loads right away too. Strange, but I'll take it.



require 'openssl'
OpenSSL::PKey::RSA.new(512)