Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

RXDATA update

Hello Everyone! I am having a big problem and hopefully one of you veterns can help. Basicly i have a rpg that i am making. Everyone downloads the initial client and once in awhile i release update packs that update such things as graphics, music, and core data embeded into rxdata. My problem is thus. Currently if you update rxdata and load player files off an existing save file, whenever a playe encounters the new data within the rxdata off their save file the game crashes.

I am looking for a way to update rxdata without the game crashing. This way with my rpg users can consistintly play off their own save files and get all the updates without having to resort to starting a new character to see their new changes.

I have a funny feeling it has something to do with adding manual def update or update commands anytime a saved file makes reference to rxdata. Now keep in mind, i probibly use a different save file type of script then most of you guys use, but i belive this problem is inherient to all save player scripts, from the one rpgmaker is bundled with to all of the custom auto savers such as the one Me? and sharktooth wrote.

thanks for any help
 
@Shadow Ball: It's an RGSS problem, not an RMXP bug.
Why don't you just use the regular save file system but keep the files in a folder outside the game client (Program files --> Common files for example)?
 
I don't think the problem is with the path. It's about incompatible savefiles. I bet you've added a new script in your update. If I got it right, I think it's difficult to update a savefile. I know it can be done, but it's beyond my grasp.
 
The problem is a few things:

1) The Marshal.load and Marshal.dump methods must read and load x-data. What it would require you to do, is this:

Any script that does something like this:
Code:
class class Scene_Load
  alias_method :blah_blah_blah, :read_save_data
  def read_save_data(file)
    blah_blah_blah(file)
    $game_object = Marshal.load(file)
 end
end

To this:
Code:
class class Scene_Load
  alias_method :blah_blah_blah, :read_save_data
  def read_save_data(file)
    blah_blah_blah(file)
    begin
      $game_object = Marshal.load(file)
    rescue
      $game_object = Object.new
    end
  end
end

This way, if an object isn't loaded, the object is created. So check your scripts. If you see anything from Save_Load, post that script here, and I will guide you threw it.


2) Something a little less hard to find, is anything that adds attributes to objects that are dumped.

For instance, say we add a new attribute, times_game_played to $game_system, like below:
Code:
class Game_System
  attr_accessor :times_game_played
  alias_method :blah_init, :initialize
  def initialize
    blah_init
    @times_game_played = 0
  end
end

Now, that @times_game_played instance is only created when the system is created, and the system data is only created when you start a new game. Thus, when you load a game, this variable will be nil, instead of 0.

So then once again, in Scene_Load, you would have to set that value yourself. This is a little more difficult, because you can't just check for this.
 

Zeriab

Sponsor

For the 2) thingie you can use my Module add-on
Simply use this code instead:
Code:
class Game_System
  attr_sec_accessor :times_game_played, 0
end

This is basically the same as sayiing attr_accessor :times_game_played where you define the default value to be 0 instead of nil.
An added bonus is that will work with old saves as well. Old saves will have the specified default value when you try to read them ;)

On slight notice, if you want an object as default value you must use the accessor like this
Code:
class Game_System
  attr_sec_accessor :times_game_played, 'Object.new'
end

*hugs*
- Zeriab
 

khmp

Sponsor

I will keep that noted from now on because I have done just $game_object = Marshal.load(file) without exception handling a lot :):

Code:
    begin
      $game_object = Marshal.load(file)
    rescue
      $game_object = Object.new
    end
 
Ok here is 4 scripts for you to look at. I dont know the right way to post code, so if you can edit it for me.

Code:
#==============================================================================
# ** Scene_File
#------------------------------------------------------------------------------
#  This is a superclass for the save screen and load screen.
#==============================================================================
#--------------------------------------------------------------------------
# * SDK Log Script
#--------------------------------------------------------------------------
SDK.log("Save & Load", "Mr.Mo", 1, "09.16.06")
#--------------------------------------------------------------------------
# * Begin SDK Enable Test
#--------------------------------------------------------------------------
if SDK.state("Save & Load") == true
  
class Scene_File
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     help_text : text string shown in the help window
  #--------------------------------------------------------------------------
  def initialize(help_text)
    @help_text = help_text
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make title graphic
    $sfondo = Sprite.new
    $sfondo.bitmap = RPG::Cache.title(User_Edit::Sfondo)
    $sfondo.z = -200
    # Make help window
    @help_window = Window_Help.new
    @help_window.set_text(@help_text)
    # Make save file window
    @savefile_windows = []
    for i in 0..2
      @savefile_windows.push(Window_SaveFile.new(i, make_filename(i)))
    end
    # Select last file to be operated
    @file_index = $game_temp.last_file_index
    @savefile_windows[@file_index].selected = true
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @help_window.dispose
    for i in @savefile_windows
      i.dispose
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @help_window.update
    for i in @savefile_windows
      i.update
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Call method: on_decision (defined by the subclasses)
      on_decision(make_filename(@file_index))
      $game_temp.last_file_index = @file_index
      return
    end
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Call method: on_cancel (defined by the subclasses)
      on_cancel
      return
    end
    # If the down directional button was pressed
    if Input.repeat?(Input::DOWN)
      # If the down directional button pressed down is not a repeat,
      # or cursor position is more in front than 3
      if Input.trigger?(Input::DOWN) or @file_index < 2
        # Play cursor SE
        $game_system.se_play($data_system.cursor_se)
        # Move cursor down
        @savefile_windows[@file_index].selected = false
        @file_index = (@file_index + 1) % 3
        @savefile_windows[@file_index].selected = true
        return
      end
    end
    # If the up directional button was pressed
    if Input.repeat?(Input::UP)
      # If the up directional button pressed down is not a repeatã€
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top