-
-
Save cacao-soft/475050eb0e45dd7c043fa1dbbc06bdf3 to your computer and use it in GitHub Desktop.
RGSS3 スクリプト 'Cache' の 106 行目で RGSSError が発生しました。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# バックトレース情報を追加 | |
module Cache | |
def self.normal_bitmap(path) | |
@cache[path] = Bitmap.new(path) unless include?(path) | |
rescue RGSSError => e | |
e.message << "\n\nPath: #{path.inspect}\n\n" << caller[2,5].map do |s| | |
s.gsub(/^{(\d+)}/) { "{#{$1}:#{$RGSS_SCRIPTS[$1.to_i][1]}}" } | |
end.join("\n") | |
raise | |
else | |
@cache[path] | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ファイルからのビットマップ生成に失敗した場合、キャッシュクリアを実行し再試行する | |
# それでも失敗する場合、再起動を促すメッセージを表示し透明な代替画像を使用する | |
module Cache | |
def self.normal_bitmap(path) | |
@cache[path] = try_load(path) unless include?(path) | |
@cache[path] | |
rescue RGSSError | |
@__errors ||= {} | |
unless @__errors[path] | |
msgbox( | |
"ビットマップの生成に失敗しました\n", | |
"ゲームを再起動してください\n\n", | |
"Path: #{path.inspect}\n\n", | |
caller[2,5].join("\n") | |
) | |
@__errors[path] = true | |
end | |
@cache[path] = empty_bitmap | |
end | |
def self.try_load(path) | |
Bitmap.new(path) | |
rescue RGSSError | |
clear # 使用中の画像解放防止のためGCに任せる | |
Bitmap.new(path) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# エラー情報を表示して処理を続行 | |
# ゲームを再起動するまで透明な画像が使用される | |
# アニメーションなどはキャッシュされないため使う度にエラー表示されます | |
module Cache | |
def self.normal_bitmap(path) | |
@cache[path] = Bitmap.new(path) unless include?(path) | |
rescue RGSSError | |
msgbox "ビットマップの生成に失敗しました\n\n", | |
"Path: #{path.inspect}\n\n", caller[2,5].join("\n") | |
@cache[path] = empty_bitmap | |
else | |
@cache[path] | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# エラー情報を表示して処理を続行 | |
# ゲームを再起動するまで透明な画像が使用される | |
# エラーを表示したかを保持しエラーは一度だけ表示する | |
module Cache | |
def self.normal_bitmap(path) | |
@cache[path] = Bitmap.new(path) unless include?(path) | |
rescue RGSSError | |
@__errors ||= {} | |
unless @__errors[path] | |
msgbox "ビットマップの生成に失敗しました\n\n", | |
"Path: #{path.inspect}\n\n", caller[2,5].join("\n") | |
@__errors[path] = true | |
end | |
@cache[path] = empty_bitmap | |
else | |
@cache[path] | |
end | |
end |
暗号化した状態ですべての画像が読み込めるかテストしてみても良いかも
unless File.exist?("Game.rgss3a")
File.open("list.txt", "w") do |f|
f.puts Dir.glob("Graphics/**/*.*[gfp]")
end
end
sp = Sprite.new
File.readlines("list.txt").each do |path|
path.chomp!
puts path
sp.bitmap = Bitmap.new(path)
Graphics.update
sp.bitmap.dispose
end
sp.dispose
puts "Complete"
Graphics フォルダにテキストが含まれることがあるから txt を含めないようにした
暗号化した状態でコンソール表示するにはGame.exe console
とすれば良い。
ショートカット作ってリンク先にconsole
加えても良い。
いろいろ作ったけどcache_error_fixを入れておけば大丈夫だと思う。
テストコード
Dir.glob("Graphics/**/*.*") do |path|
puts path
Cache.normal_bitmap(path)
end
この4K画像を50個くらいにコピーして実行してみるとエラー出ると思う。
テキストファイルも入れて実行するとエラーメッセージが表示されるはず。
どちらのエラーが発生してもcache_error_fix
を導入していれば、ゲームプレイは続行できるはず。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
itmap.new(width, height)
で大きいサイズを指定した時にも発生した。cache_error.rb
ignore_cache_error.rb
ignore_cache_error2.rb