GAMEDATA MainCfg SOC block adustment

Discussed in DMs
- All other `MainCfg` block properties require a custom gamedata (or be a main file) to be modified
- When a custom gamedata is set, clear all unlockables, conditionsets, and emblems are unconditionally cleared
- You may also Clear Levels only if a custom gamedata is used
This commit is contained in:
toaster 2022-12-13 18:20:52 +00:00
parent b26da37477
commit 117b4c6a7b
3 changed files with 47 additions and 54 deletions

View file

@ -2525,7 +2525,7 @@ void readconditionset(MYFILE *f, UINT8 setnum)
Z_Free(s);
}
void readmaincfg(MYFILE *f)
void readmaincfg(MYFILE *f, boolean mainfile)
{
char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL);
char *word = s;
@ -2565,7 +2565,49 @@ void readmaincfg(MYFILE *f)
value = atoi(word2); // used for numerical settings
if (fastcmp(word, "EXECCFG"))
if (fastcmp(word, "GAMEDATA"))
{
size_t filenamelen;
// Check the data filename so that mods
// can't write arbitrary files.
if (!GoodDataFileName(word2))
I_Error("Maincfg: bad data file name '%s'\n", word2);
G_SaveGameData();
strlcpy(gamedatafilename, word2, sizeof (gamedatafilename));
strlwr(gamedatafilename);
savemoddata = true;
majormods = false;
// Also save a time attack folder
filenamelen = strlen(gamedatafilename)-4; // Strip off the extension
filenamelen = min(filenamelen, sizeof (timeattackfolder));
strncpy(timeattackfolder, gamedatafilename, filenamelen);
timeattackfolder[min(filenamelen, sizeof (timeattackfolder) - 1)] = '\0';
strcpy(savegamename, timeattackfolder);
strlcat(savegamename, "%u.ssg", sizeof(savegamename));
// can't use sprintf since there is %u in savegamename
strcatbf(savegamename, srb2home, PATHSEP);
strcpy(liveeventbackup, va("live%s.bkp", timeattackfolder));
strcatbf(liveeventbackup, srb2home, PATHSEP);
refreshdirmenu |= REFRESHDIR_GAMEDATA;
gamedataadded = true;
titlechanged = true;
clear_unlockables();
clear_conditionsets();
clear_emblems();
//clear_levels();
}
else if (!mainfile && !gamedataadded)
{
deh_warning("You must define a custom gamedata to use \"%s\"", word);
}
else if (fastcmp(word, "EXECCFG"))
{
if (strchr(word2, '.'))
COM_BufAddText(va("exec %s\n", word2));
@ -2750,40 +2792,6 @@ void readmaincfg(MYFILE *f)
{
maxXtraLife = (UINT8)get_number(word2);
}
else if (fastcmp(word, "GAMEDATA"))
{
size_t filenamelen;
// Check the data filename so that mods
// can't write arbitrary files.
if (!GoodDataFileName(word2))
I_Error("Maincfg: bad data file name '%s'\n", word2);
G_SaveGameData();
strlcpy(gamedatafilename, word2, sizeof (gamedatafilename));
strlwr(gamedatafilename);
savemoddata = true;
majormods = false;
// Also save a time attack folder
filenamelen = strlen(gamedatafilename)-4; // Strip off the extension
filenamelen = min(filenamelen, sizeof (timeattackfolder));
strncpy(timeattackfolder, gamedatafilename, filenamelen);
timeattackfolder[min(filenamelen, sizeof (timeattackfolder) - 1)] = '\0';
strcpy(savegamename, timeattackfolder);
strlcat(savegamename, "%u.ssg", sizeof(savegamename));
// can't use sprintf since there is %u in savegamename
strcatbf(savegamename, srb2home, PATHSEP);
strcpy(liveeventbackup, va("live%s.bkp", timeattackfolder));
strcatbf(liveeventbackup, srb2home, PATHSEP);
refreshdirmenu |= REFRESHDIR_GAMEDATA;
gamedataadded = true;
titlechanged = true;
}
else if (fastcmp(word, "RESETDATA"))
{
P_ResetData(value);

View file

@ -57,7 +57,7 @@ sfxenum_t get_sfx(const char *word);
skincolornum_t get_skincolor(const char *word);
void readwipes(MYFILE *f);
void readmaincfg(MYFILE *f);
void readmaincfg(MYFILE *f, boolean mainfile);
void readconditionset(MYFILE *f, UINT8 setnum);
void readunlockable(MYFILE *f, INT32 num);
void reademblemdata(MYFILE *f, INT32 num);

View file

@ -217,7 +217,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, boolean mainfile)
else if (fastcmp(word, "MAINCFG"))
{
G_SetGameModified(multiplayer, true);
readmaincfg(f);
readmaincfg(f, mainfile);
continue;
}
else if (fastcmp(word, "WIPES"))
@ -548,28 +548,13 @@ static void DEH_LoadDehackedFile(MYFILE *f, boolean mainfile)
// (then again, modifiedgame will prevent game data saving anyway)
else if (fastcmp(word, "CLEAR"))
{
boolean clearall = (fastcmp(word2, "ALL"));
if (!mainfile && !gamedataadded)
{
deh_warning("You must define a custom gamedata to use \"%s\"", word);
continue;
}
if (clearall || fastcmp(word2, "UNLOCKABLES"))
{
clear_unlockables();
}
if (clearall || fastcmp(word2, "EMBLEMS"))
{
clear_emblems();
}
if (clearall || fastcmp(word2, "CONDITIONSETS"))
clear_conditionsets();
if (clearall || fastcmp(word2, "LEVELS"))
if (fastcmp(word2, "LEVELS"))
clear_levels();
}
else