CPKREDIR - loading and combining mods for Sonic Generations New version 0.41, now with save file redirection
#47
Posted 30 May 2012 - 09:11 PM
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.
#48
Posted 31 May 2012 - 02:01 AM
#49
Posted 31 May 2012 - 02:10 AM
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.
#50
Posted 09 July 2012 - 06:08 PM
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:
Quote
This setting is only effective if EnableSaveFileRedirection is set to true. It allows the creator of a mod to supply a custom save file, e.g. one where red rings still need to be collected in the levels. It is meant for more elaborate mods that make large changes to the hub world and the levels.
Mods that replace Sonic with some other character, or change HUD elements etc. should NOT use this setting, to avoid interfering with other mods that actually need it.
Note that any custom save file data will be reset to the game's default values when the user chooses "New Game" in the main menu of Sonic Generations, which could have undesirable effects on your mod. Unfortunately, at the moment it is not possible to automatically load a custom initial save file when a "New Game" is activated.
Nevertheless, I suggest that you provide an additional copy of your initial save file, if your mod uses this feature. This copy or backup could have the file extension ".new.sav" (Example: if your mod INI contains SaveFile=mysave.sav, then provide mysave.sav of course, but also mysave.new.sav as backup of the initial state.)
On that note, has anybody reverse-engineered the save file of Sonic Generations yet?
#51
Posted 09 July 2012 - 06:17 PM
#52
Posted 09 July 2012 - 06:21 PM
Korama, on 09 July 2012 - 06:08 PM, said:
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?
#53
Posted 09 July 2012 - 06:43 PM
Dario FF, on 09 July 2012 - 06:17 PM, said:
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.
DinnerSonic, on 09 July 2012 - 06:21 PM, said:
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?
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.
#54
Posted 09 July 2012 - 07:04 PM
Quote
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.
#55
Posted 09 July 2012 - 07:13 PM
DinnerSonic, on 09 July 2012 - 06:21 PM, said:
Korama, on 09 July 2012 - 06:08 PM, said:
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?
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.
#56
Posted 09 July 2012 - 07:48 PM
Dario FF, on 09 July 2012 - 07:04 PM, said:
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.
Quote
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)
#57
Posted 09 July 2012 - 08:01 PM
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.
#58
Posted 09 July 2012 - 08:19 PM
#59
Posted 09 July 2012 - 09:14 PM
