mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 13:15:01 +00:00
Tweaked plugin manager error code, fixed type from previous commit
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,6 +1,7 @@
|
|||||||
# Audio and Graphics folders
|
# Audio, Graphics and Plugins folders
|
||||||
Audio/
|
Audio/
|
||||||
Graphics/
|
Graphics/
|
||||||
|
Plugins/
|
||||||
|
|
||||||
# Data folder, but not Data/Scripts folder
|
# Data folder, but not Data/Scripts folder
|
||||||
Data/*
|
Data/*
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ def pbGetExceptionMessage(e,_script="")
|
|||||||
end
|
end
|
||||||
|
|
||||||
def pbPrintException(e)
|
def pbPrintException(e)
|
||||||
premessage = "\r\n=================\r\n\r\n[#{Time.now}]\r\n"
|
|
||||||
emessage = ""
|
emessage = ""
|
||||||
if $EVENTHANGUPMSG && $EVENTHANGUPMSG!=""
|
if $EVENTHANGUPMSG && $EVENTHANGUPMSG!=""
|
||||||
emessage = $EVENTHANGUPMSG # Message with map/event ID generated elsewhere
|
emessage = $EVENTHANGUPMSG # Message with map/event ID generated elsewhere
|
||||||
@@ -26,27 +25,34 @@ def pbPrintException(e)
|
|||||||
else
|
else
|
||||||
emessage = pbGetExceptionMessage(e)
|
emessage = pbGetExceptionMessage(e)
|
||||||
end
|
end
|
||||||
btrace = ""
|
# begin message formatting
|
||||||
if e.backtrace
|
|
||||||
maxlength = ($INTERNAL) ? 25 : 10
|
|
||||||
e.backtrace[0,maxlength].each { |i| btrace += "#{i}\r\n" }
|
|
||||||
end
|
|
||||||
btrace.gsub!(/Section(\d+)/) { $RGSS_SCRIPTS[$1.to_i][1] } rescue nil
|
|
||||||
message = "[Pokémon Essentials version #{Essentials::VERSION}]\r\n"
|
message = "[Pokémon Essentials version #{Essentials::VERSION}]\r\n"
|
||||||
message += "#{Essentials::ERROR_TEXT}\r\n" # For third party scripts to add to
|
message += "#{Essentials::ERROR_TEXT}\r\n" # For third party scripts to add to
|
||||||
message += "Exception: #{e.class}\r\n"
|
message += "Exception: #{e.class}\r\n"
|
||||||
message += "Message: #{emessage}\r\n"
|
message += "Message: #{emessage}\r\n"
|
||||||
message += "\r\nBacktrace:\r\n#{btrace}"
|
# show last 10/25 lines of backtrace
|
||||||
errorlog = "errorlog.txt"
|
message += "\r\nBacktrace:\r\n"
|
||||||
if (Object.const_defined?(:RTP) rescue false)
|
btrace = ""
|
||||||
errorlog = RTP.getSaveFileName("errorlog.txt")
|
if e.backtrace
|
||||||
|
maxlength = ($INTERNAL) ? 25 : 10
|
||||||
|
e.backtrace[0, maxlength].each { |i| btrace += "#{i}\r\n" }
|
||||||
end
|
end
|
||||||
File.open(errorlog,"ab") { |f| f.write(premessage); f.write(message) }
|
btrace.gsub!(/Section(\d+)/) { $RGSS_SCRIPTS[$1.to_i][1] } rescue nil
|
||||||
errorlogline = errorlog.gsub!("/", "\\")
|
message += btrace
|
||||||
|
# output to log
|
||||||
|
errorlog = "errorlog.txt"
|
||||||
|
errorlog = RTP.getSaveFileName("errorlog.txt") if (Object.const_defined?(:RTP) rescue false)
|
||||||
|
File.open(errorlog, "ab") do |f|
|
||||||
|
f.write("\r\n=================\r\n\r\n[#{Time.now}]\r\n")
|
||||||
|
f.write(message)
|
||||||
|
end
|
||||||
|
# format/censor the error log directory
|
||||||
|
errorlogline = errorlog.gsub("/", "\\")
|
||||||
errorlogline.sub!(Dir.pwd + "\\", "")
|
errorlogline.sub!(Dir.pwd + "\\", "")
|
||||||
errorlogline.sub!(pbGetUserName, "USERNAME")
|
errorlogline.sub!(pbGetUserName, "USERNAME")
|
||||||
errorlogline = "\r\n" + errorlogline if errorlogline.length > 20
|
errorlogline = "\r\n" + errorlogline if errorlogline.length > 20
|
||||||
print("#{message}\r\nThis exception was logged in #{errorlogline}.\r\nHold Ctrl after closing this message to copy it to the clipboard.")
|
# output message
|
||||||
|
print("#{message}\r\nThis exception was logged in #{errorlogline}.\r\nHold Ctrl when closing this message to copy it to the clipboard.")
|
||||||
# Give a ~500ms coyote time to start holding Control
|
# Give a ~500ms coyote time to start holding Control
|
||||||
t = System.delta
|
t = System.delta
|
||||||
until (System.delta - t) >= 500000
|
until (System.delta - t) >= 500000
|
||||||
|
|||||||
@@ -432,10 +432,10 @@ module PluginManager
|
|||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
def self.pluginErrorMsg(name, script)
|
def self.pluginErrorMsg(name, script)
|
||||||
# begin message formatting
|
# begin message formatting
|
||||||
msg = "[Pokémon Essentials version #{Essentials::VERSION}]\r\n"
|
message = "[Pokémon Essentials version #{Essentials::VERSION}]\r\n"
|
||||||
msg += "#{Essentials::ERROR_TEXT}\r\n" # For third party scripts to add to
|
message += "#{Essentials::ERROR_TEXT}\r\n" # For third party scripts to add to
|
||||||
msg += "Error in Plugin [#{name}]:\r\n"
|
message += "Error in Plugin [#{name}]:\r\n"
|
||||||
msg += "#{$!.class} occurred.\r\n"
|
message += "#{$!.class} occurred.\r\n"
|
||||||
# go through message content
|
# go through message content
|
||||||
for line in $!.message.split("\r\n")
|
for line in $!.message.split("\r\n")
|
||||||
next if !line || line == ""
|
next if !line || line == ""
|
||||||
@@ -445,26 +445,34 @@ module PluginManager
|
|||||||
err.gsub!(n, "") if n
|
err.gsub!(n, "") if n
|
||||||
err = err.capitalize if err.is_a?(String) && !err.empty?
|
err = err.capitalize if err.is_a?(String) && !err.empty?
|
||||||
linum = n ? "Line #{n}: " : ""
|
linum = n ? "Line #{n}: " : ""
|
||||||
msg += "#{linum}#{err}: #{lms}\r\n"
|
message += "#{linum}#{err}: #{lms}\r\n"
|
||||||
end
|
|
||||||
# show trace
|
|
||||||
msg += "\r\nFull trace can be found below:\r\n"
|
|
||||||
for bck in $!.backtrace
|
|
||||||
msg += "#{bck}\r\n"
|
|
||||||
end
|
end
|
||||||
|
# show last 10 lines of backtrace
|
||||||
|
message += "\r\nBacktrace:\r\n"
|
||||||
|
$!.backtrace[0, 10].each { |i| message += "#{i}\r\n" }
|
||||||
# output to log
|
# output to log
|
||||||
errorlog = "errorlog.txt"
|
errorlog = "errorlog.txt"
|
||||||
if (Object.const_defined?(:RTP) rescue false)
|
errorlog = RTP.getSaveFileName("errorlog.txt") if (Object.const_defined?(:RTP) rescue false)
|
||||||
errorlog = RTP.getSaveFileName("errorlog.txt")
|
File.open(errorlog, "ab") do |f|
|
||||||
|
f.write("\r\n=================\r\n\r\n[#{Time.now}]\r\n")
|
||||||
|
f.write(message)
|
||||||
end
|
end
|
||||||
premessage = "\r\n=================\r\n\r\n[#{Time.now}]\r\n"
|
# format/censor the error log directory
|
||||||
File.open(errorlog, "ab") { |f| f.write(premessage); f.write(msg) }
|
errorlogline = errorlog.gsub("/", "\\")
|
||||||
errorlogline = errorlog.gsub!("/", "\\")
|
|
||||||
errorlogline.sub!(Dir.pwd + "\\", "")
|
errorlogline.sub!(Dir.pwd + "\\", "")
|
||||||
errorlogline.sub!(pbGetUserName, "USERNAME")
|
errorlogline.sub!(pbGetUserName, "USERNAME")
|
||||||
errorlogline = "\r\n" + errorlogline if errorlogline.length > 20
|
errorlogline = "\r\n" + errorlogline if errorlogline.length > 20
|
||||||
# output message
|
# output message
|
||||||
return "#{msg}\r\nThis exception was logged in #{errorlogline}.\r\nHold Ctrl after closing this message to copy it to the clipboard."
|
print("#{message}\r\nThis exception was logged in #{errorlogline}.\r\nHold Ctrl when closing this message to copy it to the clipboard.")
|
||||||
|
# Give a ~500ms coyote time to start holding Control
|
||||||
|
t = System.delta
|
||||||
|
until (System.delta - t) >= 500000
|
||||||
|
Input.update
|
||||||
|
if Input.press?(Input::CTRL)
|
||||||
|
Input.clipboard = message
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Used to read the metadata file
|
# Used to read the metadata file
|
||||||
@@ -493,23 +501,23 @@ module PluginManager
|
|||||||
else # Push dependency type, name and version of plugin dependency
|
else # Push dependency type, name and version of plugin dependency
|
||||||
meta[:dependencies].push([data[2].downcase.to_sym, data[0], data[1]])
|
meta[:dependencies].push([data[2].downcase.to_sym, data[0], data[1]])
|
||||||
end
|
end
|
||||||
when "EXACT"
|
when 'EXACT'
|
||||||
next if data.length < 2 # Exact dependencies must have a version given; ignore if not
|
next if data.length < 2 # Exact dependencies must have a version given; ignore if not
|
||||||
meta[:dependencies] = [] if !meta[:dependencies]
|
meta[:dependencies] = [] if !meta[:dependencies]
|
||||||
meta[:dependencies].push([:exact, data[0], data[1]])
|
meta[:dependencies].push([:exact, data[0], data[1]])
|
||||||
when "OPTIONAL"
|
when 'OPTIONAL'
|
||||||
next if data.length < 2 # Optional dependencies must have a version given; ignore if not
|
next if data.length < 2 # Optional dependencies must have a version given; ignore if not
|
||||||
meta[:dependencies] = [] if !meta[:dependencies]
|
meta[:dependencies] = [] if !meta[:dependencies]
|
||||||
meta[:dependencies].push([:optional, data[0], data[1]])
|
meta[:dependencies].push([:optional, data[0], data[1]])
|
||||||
when 'CONFLICTS'
|
when 'CONFLICTS'
|
||||||
meta[:incompatibilities] = [] if !meta[:incompatibilities]
|
meta[:incompatibilities] = [] if !meta[:incompatibilities]
|
||||||
data.each { |value| meta[:incompatibilities].push(value) if value && !value.empty? }
|
data.each { |value| meta[:incompatibilities].push(value) if value && !value.empty? }
|
||||||
when "SCRIPTS"
|
when 'SCRIPTS'
|
||||||
meta[:scripts] = [] if !meta[:scripts]
|
meta[:scripts] = [] if !meta[:scripts]
|
||||||
data.each { |scr| meta[:scripts].push(scr) }
|
data.each { |scr| meta[:scripts].push(scr) }
|
||||||
when "CREDITS"
|
when 'CREDITS'
|
||||||
meta[:credits] = data
|
meta[:credits] = data
|
||||||
when "LINK", "WEBSITE"
|
when 'LINK', 'WEBSITE'
|
||||||
meta[:link] = data[0]
|
meta[:link] = data[0]
|
||||||
else
|
else
|
||||||
meta[property.downcase.to_sym] = data[0]
|
meta[property.downcase.to_sym] = data[0]
|
||||||
@@ -616,7 +624,6 @@ module PluginManager
|
|||||||
return false if !$DEBUG || safeExists?("Game.rgssad")
|
return false if !$DEBUG || safeExists?("Game.rgssad")
|
||||||
return true if !safeExists?("Data/PluginScripts.rxdata")
|
return true if !safeExists?("Data/PluginScripts.rxdata")
|
||||||
return true if Input.press?(Input::CTRL)
|
return true if Input.press?(Input::CTRL)
|
||||||
ret = false
|
|
||||||
# analyze whether or not to push recompile
|
# analyze whether or not to push recompile
|
||||||
mtime = File.mtime("Data/PluginScripts.rxdata")
|
mtime = File.mtime("Data/PluginScripts.rxdata")
|
||||||
for o in order
|
for o in order
|
||||||
@@ -624,17 +631,18 @@ module PluginManager
|
|||||||
scr = plugins[o][:scripts]
|
scr = plugins[o][:scripts]
|
||||||
dir = plugins[o][:dir]
|
dir = plugins[o][:dir]
|
||||||
for sc in scr
|
for sc in scr
|
||||||
ret = true if File.mtime("#{dir}/#{sc}") > mtime
|
return true if File.mtime("#{dir}/#{sc}") > mtime
|
||||||
end
|
end
|
||||||
ret = true if File.mtime("#{dir}/meta.txt") > mtime
|
return true if File.mtime("#{dir}/meta.txt") > mtime
|
||||||
end
|
end
|
||||||
# return result
|
return false
|
||||||
return ret
|
|
||||||
end
|
end
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Check if plugins need compiling
|
# Check if plugins need compiling
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
def self.compilePlugins(order, plugins)
|
def self.compilePlugins(order, plugins)
|
||||||
|
echoln ""
|
||||||
|
echo 'Compiling plugin scripts...'
|
||||||
scripts = []
|
scripts = []
|
||||||
# go through the entire order one by one
|
# go through the entire order one by one
|
||||||
for o in order
|
for o in order
|
||||||
@@ -656,6 +664,8 @@ module PluginManager
|
|||||||
File.open("Data/PluginScripts.rxdata", 'wb') { |f| Marshal.dump(scripts, f) }
|
File.open("Data/PluginScripts.rxdata", 'wb') { |f| Marshal.dump(scripts, f) }
|
||||||
# collect garbage
|
# collect garbage
|
||||||
GC.start
|
GC.start
|
||||||
|
echoln ' done.'
|
||||||
|
echoln ""
|
||||||
end
|
end
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Check if plugins need compiling
|
# Check if plugins need compiling
|
||||||
@@ -685,23 +695,7 @@ module PluginManager
|
|||||||
begin
|
begin
|
||||||
eval(code, TOPLEVEL_BINDING, fname)
|
eval(code, TOPLEVEL_BINDING, fname)
|
||||||
rescue Exception # format error message to display
|
rescue Exception # format error message to display
|
||||||
Graphics.update
|
self.pluginErrorMsg(name, sname)
|
||||||
t = Thread.new do
|
|
||||||
print(self.pluginErrorMsg(name, sname))
|
|
||||||
# Give a ~500ms coyote time to start holding Control
|
|
||||||
tm = System.delta
|
|
||||||
until (System.delta - tm) >= 500000
|
|
||||||
Input.update
|
|
||||||
if Input.press?(Input::CTRL)
|
|
||||||
Input.clipboard = message
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Thread.exit
|
|
||||||
end
|
|
||||||
while t.status
|
|
||||||
Graphics.update
|
|
||||||
end
|
|
||||||
Kernel.exit! true
|
Kernel.exit! true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ module GameData
|
|||||||
# Check for TM/HM type icons
|
# Check for TM/HM type icons
|
||||||
if item_data.is_machine?
|
if item_data.is_machine?
|
||||||
prefix = "machine"
|
prefix = "machine"
|
||||||
if item.data.is_HM?
|
if item_data.is_HM?
|
||||||
prefix = "machine_hm"
|
prefix = "machine_hm"
|
||||||
elsif item_data.is_TR?
|
elsif item_data.is_TR?
|
||||||
prefix = "machine_tr"
|
prefix = "machine_tr"
|
||||||
|
|||||||
Reference in New Issue
Block a user