Fixes the weird savegame name path string issue. All happens in dehacked.c
, which overwrites the default SRB2 save path. Facts:
timeattackname
is the game mod name truncated to 64 chars, so this is safe to append to savegamename
savegamename
, the old code used strncpy(..., ..., strlen(timeattackname)
. This copies the whole of timeattackname
, but NOT the null char
savegamename
was C:\Users\MarcoZ\SRB2\srb2sav%u.ssg
, the new string becomes sugoiers\MarcoZ\SRB2\srb2sav%u.ssg
. THIS IS THE FAILURE POINT!
%u.ssg
piece, that's appended to the end of the OLD string
sugoiers\MarcoZ\SRB2\srb2sav%u.ssg%u.ssg
srb2home
is appended to the beginning of this string, whether that's your default SRB2 dir or another folder.
C:\Users\MarcoZ\SRB2\sugoiers\MarcoZ\SRB2\srb2sav%u.ssg%u.ssg
C:\Users\MarcoZ\SRB2\sugoiers\MarcoZ\SRB2\srb2sav0.ssg10.ssg
(don't know where the 10 comes from...)This fix attacks step 2, where using strcpy()
auto-adds the null char to the end of timeattackname
. As timeattackname
is 64 chars and hence shorter than savegamename
, strcpy()
is safe to use.
All works correctly after that point: savegamename
is now merely sugoi
, and the template is now C:\Users\MarcoZ\SRB2\sugoi%u.ssg
Tested with srb2home paths both in the default SRB2 dir and in another folder.