#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:= # DREAM for Save Files by Blizzard # Version: 4.5 # Type: Encryptor / Decryptor # uses DREAM v4.4 or higher # Date 22.7.2006 # Date v2.0: 25.1.2007 # Date v3.0: 20.8.2007 # Date v3.0b: 24.9.2007 # Date v4.5: 23.3.2019 #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:= # # This work is licensed under BSD License 2.0: # # #---------------------------------------------------------------------------- # # # # Copyright (c) Boris "Blizzard" Mikić # # All rights reserved. # # # # Redistribution and use in source and binary forms, with or without # # modification, are permitted provided that the following conditions are met: # # # # 1. Redistributions of source code must retain the above copyright notice, # # this list of conditions and the following disclaimer. # # # # 2. Redistributions in binary form must reproduce the above copyright # # notice, this list of conditions and the following disclaimer in the # # documentation and/or other materials provided with the distribution. # # # # 3. Neither the name of the copyright holder nor the names of its # # contributors may be used to endorse or promote products derived from # # this software without specific prior written permission. # # # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # # POSSIBILITY OF SUCH DAMAGE. # # # #---------------------------------------------------------------------------- # # You may use this script for both non-commercial and commercial products # without limitations as long as you fulfill the conditions presented by the # above license. The "complete" way to give credit is to include the license # somewhere in your product (e.g. in the credits screen), but a "simple" way # is also acceptable. The "simple" way to give credit is as follows: # # DREAM for Save Files licensed under BSD License 2.0 # Copyright (c) Boris "Blizzard" Mikić # # Alternatively, if your font doesn't support diacritic characters, you may # use this variant: # # DREAM for Save Files licensed under BSD License 2.0 # Copyright (c) Boris "Blizzard" Mikic # # In general other similar variants are allowed as long as it is clear who # the creator is (e.g. "DREAM for Save Files created by Blizzard" is # acceptable). But if possible, prefer to use one of the two variants listed # above. # # If you fail to give credit and/or claim that this work was created by you, # this may result in legal action and/or payment of damages even though this # work is free of charge to use normally. # #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:= # # DO TOUCH THE VALUE BELOW! If you change the required version to a lower # value your script WILL malfunction, because older DREAM version don't have # all the methods and functions required by this script. Required_DREAM_Version = 4.4 # # # Special Thanks to: # # - the makers of the XVI32 Hex Editor # (without it, I couldn't have tested this script) # # # Compatibility: # # 98% compatible with SDK 1.x. 90% compatible with SDK 2.x. 99% compatible # with everything else. WILL corrupt your old savegames. Can cause # incompatibility issues with custom save screens. NEEDS DREAM of the # provided version or higher. Files will be saved into dream4 format with # .dream4 extension. Cannot decode dream2 and dream3 files where extra data # was added, but normal dream2 and dream3 files can be decoded. # # # Features: # # - uses the Double Random Encryption Algorythm Module (DREAM) to encrypt # important save data every time it is saved # - makes it harder to hack saved files (even experienced hackers will have a # hard time hacking important data from save files encrypted with DREAM) # - great for RMXP MMORPGs as alternative for saving data on the server # # new in v2.0: # - uses DREAM v3.0 which is far more powerful than DREAM v2.0, because the # .dream3 format is a format in which ALL the saved data is encrypted # - your savefiles will be saved into files with .dream3 extension # # new in v3.0: # - uses the even more powerful DREAM v4.0 # - faster, better, safer: # -> new, much faster algorithm which's speed doesn't depend on the chosen # encryption pattern anymore # -> re-coded to avoid the built-in RGSS bug with conditioning # -> new additional encryption of encrypted data # - your savefiles will be saved now into files with .dream4 extension # - displays "File corrupted!" instead of crashing when files are corrupted # - can decode dream2 and dream3 format # # new in v3.0b: # - now uses DREAM v4.1 # - direct implementation into DREAM # - now beta # # new in v4.5: # - now uses DREAM v4.4 # - added new license # - added usage and crediting instructions # # # Configuration: # # Open the Scene_Title script and find these lines or similar: # # for i in 0..3 # if FileTest.exist?("Save#{i+1}.rxdata") # @continue_enabled = true # end # end # # Change this line: # if FileTest.exist?("Save#{i+1}.rxdata") # into this one: # if FileTest.exist?("#{SAVE_NAME}#{i+1}.dream4") # # Change SAVE_NAME to the name your savefiles should have. i.e. Making it # "The Last_Elf" will make your savefiles look like "The Last_Elf.dream4". # # Find the part that needs to be configured and add additional data if you # are using additional savedata. Include all additional data AS STRINGS in # the array EXTRA_DATA. Example: # # EXTRA_DATA = ['$game_weapons', '$game_armors', '$game_items'] # # # IMPORTANT NOTES: # # This script will encrypt all save data and render them 100% unusable by any # earlier version of your game that DOES NOT have this script. If you are # using save-game update of earlier versions, this script will make further # updates of old savegames IMPOSSIBLE, because they can't be loaded at all. # Please use a DREAM save file converter to convert usual save files into a # DREAM readable format. Note that this version of this script can also READ # save files encrypted in dream2 and dream3 format only if their extension is # being changed to .dream4 and their names are changed like configured below. # Note that any extra data from dream2 and dream3 files will not be read. # This script will save any files into .dream4 format. Changing this script # can easily destroy your savefiles and it is not recommended. # # # If you find any bugs, please report them here: # http://www.chaosproject.co.nr #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:= #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: # START Configuration #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: EXTRA_DATA = [] SAVE_NAME = 'Save' #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: # END Configuration #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: #============================================================================== # module DREAM #============================================================================== module DREAM def self.self_extract data = load_data('Data/DREAM_ext.rb') file = File.open('DREAM_ext.rb', 'wb') file.write(data) file.close require File.expand_path('DREAM_ext.rb') load_DREAM end end DREAM.self_extract #============================================================================== # Scene_File #============================================================================== class Scene_File def make_filename(file_index) return "#{SAVE_NAME}#{file_index + 1}.dream4" end end #============================================================================== # Scene_Save #============================================================================== class Scene_Save < Scene_File def write_save_data(file) DREAM.save_game(file) end end #============================================================================== # Scene_Load #============================================================================== class Scene_Load < Scene_File def read_save_data(file) DREAM.load_game(file) end end #============================================================================== # Window_SaveFile #============================================================================== class Window_SaveFile < Window_Base def initialize(file_index, filename) super(0, 64 + file_index%4*104, 640, 104) self.contents = Bitmap.new(width - 32, height - 32) if $fontface != nil self.contents.font.name = $fontface self.contents.font.size = $fontsize elsif $defaultfonttype != nil self.contents.font.name = $defaultfonttype self.contents.font.size = $defaultfontsize end @file_index, @filename = file_index, "#{SAVE_NAME}#{file_index + 1}.dream4" @time_stamp, @file_exist = Time.at(0), FileTest.exist?(@filename) if @file_exist begin file = File.open(@filename, 'r') @time_stamp = file.mtime @characters, @frame_count, @game_system, @game_switches, @game_variables, @game_party, @game_map, @game_player = DREAM.data(file) @total_sec = @frame_count / Graphics.frame_rate file.close refresh rescue @file_exist = false refresh self.contents.draw_text(4, 20, 600, 32, 'File corrupted!', 1) time_string = @time_stamp.strftime('%Y/%m/%d %H:%M') self.contents.draw_text(4, 40, 600, 32, time_string, 2) end else refresh end @selected = false end end