Add files via upload

This commit is contained in:
bakustarver 2024-12-03 03:59:12 +02:00 committed by GitHub
parent 970b6b58ce
commit 69b072aec0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 68 additions and 31 deletions

View file

@ -18,15 +18,19 @@ module Preload
.include?('Win32API.new(self.steam_dll_name') .include?('Win32API.new(self.steam_dll_name')
# .remove!, # .remove!,
.replace!("achievements.rb"), .replace!("achievements.rb"),
# Patch.new("Advanced Text System fix") Patch.new("Advanced Text System fix")
# .include?('Advanced Text System') .include?('Advanced Text System')
# .include?('modern algebra (rmrk.net)') .include?('modern algebra (rmrk.net)')
# # .remove!, # # .remove!,
# .replace!("Advanced-Text-System.rb"), .replace!("Advanced-Text-System-.rb"),
Patch.new("NWConst::Warp plugin fix") Patch.new("NWConst::Warp plugin fix")
.include?('module NWConst::Warp') .include?('module NWConst::Warp')
.include?('@popup_confirm_window.select(0)') .include?('@popup_confirm_window.select(0)')
.sub!('@popup_confirm_window.select(0)', "items = @popup_confirm_window.instance_variable_get(:@list)\nif items.is_a?(Array) && !items.empty?\n@popup_confirm_window.select(0)\nend"), .sub!('@popup_confirm_window.select(0)', "items = @popup_confirm_window.instance_variable_get(:@list)\nif items.is_a?(Array) && !items.empty?\n@popup_confirm_window.select(0)\nend"),
Patch.new("class Scene_MultiPartyEdit") ##パーティ分割_scene.rb
.include?('class Scene_MultiPartyEdit < Scene_MenuBase')
.include?('@popup_confirm_window.show.activate.select(0)')
.sub!('@popup_confirm_window.show.activate.select(0)', "if @popup_confirm_window.show.activate.is_a?(Array) && @popup_confirm_window.show.activate.empty?\n@popup_confirm_window.show.activate.select(0)\nend"),
Patch.new("NWRegexpBaseItemfix plugin fix") Patch.new("NWRegexpBaseItemfix plugin fix")
.include?('module NWConst::Shop') .include?('module NWConst::Shop')
# .replace!("NWRegexpBaseItemfix.rb"), # .replace!("NWRegexpBaseItemfix.rb"),
@ -76,10 +80,12 @@ module Preload
.sub!("if contents_width > 0 && contents_height > 0", "if contents_height > 10000\nself.contents = Bitmap.new(1, 1)\nelsif contents_width > 0 && contents_height > 0") .sub!("if contents_width > 0 && contents_height > 0", "if contents_height > 10000\nself.contents = Bitmap.new(1, 1)\nelsif contents_width > 0 && contents_height > 0")
.sub!("result = text.to_s.clone","result = text.to_s.clone\nresult = result.dup if result.frozen?"), .sub!("result = text.to_s.clone","result = text.to_s.clone\nresult = result.dup if result.frozen?"),
Patch.new("temp bitmap load crash fix monster girl paradox disable preview") #ベース/Module Patch.new("temp bitmap load crash fix monster girl paradox disable preview") #ベース/Module
#maybe the memory buffer is filled up too much?? # #maybe the memory buffer is filled up too much??
# .if? {|script| script.name == "Window_Base"} # # .if? {|script| script.name == "Window_Base"}
.include?('thumnail_file = "Save/Save#{Regexp.last_match(1)}.png"') .include?('thumnail_file = "Save/Save#{Regexp')
.sub!("@thumbnails[Regexp.last_match(1).to_i - 1] = Bitmap.new(thumnail_file)", "@thumbnails[Regexp.last_match(1).to_i - 1] = @dummy_thumbnail #Bitmap.new(thumnail_file)"), # .sub!("@thumbnails[Regexp.last_match(1).to_i - 1] = Bitmap.new(thumnail_file)", "@thumbnails[Regexp.last_match(1).to_i - 1] = @dummy_thumbnail #Bitmap.new(thumnail_file)")
.sub!("@thumbnails[Regexp.last_match(1).to_i - 1] = Bitmap.new(thumnail_file)", "@thumbnails[Regexp.last_match(1).to_i - 1] = @dummy_thumbnail #Bitmap.new(thumnail_file)"),
# .replace!("base_Module.rb"),
# .replace!("savebitmanwin32api.rb"), # .replace!("savebitmanwin32api.rb"),
Patch.new("WF-RGSS Exit-EX patch test") #▼ メイン【WF-RGSS】Exit-EX 終了処理 Patch.new("WF-RGSS Exit-EX patch test") #▼ メイン【WF-RGSS】Exit-EX 終了処理
.include?("Win32API.new('System/WFExit','hookExit','v','l')") .include?("Win32API.new('System/WFExit','hookExit','v','l')")
@ -210,6 +216,10 @@ module Preload
.imported?(nil) .imported?(nil)
.include?('text.push(self.to_s.scan(/#<(\S+):/)[0][0].to_s)') .include?('text.push(self.to_s.scan(/#<(\S+):/)[0][0].to_s)')
.remove!, .remove!,
Patch.new("Diesel_ADV")
.imported?(nil)
.include?('Diesel_ADV')
.sub!("b.visible = now", "b.visible = !!now"),
# Patch.new("tktk_bitmap dll test debug") # Patch.new("tktk_bitmap dll test debug")
# .imported?(nil) # .imported?(nil)
# .include?("DLL_NAME = 'tktk_bitmap'") # .include?("DLL_NAME = 'tktk_bitmap'")
@ -232,6 +242,13 @@ module Preload
.include?('class Spriteset_BattleUnit') .include?('class Spriteset_BattleUnit')
.include?('Spriteset_Kiseki') .include?('Spriteset_Kiseki')
.sub!(/\bsuper\b(?!\s*\()/, 'super()'), .sub!(/\bsuper\b(?!\s*\()/, 'super()'),
Patch.new("test subscribe")
.imported?(nil)
.include?("exit if steam.is_subscribed != true")
.remove!,
Patch.new("module ScreenShot")
.imported?(nil)
.include?("module ScreenShot")
.remove!,
] ]
end end

View file

@ -268,16 +268,21 @@ module Preload
# Backup the original source value before encoding, to see if it changes unexpectedly # Backup the original source value before encoding, to see if it changes unexpectedly
original_source = source.dup original_source = source.dup
# puts "Before encoding: source = #{source.inspect}" # Debugging log for source
# Force encode to ASCII-8BIT (binary ASCII), replacing non-ASCII characters with '?' # Force encode to ASCII-8BIT (binary ASCII), replacing non-ASCII characters with '?'
if source.encoding.name != "ASCII-8BIT" if source.encoding.name != "ASCII-8BIT"
begin begin
# puts "Attempting to encode source..."
# Try encoding, but ensure that source remains unchanged if encoding fails # Ensure source is in UTF-8 first to avoid mix of encodings (UTF-8 and ASCII-8BIT)
# source = source.encode("UTF-8", invalid: :replace, undef: :replace, replace: "?")
# Now attempt to encode to ASCII-8BIT (ensure no mix of encodings)
# Force both source and encoded_source to be in the same encoding (UTF-8)
encoded_source = source.encode("ASCII-8BIT", invalid: :replace, undef: :replace, replace: "?") encoded_source = source.encode("ASCII-8BIT", invalid: :replace, undef: :replace, replace: "?")
# If encoding results in an empty string or nil, restore original source # If encoding results in an empty string or nil, restore original source
if encoded_source.nil? || encoded_source.empty? if encoded_source.nil? || encoded_source.empty?
# puts "Warning: 'source' became nil or empty after encoding! Reverting to original source."
source = original_source source = original_source
return return
else else
@ -285,16 +290,17 @@ module Preload
source = encoded_source source = encoded_source
end end
# puts "Encoding successful, source encoding is now: #{source.encoding.name}"
rescue Encoding::UndefinedConversionError, Encoding::InvalidByteSequenceError => e rescue Encoding::UndefinedConversionError, Encoding::InvalidByteSequenceError => e
puts "Encoding failed: #{e.message}" puts "Encoding failed: #{e.message}"
return return
rescue StandardError => e rescue StandardError => e
puts "Unexpected error during encoding: #{e.message}" # puts "Unexpected error during encoding: #{e.message}"
return return
end end
end end
# Check source after encoding to ensure it isn't nil # Check source after encoding to ensure it isn't nil
if source.nil? if source.nil?
# puts "Warning: 'source' is nil after encoding!" # puts "Warning: 'source' is nil after encoding!"
@ -521,6 +527,8 @@ module Preload
# Encodings are a mess in RGSS. Can break Regexp matching # Encodings are a mess in RGSS. Can break Regexp matching
e = script.source.encoding e = script.source.encoding
script.source.force_encoding "ASCII-8BIT" script.source.force_encoding "ASCII-8BIT"
# script.source.force_encoding("UTF-8")
# script.source.encode!("ASCII-8BIT", invalid: :replace, undef: :replace, replace: "?")
# Apply patches # Apply patches
script.source.gsub!(".encode('SHIFT_JIS')", '') script.source.gsub!(".encode('SHIFT_JIS')", '')
@ -551,11 +559,16 @@ module Preload
Dir.mkdir dump unless Dir.exist? dump Dir.mkdir dump unless Dir.exist? dump
fn_format = "%0#{ctx.script_id_digits}d%s%s%s" fn_format = "%0#{ctx.script_id_digits}d%s%s%s"
ctx.each_script do |script| ctx.each_script do |script|
filename = fn_format % [script.index, if script.name.valid_encoding?
script.name.empty? ? "" : " ", filename = fn_format % [script.index,
script.name.tr(NoFilenameChars, "_"), script.name.empty? ? "" : " ",
script.source.empty? ? "" : ".rb"] script.name.tr(NoFilenameChars, "_"),
File.write File.join(dump, filename), script.source script.source.empty? ? "" : ".rb"]
File.write File.join(dump, filename), script.source
else
puts "Invalid encoding for script name: #{script.name.inspect}"
next
end
end end
end end
end end
@ -576,6 +589,8 @@ module Preload
# Initialize # Initialize
@ctx = ctx = Context.new $RGSS_SCRIPTS @ctx = ctx = Context.new $RGSS_SCRIPTS
# ctx.add_script("5555555555555555555555555555555555555555Script1", "puts 'Hello, world!'") # ctx.add_script("5555555555555555555555555555555555555555Script1", "puts 'Hello, world!'")
script_file = '/home/pasha/desktopapps/mkxp-z/cheats/cheat3.rb'
script_file2 = '/home/pasha/desktopapps/mkxp-z/Kawariki-patches/ports/wxexittest.rb'
ctx.read_system ctx.read_system
ctx.read_env ctx.read_env
@ -659,23 +674,28 @@ game_ini_path = find_game_ini_in_directory(_config["gameFolder"].to_s)
def checkini(file_path) def checkini(file_path)
# Check if the file exists # Check if the file path is nil or empty and set it to the current directory if necessary
file_path = file_path.nil? || file_path.empty? ? Dir.pwd : file_path file_path = file_path.nil? || file_path.empty? ? Dir.pwd : file_path
# Check if the path is a valid file and not a directory
if File.exist?(file_path) if File.exist?(file_path)
# Read the content of the file if File.file?(file_path)
input_string = File.read(file_path, encoding: 'ASCII-8BIT') # Read the content of the file
input_string = File.read(file_path, encoding: 'ASCII-8BIT')
# Match the content of the file and return the appropriate value # Match the content of the file and return the appropriate value
# Match the pattern in the input string and return corresponding values if input_string =~ /rvdata2/
if input_string =~ /rvdata2/ return 3
return 3 elsif input_string =~ /rvdata/
elsif input_string =~ /rvdata/ return 2
return 2 elsif input_string =~ /rxdata/
elsif input_string =~ /rxdata/ return 1
return 1 else
return 3 # Return 3 if no pattern matches
end
else else
return 3 # Return nil if none of the patterns match puts "The specified path is a directory, not a file."
return 3
end end
else else
puts "File does not exist!" puts "File does not exist!"