don't click here

CPKREDIR - loading and combining mods for Sonic Generations

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

  1. DinnerSonic

    DinnerSonic

    Never Posting Since 2004! Member
    No idea about the emulator/rom, I'm somewhat doubtful, but the HUB music, the models, the icons, store entries and even the objects on the HUB for it are still in the PC version. I'm betting they just took out the ability for it to appear, and I assume didn't port the code for the emulator.
     
  2. Korama

    Korama

    Tech Member
    272
    2
    0
    A few people still seem to prefer releasing mods as CPKs instead of just the modified files. Plus there are a few older mods that only exist as CPKs.
    To get those mods working with CPKREDIR, you have to extract the files from the mod CPKs and if possible delete all files that haven't been modified.
    That can be tedious work, so I made a little program to automate the process.
    You'll still have to manually create a mod.ini for any mods you extract, but that shouldn't be too difficult.
    You can download the program here.
    [​IMG]
     
  3. Korama

    Korama

    Tech Member
    272
    2
    0
    Update:
    CPKREDIR v0.41

    Now save file redirection works with older versions of SonicGenerations.exe (no more error 0xc000142).
    And there's a new SaveFileOverride setting, for forcing your own save file on mods without having to disable save file redirection.
     
  4. TheUltimaXtreme

    TheUltimaXtreme

    Breaking logic since whenever Member
    Now there's a new issue.

    Upon entering a state where the game must save, the game immediately crashes.

    There's the program signature provided.
     
  5. Korama

    Korama

    Tech Member
    272
    2
    0
    Thanks for the notice.
    First, it looks like you're running v1.0.0.1 of SonicGenerations.exe. The current version is 1.0.0.5, so update the game if possible.

    Second, my guess is the game crashes because the redirected save file is attempted to be written to a folder for which you don't have write permissions.
    One solution is to run the game with admin privileges (right-click -> run as admin).
    A better solution is to check save file settings in cpkredir.ini (namely SafeFileFallback and SafeFileOverride) and in the mod.ini you're using, and to make sure they point to places where you're allowed to create files.
    Since mods probably want to save files in their own subfolder, you should take ownership of the parent folder in which you keep all mods (check the "Replace owner on subcontainers and objects" option). You also should have write access to Sonic Generation's folder (usually C:\Program Files\Steam\steamapps\common\sonic generations), so take ownership of that as well, if necessary.
     
  6. TheUltimaXtreme

    TheUltimaXtreme

    Breaking logic since whenever Member
    The v1.0.0.1 thing has to do with it being pirated. I'll see if it's possible to patch it.

    As for write permissions, that's a fairly common thing, but obviously, as I'm the only user, I do mostly have ownership over all of my content, disregarding programs locked by TrustedInstaller. Since the Steam path, where the save data for SonicGenerations.exe usually writes to, is also owned by TrustedInstaller, I don't see why it's passing through and saving there on default, when the folder, where the EXE is stored itself, seems to have such issues for its own content. Guess that's best left to discuss in a Windows thread.
     
  7. Dude

    Dude

    Tech Member
    3,138
    0
    16
    Southbridge, MA
    Random VR/AR trash
    I don't think it's a good idea to add support for pirated versions. That might get people in hot water.
     
  8. Azu

    Azu

    I must be stupid. Member
    I noticed the console doesn't come up anymore, anyway to change that so that it does?
     
  9. Overlord

    Overlord

    Now playable in Smash Bros Ultimate Moderator
    19,240
    974
    93
    Long-term happiness
    Seconded. If anything, support for mods like this only in actual official versions might encourage people to buy the damn game and support Sega - it's not a huge amount and lord knows they need it right now.
     
  10. Korama

    Korama

    Tech Member
    272
    2
    0
    I'm not intentionally adding support for pirated versions. If I could, I'd make CPKREDIR work only with legitimate copies of the game.
    The problem is, how do you detect that a copy is pirated?
    I could remove support for all but the current version of SonicGenerations.exe (v1.0.0.5), as legitimate users should always have the latest update.
    I could check if there's a suspicious DLL in Sonic Generation's folder, as many pirated versions use a cracked steam_api.dll called storm_api.dll or burst_api.dll.
    Tell me if you think I should really be doing this. And if you have any good ideas for detecting pirated copies, I'm all ears.

    The console was disabled by default, as it seemed to cause performance problems for some people.
    Just open cpkredir.ini and make sure it contains the line "LogType=console". If you're using the default cpkredir.ini from the latest zip file, this line is already there, but commented out. So just remove the ";" in front of it.
     
  11. Dario FF

    Dario FF

    Tech Support Hotline Tech Member
    Taking support out for cracking is against preservation of software, which is the main reason why I hate stuff like Steam, since it's not much of a digital store, but more of a digital subscription. GoG does it right.

    At this point your job is done. You don't need to play morality hunter and go around implementing DRM for CPKREDIR. It's useless, and if needed, people will crack it. It's Sega's job, not yours.

    Besides, we all know how we want to tamper with the exe and stuff for seeing what we can unlock(*cough* Unleashed Renderer *cough*). If one of the things we modified happened to shoot some warning to Steam(like some weird memory corruption of some sort), you could be risking a ban.

    TL;DR; Don't bother adding protection, and don't bother supporting older versions either if it's not necessary.
     
  12. Overlord

    Overlord

    Now playable in Smash Bros Ultimate Moderator
    19,240
    974
    93
    Long-term happiness
    Yeah, basically what Dario said, honestly. Don't specifically bother adding support for pirated versions, but actively adding checks to prevent it is going too far in the other direction.
     
  13. TheUltimaXtreme

    TheUltimaXtreme

    Breaking logic since whenever Member
    Well, most of the time, people, whether pirating it or not, if it doesn't fault the gameplay, there's nothing to bother about. That sense of "If it ain't broke, don't fix it" rolls in for these kinds of games. It works with modding as well. I've not seen issues with the older CPKREDIR, so it'd make sense to stay on that revision. Other people obviously want their game to be "perfect" and that every patch brings it closer to that. That's how it works.

    Applying a DRM to your modifying program, for a game that, in itself, is supposed to be DRM for the sense that you need Steam running to make the game itself run, would be incredibly crass if I say so myself.
     
  14. Korama

    Korama

    Tech Member
    272
    2
    0
    I built a flexible patching system to be forward compatible, so that CPKREDIR would be likely to work with Sonic Generations v1.0.0.6 and beyond, should there ever be any more updates released (yeah, seems unlikely).
    The fact that this also makes it backward compatible to Sonic Generations v1.0.0.4 and older was just a welcome side effect.
    I could implement a simple version check to test if SonicGenerations.exe is older than v1.0.0.5, display an error message and refuse to run. But given how easily this could be circumvented, it's probably not worth the effort. Still, it might deter some pirates who don't know how to use a hex editor. ;)

    That's how I see it as well. While it might be fun to annoy people who try to run CPKREDIR with a pirated copy of Sonic Generations, every measure that I take could be circumvented. And unless CPKREDIR v0.5 introduces a killer feature that most mods would end up relying on, people could just continue using v0.4.
     
  15. Dario FF

    Dario FF

    Tech Support Hotline Tech Member
    So after all this discussion I kinda got lost. Is cpkredir v0.4.1 stable enough to be rebundled again with SonicGMI?
     
  16. Korama

    Korama

    Tech Member
    272
    2
    0
    Yep, it is.
    You might want to add controls for the new SaveFileOverride key to SonicGMI, because it's the way to play mods such as Dragon Road with your own save file instead of the mod's save file. Without disabling save file redirection, which ideally should always stay enabled.
     
  17. Korama

    Korama

    Tech Member
    272
    2
    0
    So, with the release of the Sonic Generations Unleashed Project, cpkredir is put to the test like never before.
    If you run into any errors, please report them here. Reproducible errors complete with test cases would be best, of course.

    I've experienced a few infinite loading screens myself after quitting a stage, but so far I haven't been able to reproduce the error and track down the cause.

    However, I have found and fixed a bug that prevented cpkredir from adding external files via the normal IncludeDir function when a CPK ini (bb/bb2/bb3.ini) was specified.
    I'll post an update soon.
     
  18. Iggy for Short

    Iggy for Short

    Member
    818
    182
    43
    We determined some time ago that the infinite loading screens seem to be related to music/sound modding. As an example, JoeTE's first release of Metal Sonic had a shit-ton of music swaps and had endless loading screens incredibly often, but removing said audio changes would make it much more stable.
     
  19. Korama

    Korama

    Tech Member
    272
    2
    0
    Interesting. Is that mod still available somewhere? I could never reproduce that problem, so that bug might still exist.

    In other news, mega bump. First post has been updated.
     
  20. Iggy for Short

    Iggy for Short

    Member
    818
    182
    43
    It can happen on any mod that does a decent amount of sound tampering. It's never been a consistently occurring bug, though; it happens when it feels like it, and specific tracks may have a higher likelihood of triggering it when tampered with. It also may be avoidable if a mod packs its sound files as opposed to keeping them in simple folders, but I don't believe many (if any) mods have bothered to do so, so I'm uncertain.

    I'm also not sure it's a problem that CPKREDIR can fix. For all we know it could be a problem inherent to the way Generations loads sound files. Thanks to some experimentation I did with SonicGMI while running the game, I know that the game's music tracks are loaded during loading screens, as opposed to things like the levels which seem to be front-loaded when the game initially starts up. For example, if you have a level mod that replaces Green Hill Zone, turning the mod off mid-game won't bring GHZ back, but will still load GHZ's music if you enter the level. I'd say that means it's safe to assume that the bug is Generations failing to load a music track and hanging on the loading screen as a result, so the question is if that's CPKREDIR's fault or the game's.