Module: Lich
- Included in:
- DragonRealms, Gemstone
- Defined in:
- lib/games.rb,
lib/lich.rb,
lib/stash.rb,
lib/update.rb,
lib/messaging.rb,
lib/util/util.rb,
lib/common/hmr.rb,
lib/common/log.rb,
lib/magic-info.rb,
lib/common/vars.rb,
lib/gemstone/sk.rb,
lib/common/spell.rb,
lib/common/buffer.rb,
lib/common/script.rb,
lib/gemstone/disk.rb,
lib/gemstone/gift.rb,
lib/gemstone/psms.rb,
lib/common/account.rb,
lib/common/eaccess.rb,
lib/common/gameobj.rb,
lib/gemstone/claim.rb,
lib/gemstone/group.rb,
lib/gemstone/scars.rb,
lib/attributes/char.rb,
lib/common/db_store.rb,
lib/common/settings.rb,
lib/common/uservars.rb,
lib/common/watchfor.rb,
lib/gemstone/bounty.rb,
lib/gemstone/wounds.rb,
lib/attributes/stats.rb,
lib/common/front-end.rb,
lib/common/gui-login.rb,
lib/common/xmlparser.rb,
lib/gemstone/effects.rb,
lib/gemstone/infomon.rb,
lib/attributes/skills.rb,
lib/attributes/spells.rb,
lib/common/map/map_dr.rb,
lib/common/map/map_gs.rb,
lib/gemstone/stowlist.rb,
lib/attributes/society.rb,
lib/common/game-loader.rb,
lib/gemstone/critranks.rb,
lib/gemstone/psms/cman.rb,
lib/gemstone/psms/feat.rb,
lib/gemstone/readylist.rb,
lib/common/limitedarray.rb,
lib/common/sharedbuffer.rb,
lib/common/upstreamhook.rb,
lib/gemstone/experience.rb,
lib/gemstone/psms/armor.rb,
lib/gemstone/spellranks.rb,
lib/attributes/resources.rb,
lib/attributes/spellsong.rb,
lib/gemstone/bounty/task.rb,
lib/gemstone/infomon/cli.rb,
lib/gemstone/psms/shield.rb,
lib/gemstone/psms/warcry.rb,
lib/gemstone/psms/weapon.rb,
lib/common/downstreamhook.rb,
lib/gemstone/bounty/parser.rb,
lib/gemstone/infomon/cache.rb,
lib/gemstone/infomon/parser.rb,
lib/gemstone/infomon/status.rb,
lib/gemstone/psms/ascension.rb,
lib/gemstone/infomon/currency.rb,
lib/gemstone/infomon/xmlparser.rb,
lib/common/class_exts/stringproc.rb,
lib/common/settings/charsettings.rb,
lib/common/settings/gamesettings.rb,
lib/gemstone/infomon/activespell.rb,
lib/common/settings/path_navigator.rb,
lib/common/settings/settings_proxy.rb,
lib/common/settings/database_adapter.rb,
lib/common/class_exts/synchronizedsocket.rb,
lib/gemstone/critranks/generic_critical_table.rb
Overview
requireds template for a crit GENERIC: <<– the ‘crit table name’
UNSPECIFIED: <<-- the 'location'
0: <<-- the 'crit rank'
:type: GENERIC <<-- this must match the crit table name
:location: UNSPECIFIED <<-- this must match the location
:rank: 0 <<-- this must match the crit rank
:damage: 0 <<-- additional damage per crit table
:position: <<-- if the crit causing KNEEL, SITTING or PRONE
:fatal: false <<-- if the crit is fatal
:stunned: 999 <<-- rounds of stun caused by the crit - use 999 for unknown
:amputated: false <<-- if the crit causes the LOCATION to be severed
:crippled: false <<-- if the crit causes the location to be useless
:sleeping: false <<-- if the crit causes an unconcious / sleeping state
:dazed: false <<-- UAC can caused dazed effect (possible PSMs too?)
:limb_favored: <<-- limb favored (true false or location tbd)
:roundtime: 0 <<-- if the crit causes additional roundtime
:silenced: false <<-- if the crit prevents speaking / casting
:slowed: false <<-- if the crit causes slower actions
:wound_rank: 0 <<-- rank of wound caused at LOCATION
:secondary_wound: <<-- second wound caused at different LOCATIONI
:regex: !ruby/regexp /.*? is stunned!/ <<-- the regex that denotes the crit text for capture
Defined Under Namespace
Modules: Claim, Common, Currency, DragonRealms, Gemstone, Messaging, Resources, Stash, Unknown, Util
Constant Summary collapse
- @@hosts_file =
nil
- @@lich_db =
nil
- @@last_warn_deprecated =
0
- @@deprecated_log =
[]
- @@display_lichid =
settings
nil
- @@display_uid =
boolean
nil
- @@display_exits =
boolean
nil
- @@display_stringprocs =
boolean
nil
- @@hide_uid_flag =
boolean
nil
- @@track_autosort_state =
boolean
nil
- @@track_dark_mode =
boolean
nil
- @@track_layout_state =
boolean
nil
Class Method Summary collapse
-
.break_game_host_port(gamehost, gameport) ⇒ Array
Reverts the game host and port based on predefined mappings.
-
.class_eval(*_a) ⇒ nil
Returns nil for class evaluation.
-
.class_variable_get(*_a) ⇒ nil
Returns nil for class variable access.
-
.core_updated_with_lich_version ⇒ String
Retrieves the version of the core that was updated with the lich version.
-
.core_updated_with_lich_version=(val) ⇒ nil
Sets the version of the core that was updated with the lich version.
-
.db ⇒ SQLite3::Database
Initializes the database connection and creates necessary tables.
-
.db_mutex ⇒ Mutex
Returns the database mutex for thread safety.
-
.debug_messaging ⇒ Boolean
Retrieves the debug messaging setting from the database.
-
.debug_messaging=(val) ⇒ nil
Sets the debug messaging setting in the database.
-
.deprecated(old_object = '', new_object = '', script_location = "#{Script.current.name || 'unknown'}", debug_log: true, fe_log: false, limit_log: true) ⇒ nil
Logs a deprecation warning for a method or variable.
-
.display_exits ⇒ Boolean
Retrieves the current state of the display exits setting.
-
.display_exits=(val) ⇒ nil
Sets the display exits setting.
-
.display_lichid ⇒ Boolean
Retrieves the display Lich ID setting from the database.
-
.display_lichid=(val) ⇒ nil
Sets the display state of the lich ID.
-
.display_stringprocs ⇒ Boolean
Retrieves the current state of the display string procs setting.
-
.display_stringprocs=(val) ⇒ nil
Sets the display string procs setting.
-
.display_uid ⇒ Boolean
Retrieves the current state of the display UID setting.
-
.display_uid=(val) ⇒ nil
Sets the display UID setting.
-
.find_hosts_file ⇒ String, false
Searches for the hosts file based on the operating system.
-
.fix_game_host_port(gamehost, gameport) ⇒ Array
Fixes the game host and port based on predefined mappings.
-
.get_simu_launcher ⇒ String?
Retrieves the command for the Simutronics launcher from the registry.
-
.hide_uid_flag ⇒ Boolean
Retrieves the current state of the hide UID flag.
-
.hide_uid_flag=(val) ⇒ nil
Sets the hide UID flag.
-
.hosts_file ⇒ String, false
Retrieves the path to the hosts file.
-
.init_db ⇒ Object
Creates necessary tables in the database if they do not exist.
-
.inventory_boxes(player_id) ⇒ Boolean
Checks if inventory boxes are enabled for a specific player.
-
.link_to_sal ⇒ Boolean
Links the application to the Simutronics Auto-launch command on Windows or Wine.
-
.link_to_sge ⇒ Boolean
Links the application to the Simutronics Game Engine (SGE) on Windows or Wine.
-
.log(msg) ⇒ Object
Logs a message to standard error with a timestamp.
-
.method_missing(arg1, arg2 = '') ⇒ Object
Handles missing methods for Lich, providing a warning for deprecated usage.
-
.modify_hosts(game_host) ⇒ Boolean
Modifies the hosts file to include a new game host.
-
.module_eval(*_a) ⇒ nil
Returns nil for module evaluation.
-
.msgbox(args) ⇒ Symbol?
Displays a message box with specified options.
-
.mutex_lock ⇒ Object
Locks the database mutex to ensure thread safety during operations.
-
.mutex_unlock ⇒ Object
Unlocks the database mutex after operations are complete.
-
.restore_hosts ⇒ nil
Restores the original hosts file from the backup.
-
.seek(fe) ⇒ String?
Retrieves the location of the front-end based on the provided identifier.
-
.set_inventory_boxes(player_id, enabled) ⇒ nil
Enables or disables inventory boxes for a specific player.
-
.show_deprecated_log ⇒ nil
Displays the log of deprecated messages.
-
.track_autosort_state ⇒ Boolean
Retrieves the current state of the track autosort state setting.
-
.track_autosort_state=(val) ⇒ nil
Sets the track autosort state setting.
-
.track_dark_mode ⇒ Boolean
Retrieves the current state of the track dark mode setting.
-
.track_dark_mode=(val) ⇒ nil
Sets the track dark mode setting.
-
.track_layout_state ⇒ Boolean
Retrieves the current state of the track layout state setting.
-
.track_layout_state=(val) ⇒ nil
Sets the track layout state setting.
-
.unlink_from_sal ⇒ Boolean
Unlinks the application from the Simutronics Auto-launch command on Windows or Wine.
-
.unlink_from_sge ⇒ Boolean
Unlinks the application from the Simutronics Game Engine (SGE) on Windows or Wine.
-
.win32_launch_method ⇒ String?
Retrieves the current win32 launch method from the database.
-
.win32_launch_method=(val) ⇒ nil
Sets the win32 launch method in the database.
Class Method Details
.break_game_host_port(gamehost, gameport) ⇒ Array
Reverts the game host and port based on predefined mappings.
780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 |
# File 'lib/lich.rb', line 780 def Lich.break_game_host_port(gamehost, gameport) if (gamehost == 'storm.gs4.game.play.net') and (gameport.to_i == 10324) gamehost = 'gs4.simutronics.net' gameport = 10321 elsif (gamehost == 'storm.gs4.game.play.net') and (gameport.to_i == 10124) gamehost = 'gs-plat.simutronics.net' gameport = 10121 elsif (gamehost == 'storm.gs4.game.play.net') and (gameport.to_i == 10024) gamehost = 'gs3.simutronics.net' gameport = 4900 elsif (gamehost == 'dr.simutronics.net') and (gameport.to_i == 11024) gamehost = 'prime.dr.game.play.net' gameport = 4901 end [gamehost, gameport] end |
.class_eval(*_a) ⇒ nil
Returns nil for class evaluation.
126 |
# File 'lib/lich.rb', line 126 def Lich.class_eval(*_a); nil; end |
.class_variable_get(*_a) ⇒ nil
Returns nil for class variable access.
120 |
# File 'lib/lich.rb', line 120 def Lich.class_variable_get(*_a); nil; end |
.core_updated_with_lich_version ⇒ String
Retrieves the version of the core that was updated with the lich version.
915 916 917 918 919 920 921 922 923 |
# File 'lib/lich.rb', line 915 def Lich.core_updated_with_lich_version begin val = Lich.db.get_first_value("SELECT value FROM lich_settings WHERE name='core_updated_with_lich_version';") rescue SQLite3::BusyException sleep 0.1 retry end return val.to_s end |
.core_updated_with_lich_version=(val) ⇒ nil
Sets the version of the core that was updated with the lich version.
932 933 934 935 936 937 938 939 940 |
# File 'lib/lich.rb', line 932 def Lich.core_updated_with_lich_version=(val) begin Lich.db.execute("INSERT OR REPLACE INTO lich_settings(name,value) values('core_updated_with_lich_version',?);", [val.to_s.encode('UTF-8')]) rescue SQLite3::BusyException sleep 0.1 retry end return nil end |
.db ⇒ SQLite3::Database
Initializes the database connection and creates necessary tables.
90 91 92 |
# File 'lib/lich.rb', line 90 def Lich.db @@lich_db ||= SQLite3::Database.new("#{DATA_DIR}/lich.db3") end |
.db_mutex ⇒ Mutex
Returns the database mutex for thread safety.
22 23 24 |
# File 'lib/lich.rb', line 22 def self.db_mutex @@db_mutex end |
.debug_messaging ⇒ Boolean
Retrieves the debug messaging setting from the database.
802 803 804 805 806 807 808 809 810 811 812 813 814 |
# File 'lib/lich.rb', line 802 def Lich.debug_messaging if @@debug_messaging.nil? begin val = Lich.db.get_first_value("SELECT value FROM lich_settings WHERE name='debug_messaging';") rescue SQLite3::BusyException sleep 0.1 retry end @@debug_messaging = (val.to_s =~ /on|true|yes/ ? true : false) Lich.debug_messaging = @@debug_messaging end return @@debug_messaging end |
.debug_messaging=(val) ⇒ nil
Sets the debug messaging setting in the database.
823 824 825 826 827 828 829 830 831 832 |
# File 'lib/lich.rb', line 823 def Lich.debug_messaging=(val) @@debug_messaging = (val.to_s =~ /on|true|yes/ ? true : false) begin Lich.db.execute("INSERT OR REPLACE INTO lich_settings(name,value) values('debug_messaging',?);", [@@debug_messaging.to_s.encode('UTF-8')]) rescue SQLite3::BusyException sleep 0.1 retry end return nil end |
.deprecated(old_object = '', new_object = '', script_location = "#{Script.current.name || 'unknown'}", debug_log: true, fe_log: false, limit_log: true) ⇒ nil
Logs a deprecation warning for a method or variable.
154 155 156 157 158 159 160 |
# File 'lib/lich.rb', line 154 def Lich.deprecated(old_object = '', new_object = '', script_location = "#{Script.current.name || 'unknown'}", debug_log: true, fe_log: false, limit_log: true) msg = "Deprecated call to #{old_object} used in #{script_location}. Please change to #{new_object} instead!" return if limit_log && @@deprecated_log.include?(msg) Lich.log(msg) if debug_log Lich::Messaging.msg("bold", msg) if fe_log @@deprecated_log.push(msg) unless @@deprecated_log.include?(msg) end |
.display_exits ⇒ Boolean
Retrieves the current state of the display exits setting.
986 987 988 989 990 991 992 993 994 995 996 997 998 |
# File 'lib/lich.rb', line 986 def Lich.display_exits if @@display_exits.nil? begin val = Lich.db.get_first_value("SELECT value FROM lich_settings WHERE name='display_exits';") rescue SQLite3::BusyException sleep 0.1 retry end val = false if val.nil? and XMLData.game != ""; # default false @@display_exits = (val.to_s =~ /on|true|yes/ ? true : false) if !val.nil?; end return @@display_exits end |
.display_exits=(val) ⇒ nil
Sets the display exits setting.
1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 |
# File 'lib/lich.rb', line 1007 def Lich.display_exits=(val) @@display_exits = (val.to_s =~ /on|true|yes/ ? true : false) begin Lich.db.execute("INSERT OR REPLACE INTO lich_settings(name,value) values('display_exits',?);", [@@display_exits.to_s.encode('UTF-8')]) rescue SQLite3::BusyException sleep 0.1 retry end return nil end |
.display_lichid ⇒ Boolean
Retrieves the display Lich ID setting from the database.
839 840 841 842 843 844 845 846 847 848 849 850 851 |
# File 'lib/lich.rb', line 839 def Lich.display_lichid if @@display_lichid.nil? begin val = Lich.db.get_first_value("SELECT value FROM lich_settings WHERE name='display_lichid';") rescue SQLite3::BusyException sleep 0.1 retry end val = (XMLData.game =~ /^GS/ ? true : false) if val.nil? and XMLData.game != ""; # default false if DR, otherwise default true @@display_lichid = (val.to_s =~ /on|true|yes/ ? true : false) if !val.nil?; end return @@display_lichid end |
.display_lichid=(val) ⇒ nil
Sets the display state of the lich ID.
860 861 862 863 864 865 866 867 868 869 |
# File 'lib/lich.rb', line 860 def Lich.display_lichid=(val) @@display_lichid = (val.to_s =~ /on|true|yes/ ? true : false) begin Lich.db.execute("INSERT OR REPLACE INTO lich_settings(name,value) values('display_lichid',?);", [@@display_lichid.to_s.encode('UTF-8')]) rescue SQLite3::BusyException sleep 0.1 retry end return nil end |
.display_stringprocs ⇒ Boolean
Retrieves the current state of the display string procs setting.
1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 |
# File 'lib/lich.rb', line 1024 def Lich.display_stringprocs if @@display_stringprocs.nil? begin val = Lich.db.get_first_value("SELECT value FROM lich_settings WHERE name='display_stringprocs';") rescue SQLite3::BusyException sleep 0.1 retry end val = false if val.nil? and XMLData.game != ""; # default false @@display_stringprocs = (val.to_s =~ /on|true|yes/ ? true : false) if !val.nil?; end return @@display_stringprocs end |
.display_stringprocs=(val) ⇒ nil
Sets the display string procs setting.
1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 |
# File 'lib/lich.rb', line 1045 def Lich.display_stringprocs=(val) @@display_stringprocs = (val.to_s =~ /on|true|yes/ ? true : false) begin Lich.db.execute("INSERT OR REPLACE INTO lich_settings(name,value) values('display_stringprocs',?);", [@@display_stringprocs.to_s.encode('UTF-8')]) rescue SQLite3::BusyException sleep 0.1 retry end return nil end |
.display_uid ⇒ Boolean
Retrieves the current state of the display UID setting.
948 949 950 951 952 953 954 955 956 957 958 959 960 |
# File 'lib/lich.rb', line 948 def Lich.display_uid if @@display_uid.nil? begin val = Lich.db.get_first_value("SELECT value FROM lich_settings WHERE name='display_uid';") rescue SQLite3::BusyException sleep 0.1 retry end val = (XMLData.game =~ /^GS/ ? true : false) if val.nil? and XMLData.game != ""; # default false if DR, otherwise default true @@display_uid = (val.to_s =~ /on|true|yes/ ? true : false) if !val.nil?; end return @@display_uid end |
.display_uid=(val) ⇒ nil
Sets the display UID setting.
969 970 971 972 973 974 975 976 977 978 |
# File 'lib/lich.rb', line 969 def Lich.display_uid=(val) @@display_uid = (val.to_s =~ /on|true|yes/ ? true : false) begin Lich.db.execute("INSERT OR REPLACE INTO lich_settings(name,value) values('display_uid',?);", [@@display_uid.to_s.encode('UTF-8')]) rescue SQLite3::BusyException sleep 0.1 retry end return nil end |
.find_hosts_file ⇒ String, false
Searches for the hosts file based on the operating system.
578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 |
# File 'lib/lich.rb', line 578 def Lich.find_hosts_file if defined?(Win32) begin key = Win32.RegOpenKeyEx(:hKey => Win32::HKEY_LOCAL_MACHINE, :lpSubKey => 'System\\CurrentControlSet\\Services\\Tcpip\\Parameters', :samDesired => Win32::KEY_READ)[:phkResult] hosts_path = Win32.RegQueryValueEx(:hKey => key, :lpValueName => 'DataBasePath')[:lpData] ensure Win32.RegCloseKey(:hKey => key) rescue nil end if hosts_path windir = (ENV['windir'] || ENV['SYSTEMROOT'] || 'c:\windows') hosts_path.gsub!('%SystemRoot%', windir) hosts_file = "#{hosts_path}\\hosts" if File.exist?(hosts_file) return (@@hosts_file = hosts_file) end end if (windir = (ENV['windir'] || ENV['SYSTEMROOT'])) and File.exist?("#{windir}\\system32\\drivers\\etc\\hosts") return (@@hosts_file = "#{windir}\\system32\\drivers\\etc\\hosts") end for drive in ['C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] for windir in ['winnt', 'windows'] if File.exist?("#{drive}:\\#{windir}\\system32\\drivers\\etc\\hosts") return (@@hosts_file = "#{drive}:\\#{windir}\\system32\\drivers\\etc\\hosts") end end end else # Linux/Mac if File.exist?('/etc/hosts') return (@@hosts_file = '/etc/hosts') elsif File.exist?('/private/etc/hosts') return (@@hosts_file = '/private/etc/hosts') end end return (@@hosts_file = false) end |
.fix_game_host_port(gamehost, gameport) ⇒ Array
Fixes the game host and port based on predefined mappings.
756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 |
# File 'lib/lich.rb', line 756 def Lich.fix_game_host_port(gamehost, gameport) if (gamehost == 'gs-plat.simutronics.net') and (gameport.to_i == 10121) gamehost = 'storm.gs4.game.play.net' gameport = 10124 elsif (gamehost == 'gs3.simutronics.net') and (gameport.to_i == 4900) gamehost = 'storm.gs4.game.play.net' gameport = 10024 elsif (gamehost == 'gs4.simutronics.net') and (gameport.to_i == 10321) gamehost = 'storm.gs4.game.play.net' gameport = 10324 elsif (gamehost == 'prime.dr.game.play.net') and (gameport.to_i == 4901) gamehost = 'dr.simutronics.net' gameport = 11024 end [gamehost, gameport] end |
.get_simu_launcher ⇒ String?
Retrieves the command for the Simutronics launcher from the registry.
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
# File 'lib/lich.rb', line 262 def Lich.get_simu_launcher if defined?(Win32) begin launcher_key = Win32.RegOpenKeyEx(:hKey => Win32::HKEY_LOCAL_MACHINE, :lpSubKey => 'Software\\Classes\\Simutronics.Autolaunch\\Shell\\Open\\command', :samDesired => (Win32::KEY_ALL_ACCESS | Win32::KEY_WOW64_32KEY))[:phkResult] launcher_cmd = Win32.RegQueryValueEx(:hKey => launcher_key, :lpValueName => 'RealCommand')[:lpData] if launcher_cmd.nil? or launcher_cmd.empty? launcher_cmd = Win32.RegQueryValueEx(:hKey => launcher_key)[:lpData] end return launcher_cmd ensure Win32.RegCloseKey(:hKey => launcher_key) rescue nil end elsif defined?(Wine) launcher_cmd = Wine.registry_gets('HKEY_LOCAL_MACHINE\\Software\\Classes\\Simutronics.Autolaunch\\Shell\\Open\\command\\RealCommand') unless launcher_cmd and not launcher_cmd.empty? launcher_cmd = Wine.registry_gets('HKEY_LOCAL_MACHINE\\Software\\Classes\\Simutronics.Autolaunch\\Shell\\Open\\command\\') end return launcher_cmd else return nil end end |
.hide_uid_flag ⇒ Boolean
Retrieves the current state of the hide UID flag.
877 878 879 880 881 882 883 884 885 886 887 888 889 |
# File 'lib/lich.rb', line 877 def Lich.hide_uid_flag if @@hide_uid_flag.nil? begin val = Lich.db.get_first_value("SELECT value FROM lich_settings WHERE name='hide_uid_flag';") rescue SQLite3::BusyException sleep 0.1 retry end val = false if val.nil? and XMLData.game != ""; # default false @@hide_uid_flag = (val.to_s =~ /on|true|yes/ ? true : false) if !val.nil?; end return @@hide_uid_flag end |
.hide_uid_flag=(val) ⇒ nil
Sets the hide UID flag.
898 899 900 901 902 903 904 905 906 907 |
# File 'lib/lich.rb', line 898 def Lich.hide_uid_flag=(val) @@hide_uid_flag = (val.to_s =~ /on|true|yes/ ? true : false) begin Lich.db.execute("INSERT OR REPLACE INTO lich_settings(name,value) values('hide_uid_flag',?);", [@@hide_uid_flag.to_s.encode('UTF-8')]) rescue SQLite3::BusyException sleep 0.1 retry end return nil end |
.hosts_file ⇒ String, false
Retrieves the path to the hosts file. If the path is not already cached, it will search for it.
567 568 569 570 |
# File 'lib/lich.rb', line 567 def Lich.hosts_file Lich.find_hosts_file if @@hosts_file.nil? return @@hosts_file end |
.init_db ⇒ Object
Creates necessary tables in the database if they do not exist.
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/lich.rb', line 99 def Lich.init_db begin Lich.db.execute("CREATE TABLE IF NOT EXISTS script_setting (script TEXT NOT NULL, name TEXT NOT NULL, value BLOB, PRIMARY KEY(script, name));") Lich.db.execute("CREATE TABLE IF NOT EXISTS script_auto_settings (script TEXT NOT NULL, scope TEXT, hash BLOB, PRIMARY KEY(script, scope));") Lich.db.execute("CREATE TABLE IF NOT EXISTS lich_settings (name TEXT NOT NULL, value TEXT, PRIMARY KEY(name));") Lich.db.execute("CREATE TABLE IF NOT EXISTS uservars (scope TEXT NOT NULL, hash BLOB, PRIMARY KEY(scope));") if (RUBY_VERSION =~ /^2\.[012]\./) Lich.db.execute("CREATE TABLE IF NOT EXISTS trusted_scripts (name TEXT NOT NULL);") end Lich.db.execute("CREATE TABLE IF NOT EXISTS simu_game_entry (character TEXT NOT NULL, game_code TEXT NOT NULL, data BLOB, PRIMARY KEY(character, game_code));") Lich.db.execute("CREATE TABLE IF NOT EXISTS enable_inventory_boxes (player_id INTEGER NOT NULL, PRIMARY KEY(player_id));") rescue SQLite3::BusyException sleep 0.1 retry end end |
.inventory_boxes(player_id) ⇒ Boolean
Checks if inventory boxes are enabled for a specific player.
676 677 678 679 680 681 682 683 684 685 686 687 688 |
# File 'lib/lich.rb', line 676 def Lich.inventory_boxes(player_id) begin v = Lich.db.get_first_value('SELECT player_id FROM enable_inventory_boxes WHERE player_id=?;', [player_id.to_i]) rescue SQLite3::BusyException sleep 0.1 retry end if v true else false end end |
.link_to_sal ⇒ Boolean
Links the application to the Simutronics Auto-launch command on Windows or Wine.
This method checks if the application is already linked to the Auto-launch command. If not, it attempts to link it by modifying the Windows registry or using Wine’s registry functions.
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 |
# File 'lib/lich.rb', line 433 def Lich.link_to_sal if defined?(Win32) if Win32.admin? begin # fixme: 64 bit browsers? launcher_key = Win32.RegOpenKeyEx(:hKey => Win32::HKEY_LOCAL_MACHINE, :lpSubKey => 'Software\\Classes\\Simutronics.Autolaunch\\Shell\\Open\\command', :samDesired => (Win32::KEY_ALL_ACCESS | Win32::KEY_WOW64_32KEY))[:phkResult] r = Win32.RegQueryValueEx(:hKey => launcher_key, :lpValueName => 'RealCommand') if (r[:return] == 0) and not r[:lpData].empty? # already linked return true end r = Win32.GetModuleFileName unless r[:return] > 0 # fixme return false end new_launcher_cmd = "\"#{r[:lpFilename]}\" \"#{File.($PROGRAM_NAME)}\" %1" r = Win32.RegQueryValueEx(:hKey => launcher_key) launcher_cmd = r[:lpData] r = Win32.RegSetValueEx(:hKey => launcher_key, :lpValueName => 'RealCommand', :dwType => Win32::REG_SZ, :lpData => launcher_cmd) return false unless (r == 0) r = Win32.RegSetValueEx(:hKey => launcher_key, :dwType => Win32::REG_SZ, :lpData => new_launcher_cmd) return (r == 0) ensure Win32.RegCloseKey(:hKey => launcher_key) rescue nil end else begin r = Win32.GetModuleFileName file = ((r[:return] > 0) ? r[:lpFilename] : 'rubyw.exe') params = "#{$PROGRAM_NAME.split(/\/|\\/).last} --link-to-sal" r = Win32.ShellExecuteEx(:lpVerb => 'runas', :lpFile => file, :lpDirectory => LICH_DIR.tr("/", "\\"), :lpParameters => params, :fMask => Win32::SEE_MASK_NOCLOSEPROCESS) if r[:return] > 0 process_id = r[:hProcess] sleep 0.2 while Win32.GetExitCodeProcess(:hProcess => process_id)[:lpExitCode] == Win32::STILL_ACTIVE sleep 3 else Win32.ShellExecute(:lpOperation => 'runas', :lpFile => file, :lpDirectory => LICH_DIR.tr("/", "\\"), :lpParameters => params) sleep 6 end rescue Lich.msgbox(:message => $!) end end elsif defined?(Wine) launch_cmd = Wine.registry_gets('HKEY_LOCAL_MACHINE\\Software\\Classes\\Simutronics.Autolaunch\\Shell\\Open\\command\\') return false unless launch_cmd new_launch_cmd = "#{File.($PROGRAM_NAME)} --wine=#{Wine::BIN} --wine-prefix=#{Wine::PREFIX} %1" result = true if launch_cmd if launch_cmd =~ /lich/i $stdout.puts "--- warning: Lich appears to already be installed to the registry" Lich.log "warning: Lich appears to already be installed to the registry" Lich.log 'info: launch_cmd: ' + launch_cmd else result = result && Wine.registry_puts('HKEY_LOCAL_MACHINE\\Software\\Classes\\Simutronics.Autolaunch\\Shell\\Open\\command\\RealCommand', launch_cmd) result = result && Wine.registry_puts('HKEY_LOCAL_MACHINE\\Software\\Classes\\Simutronics.Autolaunch\\Shell\\Open\\command\\', new_launch_cmd) end end return result else return false end end |
.link_to_sge ⇒ Boolean
Links the application to the Simutronics Game Engine (SGE) on Windows or Wine.
This method checks if the application is already linked to SGE. If not, it attempts to link it by modifying the Windows registry or using Wine’s registry functions.
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
# File 'lib/lich.rb', line 295 def Lich.link_to_sge if defined?(Win32) if Win32.admin? begin launcher_key = Win32.RegOpenKeyEx(:hKey => Win32::HKEY_LOCAL_MACHINE, :lpSubKey => 'Software\\Simutronics\\Launcher', :samDesired => (Win32::KEY_ALL_ACCESS | Win32::KEY_WOW64_32KEY))[:phkResult] r = Win32.RegQueryValueEx(:hKey => launcher_key, :lpValueName => 'RealDirectory') if (r[:return] == 0) and not r[:lpData].empty? # already linked return true end r = Win32.GetModuleFileName unless r[:return] > 0 # fixme return false end new_launcher_dir = "\"#{r[:lpFilename]}\" \"#{File.($PROGRAM_NAME)}\" " r = Win32.RegQueryValueEx(:hKey => launcher_key, :lpValueName => 'Directory') launcher_dir = r[:lpData] r = Win32.RegSetValueEx(:hKey => launcher_key, :lpValueName => 'RealDirectory', :dwType => Win32::REG_SZ, :lpData => launcher_dir) return false unless (r == 0) r = Win32.RegSetValueEx(:hKey => launcher_key, :lpValueName => 'Directory', :dwType => Win32::REG_SZ, :lpData => new_launcher_dir) return (r == 0) ensure Win32.RegCloseKey(:hKey => launcher_key) rescue nil end else begin r = Win32.GetModuleFileName file = ((r[:return] > 0) ? r[:lpFilename] : 'rubyw.exe') params = "#{$PROGRAM_NAME.split(/\/|\\/).last} --link-to-sge" r = Win32.ShellExecuteEx(:lpVerb => 'runas', :lpFile => file, :lpDirectory => LICH_DIR.tr("/", "\\"), :lpParameters => params, :fMask => Win32::SEE_MASK_NOCLOSEPROCESS) if r[:return] > 0 process_id = r[:hProcess] sleep 0.2 while Win32.GetExitCodeProcess(:hProcess => process_id)[:lpExitCode] == Win32::STILL_ACTIVE sleep 3 else Win32.ShellExecute(:lpOperation => 'runas', :lpFile => file, :lpDirectory => LICH_DIR.tr("/", "\\"), :lpParameters => params) sleep 6 end rescue Lich.msgbox(:message => $!) end end elsif defined?(Wine) launch_dir = Wine.registry_gets('HKEY_LOCAL_MACHINE\\Software\\Simutronics\\Launcher\\Directory') return false unless launch_dir lich_launch_dir = "#{File.($PROGRAM_NAME)} --wine=#{Wine::BIN} --wine-prefix=#{Wine::PREFIX} " result = true if launch_dir if launch_dir =~ /lich/i $stdout.puts "--- warning: Lich appears to already be installed to the registry" Lich.log "warning: Lich appears to already be installed to the registry" Lich.log 'info: launch_dir: ' + launch_dir else result = result && Wine.registry_puts('HKEY_LOCAL_MACHINE\\Software\\Simutronics\\Launcher\\RealDirectory', launch_dir) result = result && Wine.registry_puts('HKEY_LOCAL_MACHINE\\Software\\Simutronics\\Launcher\\Directory', lich_launch_dir) end end return result else return false end end |
.log(msg) ⇒ Object
Logs a message to standard error with a timestamp.
139 140 141 |
# File 'lib/lich.rb', line 139 def Lich.log(msg) $stderr.puts "#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}: #{msg}" end |
.method_missing(arg1, arg2 = '') ⇒ Object
Handles missing methods for Lich, providing a warning for deprecated usage.
61 62 63 64 65 66 67 |
# File 'lib/lich.rb', line 61 def Lich.method_missing(arg1, arg2 = '') if (Time.now.to_i - @@last_warn_deprecated) > 300 respond "--- warning: Lich.* variables will stop working in a future version of Lich. Use Vars.* (offending script: #{Script.current.name || 'unknown'})" @@last_warn_deprecated = Time.now.to_i end Vars.method_missing(arg1, arg2) end |
.modify_hosts(game_host) ⇒ Boolean
Modifies the hosts file to include a new game host.
621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 |
# File 'lib/lich.rb', line 621 def Lich.modify_hosts(game_host) if Lich.hosts_file and File.exist?(Lich.hosts_file) at_exit { Lich.restore_hosts } Lich.restore_hosts if File.exist?("#{Lich.hosts_file}.bak") return false end begin # copy hosts to hosts.bak File.open("#{Lich.hosts_file}.bak", 'w') { |hb| File.open(Lich.hosts_file) { |h| hb.write(h.read) } } rescue File.unlink("#{Lich.hosts_file}.bak") if File.exist?("#{Lich.hosts_file}.bak") return false end File.open(Lich.hosts_file, 'a') { |f| f.write "\r\n127.0.0.1\t\t#{game_host}" } return true else return false end end |
.module_eval(*_a) ⇒ nil
Returns nil for module evaluation.
132 |
# File 'lib/lich.rb', line 132 def Lich.module_eval(*_a); nil; end |
.msgbox(args) ⇒ Symbol?
Displays a message box with specified options.
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/lich.rb', line 183 def Lich.msgbox(args) if defined?(Win32) if args[:buttons] == :ok_cancel = Win32::MB_OKCANCEL elsif args[:buttons] == :yes_no = Win32::MB_YESNO else = Win32::MB_OK end if args[:icon] == :error icon = Win32::MB_ICONERROR elsif args[:icon] == :question icon = Win32::MB_ICONQUESTION elsif args[:icon] == :warning icon = Win32::MB_ICONWARNING else icon = 0 end args[:title] ||= "Lich v#{LICH_VERSION}" r = Win32.MessageBox(:lpText => args[:message], :lpCaption => args[:title], :uType => ( | icon)) if r == Win32::IDIOK return :ok elsif r == Win32::IDICANCEL return :cancel elsif r == Win32::IDIYES return :yes elsif r == Win32::IDINO return :no else return nil end elsif defined?(Gtk) if args[:buttons] == :ok_cancel = Gtk::MessageDialog::BUTTONS_OK_CANCEL elsif args[:buttons] == :yes_no = Gtk::MessageDialog::BUTTONS_YES_NO else = Gtk::MessageDialog::BUTTONS_OK end if args[:icon] == :error type = Gtk::MessageDialog::ERROR elsif args[:icon] == :question type = Gtk::MessageDialog::QUESTION elsif args[:icon] == :warning type = Gtk::MessageDialog::WARNING else type = Gtk::MessageDialog::INFO end dialog = Gtk::MessageDialog.new(nil, Gtk::Dialog::MODAL, type, , args[:message]) args[:title] ||= "Lich v#{LICH_VERSION}" dialog.title = args[:title] response = nil dialog.run { |d_r| response = d_r dialog.destroy } if response == Gtk::Dialog::RESPONSE_OK return :ok elsif response == Gtk::Dialog::RESPONSE_CANCEL return :cancel elsif response == Gtk::Dialog::RESPONSE_YES return :yes elsif response == Gtk::Dialog::RESPONSE_NO return :no else return nil end elsif $stdout.isatty $stdout.puts(args[:message]) return nil end end |
.mutex_lock ⇒ Object
Locks the database mutex to ensure thread safety during operations.
31 32 33 34 35 36 37 38 |
# File 'lib/lich.rb', line 31 def self.mutex_lock begin self.db_mutex.lock unless self.db_mutex.owned? rescue StandardError respond "--- Lich: error: Lich.mutex_lock: #{$!}" Lich.log "error: Lich.mutex_lock: #{$!}\n\t#{$!.backtrace.join("\n\t")}" end end |
.mutex_unlock ⇒ Object
Unlocks the database mutex after operations are complete.
45 46 47 48 49 50 51 52 |
# File 'lib/lich.rb', line 45 def self.mutex_unlock begin self.db_mutex.unlock if self.db_mutex.owned? rescue StandardError respond "--- Lich: error: Lich.mutex_unlock: #{$!}" Lich.log "error: Lich.mutex_unlock: #{$!}\n\t#{$!.backtrace.join("\n\t")}" end end |
.restore_hosts ⇒ nil
Restores the original hosts file from the backup.
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 |
# File 'lib/lich.rb', line 649 def Lich.restore_hosts if Lich.hosts_file and File.exist?(Lich.hosts_file) begin # fixme: use rename instead? test rename on windows if File.exist?("#{Lich.hosts_file}.bak") File.open("#{Lich.hosts_file}.bak") { |infile| File.open(Lich.hosts_file, 'w') { |outfile| outfile.write(infile.read) } } File.unlink "#{Lich.hosts_file}.bak" end rescue $stdout.puts "--- error: restore_hosts: #{$!}" Lich.log "error: restore_hosts: #{$!}\n\t#{$!.backtrace.join("\n\t")}" exit(1) end end end |
.seek(fe) ⇒ String?
Retrieves the location of the front-end based on the provided identifier.
75 76 77 78 79 80 81 82 |
# File 'lib/lich.rb', line 75 def Lich.seek(fe) if fe =~ /wizard/ return $wiz_fe_loc elsif fe =~ /stormfront/ return $sf_fe_loc end pp "Landed in get_simu_launcher method" end |
.set_inventory_boxes(player_id, enabled) ⇒ nil
Enables or disables inventory boxes for a specific player.
698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 |
# File 'lib/lich.rb', line 698 def Lich.set_inventory_boxes(player_id, enabled) if enabled begin Lich.db.execute('INSERT OR REPLACE INTO enable_inventory_boxes values(?);', [player_id.to_i]) rescue SQLite3::BusyException sleep 0.1 retry end else begin Lich.db.execute('DELETE FROM enable_inventory_boxes where player_id=?;', [player_id.to_i]) rescue SQLite3::BusyException sleep 0.1 retry end end nil end |
.show_deprecated_log ⇒ nil
Displays the log of deprecated messages.
167 168 169 170 171 |
# File 'lib/lich.rb', line 167 def Lich.show_deprecated_log @@deprecated_log.each do |msg| respond(msg) end end |
.track_autosort_state ⇒ Boolean
Retrieves the current state of the track autosort state setting.
1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 |
# File 'lib/lich.rb', line 1062 def Lich.track_autosort_state if @@track_autosort_state.nil? begin val = Lich.db.get_first_value("SELECT value FROM lich_settings WHERE name='track_autosort_state';") rescue SQLite3::BusyException sleep 0.1 retry end @@track_autosort_state = (val.to_s =~ /on|true|yes/ ? true : false) end return @@track_autosort_state end |
.track_autosort_state=(val) ⇒ nil
Sets the track autosort state setting.
1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 |
# File 'lib/lich.rb', line 1082 def Lich.track_autosort_state=(val) @@track_autosort_state = (val.to_s =~ /on|true|yes/ ? true : false) begin Lich.db.execute("INSERT OR REPLACE INTO lich_settings(name,value) values('track_autosort_state',?);", [@@track_autosort_state.to_s.encode('UTF-8')]) rescue SQLite3::BusyException sleep 0.1 retry end return nil end |
.track_dark_mode ⇒ Boolean
Retrieves the current state of the track dark mode setting.
1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 |
# File 'lib/lich.rb', line 1099 def Lich.track_dark_mode if @@track_dark_mode.nil? begin val = Lich.db.get_first_value("SELECT value FROM lich_settings WHERE name='track_dark_mode';") rescue SQLite3::BusyException sleep 0.1 retry end @@track_dark_mode = (val.to_s =~ /on|true|yes/ ? true : false) end return @@track_dark_mode end |
.track_dark_mode=(val) ⇒ nil
Sets the track dark mode setting.
1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 |
# File 'lib/lich.rb', line 1119 def Lich.track_dark_mode=(val) @@track_dark_mode = (val.to_s =~ /on|true|yes/ ? true : false) begin Lich.db.execute("INSERT OR REPLACE INTO lich_settings(name,value) values('track_dark_mode',?);", [@@track_dark_mode.to_s.encode('UTF-8')]) rescue SQLite3::BusyException sleep 0.1 retry end return nil end |
.track_layout_state ⇒ Boolean
Retrieves the current state of the track layout state setting.
1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 |
# File 'lib/lich.rb', line 1136 def Lich.track_layout_state if @@track_layout_state.nil? begin val = Lich.db.get_first_value("SELECT value FROM lich_settings WHERE name='track_layout_state';") rescue SQLite3::BusyException sleep 0.1 retry end @@track_layout_state = (val.to_s =~ /on|true|yes/ ? true : false) end return @@track_layout_state end |
.track_layout_state=(val) ⇒ nil
Sets the track layout state setting.
1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 |
# File 'lib/lich.rb', line 1156 def Lich.track_layout_state=(val) @@track_layout_state = (val.to_s =~ /on|true|yes/ ? true : false) begin Lich.db.execute("INSERT OR REPLACE INTO lich_settings(name,value) values('track_layout_state',?);", [@@track_layout_state.to_s.encode('UTF-8')]) rescue SQLite3::BusyException sleep 0.1 retry end return nil end |
.unlink_from_sal ⇒ Boolean
Unlinks the application from the Simutronics Auto-launch command on Windows or Wine.
This method checks if the application is linked to the Auto-launch command. If it is, it attempts to unlink it by modifying the Windows registry or using Wine’s registry functions.
512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 |
# File 'lib/lich.rb', line 512 def Lich.unlink_from_sal if defined?(Win32) if Win32.admin? begin launcher_key = Win32.RegOpenKeyEx(:hKey => Win32::HKEY_LOCAL_MACHINE, :lpSubKey => 'Software\\Classes\\Simutronics.Autolaunch\\Shell\\Open\\command', :samDesired => (Win32::KEY_ALL_ACCESS | Win32::KEY_WOW64_32KEY))[:phkResult] real_directory = Win32.RegQueryValueEx(:hKey => launcher_key, :lpValueName => 'RealCommand')[:lpData] if real_directory.nil? or real_directory.empty? # not linked return true end r = Win32.RegSetValueEx(:hKey => launcher_key, :dwType => Win32::REG_SZ, :lpData => real_directory) return false unless (r == 0) r = Win32.RegDeleteValue(:hKey => launcher_key, :lpValueName => 'RealCommand') return (r == 0) ensure Win32.RegCloseKey(:hKey => launcher_key) rescue nil end else begin r = Win32.GetModuleFileName file = ((r[:return] > 0) ? r[:lpFilename] : 'rubyw.exe') params = "#{$PROGRAM_NAME.split(/\/|\\/).last} --unlink-from-sal" r = Win32.ShellExecuteEx(:lpVerb => 'runas', :lpFile => file, :lpDirectory => LICH_DIR.tr("/", "\\"), :lpParameters => params, :fMask => Win32::SEE_MASK_NOCLOSEPROCESS) if r[:return] > 0 process_id = r[:hProcess] sleep 0.2 while Win32.GetExitCodeProcess(:hProcess => process_id)[:lpExitCode] == Win32::STILL_ACTIVE sleep 3 else Win32.ShellExecute(:lpOperation => 'runas', :lpFile => file, :lpDirectory => LICH_DIR.tr("/", "\\"), :lpParameters => params) sleep 6 end rescue Lich.msgbox(:message => $!) end end elsif defined?(Wine) real_launch_cmd = Wine.registry_gets('HKEY_LOCAL_MACHINE\\Software\\Classes\\Simutronics.Autolaunch\\Shell\\Open\\command\\RealCommand') result = true if real_launch_cmd and not real_launch_cmd.empty? result = result && Wine.registry_puts('HKEY_LOCAL_MACHINE\\Software\\Classes\\Simutronics.Autolaunch\\Shell\\Open\\command\\', real_launch_cmd) result = result && Wine.registry_puts('HKEY_LOCAL_MACHINE\\Software\\Classes\\Simutronics.Autolaunch\\Shell\\Open\\command\\RealCommand', '') end return result else return false end end |
.unlink_from_sge ⇒ Boolean
Unlinks the application from the Simutronics Game Engine (SGE) on Windows or Wine.
This method checks if the application is linked to SGE. If it is, it attempts to unlink it by modifying the Windows registry or using Wine’s registry functions.
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 |
# File 'lib/lich.rb', line 373 def Lich.unlink_from_sge if defined?(Win32) if Win32.admin? begin launcher_key = Win32.RegOpenKeyEx(:hKey => Win32::HKEY_LOCAL_MACHINE, :lpSubKey => 'Software\\Simutronics\\Launcher', :samDesired => (Win32::KEY_ALL_ACCESS | Win32::KEY_WOW64_32KEY))[:phkResult] real_directory = Win32.RegQueryValueEx(:hKey => launcher_key, :lpValueName => 'RealDirectory')[:lpData] if real_directory.nil? or real_directory.empty? # not linked return true end r = Win32.RegSetValueEx(:hKey => launcher_key, :lpValueName => 'Directory', :dwType => Win32::REG_SZ, :lpData => real_directory) return false unless (r == 0) r = Win32.RegDeleteValue(:hKey => launcher_key, :lpValueName => 'RealDirectory') return (r == 0) ensure Win32.RegCloseKey(:hKey => launcher_key) rescue nil end else begin r = Win32.GetModuleFileName file = ((r[:return] > 0) ? r[:lpFilename] : 'rubyw.exe') params = "#{$PROGRAM_NAME.split(/\/|\\/).last} --unlink-from-sge" r = Win32.ShellExecuteEx(:lpVerb => 'runas', :lpFile => file, :lpDirectory => LICH_DIR.tr("/", "\\"), :lpParameters => params, :fMask => Win32::SEE_MASK_NOCLOSEPROCESS) if r[:return] > 0 process_id = r[:hProcess] sleep 0.2 while Win32.GetExitCodeProcess(:hProcess => process_id)[:lpExitCode] == Win32::STILL_ACTIVE sleep 3 else Win32.ShellExecute(:lpOperation => 'runas', :lpFile => file, :lpDirectory => LICH_DIR.tr("/", "\\"), :lpParameters => params) sleep 6 end rescue Lich.msgbox(:message => $!) end end elsif defined?(Wine) real_launch_dir = Wine.registry_gets('HKEY_LOCAL_MACHINE\\Software\\Simutronics\\Launcher\\RealDirectory') result = true if real_launch_dir and not real_launch_dir.empty? result = result && Wine.registry_puts('HKEY_LOCAL_MACHINE\\Software\\Simutronics\\Launcher\\Directory', real_launch_dir) result = result && Wine.registry_puts('HKEY_LOCAL_MACHINE\\Software\\Simutronics\\Launcher\\RealDirectory', '') end return result else return false end end |
.win32_launch_method ⇒ String?
Retrieves the current win32 launch method from the database.
723 724 725 726 727 728 729 730 731 |
# File 'lib/lich.rb', line 723 def Lich.win32_launch_method begin val = Lich.db.get_first_value("SELECT value FROM lich_settings WHERE name='win32_launch_method';") rescue SQLite3::BusyException sleep 0.1 retry end val end |
.win32_launch_method=(val) ⇒ nil
Sets the win32 launch method in the database.
740 741 742 743 744 745 746 747 |
# File 'lib/lich.rb', line 740 def Lich.win32_launch_method=(val) begin Lich.db.execute("INSERT OR REPLACE INTO lich_settings(name,value) values('win32_launch_method',?);", [val.to_s.encode('UTF-8')]) rescue SQLite3::BusyException sleep 0.1 retry end end |