Fix savegamename being improperly built
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 tosavegamename
- When overwriting
savegamename
, the old code usedstrncpy(..., ..., strlen(timeattackname)
. This copies the whole oftimeattackname
, but NOT the null char- Therefore, if the previous
savegamename
wasC:\Users\MarcoZ\SRB2\srb2sav%u.ssg
, the new string becomessugoiers\MarcoZ\SRB2\srb2sav%u.ssg
. THIS IS THE FAILURE POINT!
- Therefore, if the previous
- When appending the
%u.ssg
piece, that's appended to the end of the OLD stringsugoiers\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
- The result save name:
-
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.
Edited by mazmazz
Merge request reports
Activity
Filter activity
Please register or sign in to reply