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.

Wrong marshall version?

I have this snippet that is saving:

Code:
def self.save
  begin
    #Saves the file to whatever $game_system.filename is
    file = File.open("preferences.rxdata", "wb")
    a = Scene_Save.new
    a.write_save_data(file)
  ensure
    file.close
  end
end

And this snippet that is loading:

Code:
def read_save_data(file)
    # Read character data for drawing save file
#    characters = Marshal.load(file)
    # Read frame count for measuring play time
    Graphics.frame_count = Marshal.load(file)
    # Read each type of game object
    $game_system        = Marshal.load(file)
    $game_switches      = Marshal.load(file)
    $game_variables     = Marshal.load(file)
    $game_self_switches = Marshal.load(file)
    $game_screen        = Marshal.load(file)
    $game_actors        = Marshal.load(file)
    $game_party         = Marshal.load(file)
    $game_troop         = Marshal.load(file)
    $game_map           = Marshal.load(file)
    $game_player        = Marshal.load(file)
    # If magic number is different from when saving
    # (if editing was added with editor)
    if $game_system.magic_number != $data_system.magic_number
      # Load map
      $game_map.setup($game_map.map_id)
      $game_player.center($game_player.x, $game_player.y)
    end
    # Refresh party members
    $game_party.refresh
  end


But when it tries to load I get this odd error:

TypeError occurred.

incompatible marshal file format (can't be read)
format version 4.8 required; 112.114 given



Anyone have any ideas?
 
TypeError occurred.

incompatible marshal file format (can't be read)
format version 4.8 required; 112.114 given
That's because the two first digits of the marshal data should be 0x04 and 0x08, and they aren't. Do you have the save methods? That's the most important part to view, as the load methods seems good.
PD: Have you tried to save the file again? And then try to load it?
 
As far as I know I haven't editted the saving or loading methods, other than moving them around so that it auto-loads the one save file if it exists.

I've tried deleting the save file and retrying, but no good.

The only addition is this, from the ABS:

Code:
#============================================================================
# * Scene Save
#============================================================================
class Scene_Save
  #--------------------------------------------------------------------------
  alias mrmo_abs_scene_save_write write_save_data
  #--------------------------------------------------------------------------
  # * Write Save Data
  #     file : write file object (opened)
  #--------------------------------------------------------------------------
  def write_save_data(file)
    mrmo_abs_scene_save_write(file)
    Marshal.dump($NeoABS, file)
  end
end
 
Mmm, that's rare, but I have a new idea. You have removed the characters load:
Code:
#    characters = Marshal.load(file)
But is still available the characters save? If yes, remove it too, or allow the characters load. Other way, the problem should be in the ABS script. Try to remove the load and save of the ABS script, if it works that way, the problem is from the ABS.
 
Now that's really really weird. Well, my last idea, do you have the save file? And, in which line the error is raised?

PD: Another idea, do you have modified the $KCODE variable? Or the Marshal/File class?
 
Code:
#    characters = Marshal.load(file)

is indeed the problem. You can't comment out Marshal.load like that, given that they must be sequential. Even if you don't use it, don't comment it out, use :
Code:
 Marshal.load(file)
instead. Or else, when trying to Graphics.frame_count = Marshal.load(file), it'll read a character class, and will crash.
 
You need to have exactly the same order of Marshall.dump in write_save_data as Marshall.load in read_save_data

Check if you do. And don't use your savegames, they may have been corrupted already
 
I really don't get this now.

There's now nothing in there messing with Scene_Load and Scene_Save. I've added in a new fresh one of each and removed the old one, tested, still not working. And yet it works if I make a new project.
 

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