Versione: Jet
Autore/i: N/D
Informazioni:
Lo script permette di diminuire il peso di compressione dei file =)
Istruzioni:
Inserite lo script sotto Material.
Istruzioni all'interno dello script.
Script:
#===============================================================================
# RVDATA2 Compression
# By Jet10985 (Jet)
#===============================================================================
# This script will compress .rvdata2 files in your data directory, to save space.
# This script also compresses new save files.
# This script has: 0 customization options.
#===============================================================================
# Overwritten Methods:
# None
#-------------------------------------------------------------------------------
# Aliased methods:
# Object: load_data, save_data
# DataManager: load_game, save_game, load_header
#===============================================================================
=begin
This script will compress .rvdata2 everytime the game is started in TEST MODE.
This is to make sure the files are of the latest version.
--------------------------------------------------------------------------------
Before releasing your game, or releasing updates, you should run the game
in test mode to update the compressed files.
Before compiling your game, you should remove (DO NOT DELETE) the regular
.rvdata2 files.
--------------------------------------------------------------------------------
This script does not compress Scripts.rvdata2, do not remove it when you
release your game.
--------------------------------------------------------------------------------
This script will also compress save files, which means if you remove this script
and then attempt to load a save game that was made while this script was active,
it won't work.
=end
if $TEST
array = Dir.entries("Data")
array.each {|a|
next if [".", ".."].include?(a)
next unless !a.include?(".crvdata2") && !a.include?("Scripts.rvdata2")
if File.directory?("Data/#{a}")
Dir.entries("Data/#{a}").each {|v|
next if [".", ".."].include?(v)
array.push("#{a}/#{v}")
}
next
end
t = Zlib::Deflate.deflate(Marshal.dump(load_data("Data/#{a}")), 9)
save_data(t, "Data/#{a.gsub(".rvdata2", "")}.crvdata2")
}
end
class Object
alias jet1828_load_data load_data
def load_data(string)
return $RGSS_SCRIPTS if string.include?("Scripts")
string.gsub!(".rvdata2", ".crvdata2")
f = Zlib::Inflate.inflate(jet1828_load_data(string))
return Marshal.load(f)
end
alias jet1838_save_data save_data
def save_data(var, file)
f = Zlib::Deflate.deflate(Marshal.dump(var), 9)
jet1838_save_data(f, "#{file.gsub(".rvdata", "")}.crvdata")
end
end
module JetSaveMarshal
def self.dump(object, io)
Marshal.dump(Zlib::Deflate.deflate(Marshal.dump(object), 9), io)
end
def self.load(io)
return Marshal.load(Zlib::Inflate.inflate(Marshal.load(io)))
end
end
class << DataManager
alias jet2846_save_game save_game
def save_game(*args, &block)
old_marshal = Object.const_get(:Marshal)
DataManager.const_set(:Marshal, JetSaveMarshal)
ret = jet2846_save_game(*args, &block)
DataManager.const_set(:Marshal, old_marshal)
return ret
end
alias jet2846_load_game load_game
def load_game(*args, &block)
old_marshal = Object.const_get(:Marshal)
DataManager.const_set(:Marshal, JetSaveMarshal)
ret = jet2846_load_game(*args, &block)
DataManager.const_set(:Marshal, old_marshal)
return ret
end
alias jet2846_load_header load_header
def load_header(*args, &block)
old_marshal = Object.const_get(:Marshal)
DataManager.const_set(:Marshal, JetSaveMarshal)
ret = jet2846_load_header(*args, &block)
DataManager.const_set(:Marshal, old_marshal)
return ret
end
end













