don't click here

CPKREDIR - loading and combining mods for Sonic Generations

Discussion in 'Engineering & Reverse Engineering' started by Korama, May 9, 2012.

  1. Korama

    Korama

    Tech Member
    272
    2
    0
    So you're saying you removed CPKREDIR, completely reinstalled Sonic Generations, but the game crashes after GHZ Act 2 with your old save file?
    That's strange. The only thing that I can think of is that maybe your save file got corrupted somehow, but I've never heard of that happening before.
     
  2. Bareirito

    Bareirito

    Member
    102
    0
    0
    Argentina
    Sonic - Mystery of the Chaos Emeralds
    No. I can get through GHZ 2 with an older save file, in which I beated the game. I wanted to play through the game again, I started a new save, but it crashes after GHZ 2 when loading the HUB. It happens everytime when I start a new save. Nevermind by the way, I can use that '100% complete' save.
     
  3. Dude

    Dude

    Tech Member
    3,138
    0
    16
    Southbridge, MA
    Random VR/AR trash
    I just upgraded to 0.31 and it broke compatibility with my mod. I can't figure out what's wrong because I can't read the debug window, it disappears when the program crashes (as well as having video corruption so I can't read it). Whenever I try loading emerald coast, it just crashes with a generic windows error. It's not saving to a logfile halp!

    (I'd like to mention that it's loading files from bb2 and bb3 just fine, it's not liking files from bb1)

    NVM, I fixed it by disabling console logging.
     
  4. Azu

    Azu

    I must be stupid. Member
    Question, I noticed that in the Unleashed mod, the music isn't packed in a cpk. so, can I leave the ar.* files unpacked?
     
  5. Dario FF

    Dario FF

    Tech Support Hotline Tech Member
    The music is packed in a cpk... :v:
     
  6. Azu

    Azu

    I must be stupid. Member
    Not in the version I downloaded.
     
  7. Dario FF

    Dario FF

    Tech Support Hotline Tech Member
    What I mean is that the songs are packed inside CPKs normally in the game, but in the version we distributed, CPKREDIR can redirect to the AAX files inside of it. That's why you saw only the folders and the AAX files for Windmill Isle, CPKREDIR took care of redirecting.

    While AR File redirection sounds neat it sounds like it could be a bit hard to pull off since that's more game-dependent than the external routines used to load CPKs.
     
  8. Lobotomy

    Lobotomy

    35% Cognac Banned
    4,394
    1
    0
    Traverse City
    Project: Matter/Energy
    Is there any easy way to turn off just one mod out of the many I have?
     
  9. DinnerSonic

    DinnerSonic

    Never Posting Since 2004! Member
    In the modsDB.ini file, just tack on a ; before the respective ActiveMod entry.

    ActiveMod0="Logo Removal"
    ;ActiveMod1="Classic Sonic Adventures"
    ActiveMod2="WaveOcean"

    This for example would disable the Classic Sonic Adventures mod while leaving it easy to turn back on real quickly. Good for disabling conflicting mods, I assume CSA wouldn't play well with the Wave Ocean level for example.
     
  10. Korama

    Korama

    Tech Member
    272
    2
    0
    I finally got around to update CPKREDIR. Version 0.4 is here.

    The big new feature is save file redirection.
    Activated by setting "EnableSaveFileRedirection" in cpkredir.ini to true (it is by default).

    Now mods can specify custom save files in the [Main] section of their mod.ini. Excerpt from the readme for your convenience:
    On that note, has anybody reverse-engineered the save file of Sonic Generations yet?
     
  11. Dario FF

    Dario FF

    Tech Support Hotline Tech Member
    As I mentioned before, great work. Just one question. If SaveFileFallback is "", and Save file redirection is enabled, it just won't redirect the save file? Because that's how I would expect it to work.
     
  12. DinnerSonic

    DinnerSonic

    Never Posting Since 2004! Member
    If it matters, I found out a tiny bit of info at least, where the game stores currently equipped skills. I hoped(and failed) to force the Sonics to use the Rocket/Spikes Wisp skills which are in the skills list data along with the Mega Drive. I'm not sure where but there's surely a "what skills are bought" section that could allow that.

    It's harder for me to figure out because I'm not using any tracer things, just comparing back and forth save files, which also likely include things like time played and number of steps counters going about. Still, a tiny start?
     
  13. Korama

    Korama

    Tech Member
    272
    2
    0
    Thank you. I treat SaveFileFallback="" the same as not having that key present at all, meaning that the default value "cpkredir.sav" will be used. Same goes for LogFile, by the way. And for ModsDbIni, but there the default value is "" anyway.

    Thanks, that's interesting. Here's what I figured out:

    The first 32 bytes (8 dwords) are a header of sorts. First dword is the ID "SGD1". The following dwords specify the sizes of the segments the save file consists of. They (always) are 0xA300, 0x134, 0x1B4, 0x8.
    So, the first segment of the save file is 41728 (=0xA300) bytes, from file offset 0x20 (immediately after the header) to 0xA31F.

    Some easy settings (by file offset):
    0x30: Voice-Over language (00 = English, 01 = Japanese, 02 = French, 03 = German, 04 = Spanish, 05 = Italian)
    0x31: Music Volume (0 - 100)
    0x32: Effects Volume (0 - 100)
    0x33: Brightness (0 - 100)
    0x34: 3D Scale (0 - 100)

    0x38: a bitfield:
    Bit #0 = Control Tutorial
    Bit #1 = Omochao Hints
    Bit #4 = Subtitles
    Bit #6 = 3D enabled
    No idea what Bits #2 and #3 are for. I changed them but saw no effect.

    0xA0E0: the dword at this offset is 0xFFFFFFFF for new/empty saves. But there are more factors that mark a save as empty.
     
  14. Dario FF

    Dario FF

    Tech Support Hotline Tech Member
    If the save file stores stuff like Option Settings, it makes sense that using New Game doesn't delete it as you mentioned in your PM, but rather overwrites the contents of the current Save File. So it's likely the Delete function didn't get used after all.

    Here's the thing, I don't think it should actually use that value as default. The user might want to leave SaveFileRedirection enabled in case one of the mods he installed uses it, but if none of them use it, CPKREDIR would create a brand new save file called "cpkredir.sav", and the player would have to start all over from scratch just for installing say, a NoHUD mod.

    For example, I just tried installing CPKREDIR v0.4.0 with the LogoRemoval mod alone. Since the Save file redirection is enabled by default in the example INI that comes with it, a brand new game got started! That's definitely not what the user would like. This could be quite the issue for distributing, so if it's fixable soon, it'd be pretty much perfect. :)

    Easiest way to fix it is making the default NOT use a save file even if the redirection is enabled, but the key for SaveFileFallback is empty(or ""). Of course if none of the mods use Save Files that is.
     
  15. Josh

    Josh

    Oldbie
    2,123
    1,087
    93
    USA
    The Mega Drive, eh? Would it be possible to restore that to the HUB? I mean, I know it wouldn't be functional, but I do think it's a pretty neat object, especially the way the GHZ music drops back to 16-bit when you're near it.
     
  16. Korama

    Korama

    Tech Member
    272
    2
    0
    The delete function can get called if the conditions are right, I've found the code that does it. But don't ask me what the conditions are. ;)
    Anyway, the game keeps the settings in memory, so it could delete the old save file and create a new one without problem. But directly overwriting it, as the game does, requires one step less, of course.

    Yeah, I've just noticed that myself. Initially, I copied my normal save file to cpkredir.sav and therefore wasn't hit by that issue.
    Anyway, I've implemented a "read-through" mechanism, as I actually intended to at the beginning. If save file redirection is enabled, but no mod specifies a save file, and no SaveFileFallback is given (or it is the default cpkredir.sav), then the game will load your normal save file, but write any changes to cpkredir.sav.
    So, if cpkredir.sav doesn't exist, it is automatically copied from your regular save.
    Of course, if you set SaveFileFallback to some value that isn't "" or cpkredir.sav, and that file doesn't exist yet, then you WILL start with a completely new save.

    Download fixed version
    (argh, link was wrong)
     
  17. Dario FF

    Dario FF

    Tech Support Hotline Tech Member
    That solution works perfectly. Thanks for the quick update. :)

    Your method actually solves the problem with people having the fear of ruining their Time-Attack scores and the like. Only way they have to ruin their save file is by explicitly disabling save file redirection, which is a default enabled option. Since the user won't likely disable it(and I could offer a warning in SonicGMI if he does), his Stats will be safe when using Mods... Upon disabling mods, he would just fall back to his original save file.

    So kudos on it! Seems it's solved in the best way I can think of now.

    EDIT: Mirror'd. I'm also uploading the tools to ModDB if you don't mind.
     
  18. Korama

    Korama

    Tech Member
    272
    2
    0
    It's nice to see that there a finally some Sonic Generation mods listed on ModDB. Please upload CPKREDIR there if you like.
     
  19. Wait a moment, the Mega Drive data is in the PC version? Does this mean you could make a mod to reinsert it and play the original Sonic the Hedgehog?
     
  20. Josh

    Josh

    Oldbie
    2,123
    1,087
    93
    USA
    I don't think the emulator and ROM are there, but I'd imagine the Mega Drive object is.