* Increased leniency for SOC wrt "major mods".

* If your file defines state and object freeslots in SOC, you are allowed to modify those freeslots IN ANY SOC SCRIPT IN THE SAME FILE without being marked as a "major mod".
	* If your file contains broken unlockables/emblems that don't actually have effect for any reason, it's not counted as a "major mod".
* Added add-ons menu message for adding a "major mod".
This commit is contained in:
toaster 2019-01-17 20:51:41 +00:00
parent a7445a7b71
commit 2f2d3768d5
4 changed files with 46 additions and 9 deletions

View file

@ -602,6 +602,14 @@ done:
Z_Free(s); Z_Free(s);
} }
static int freeslotusage[2][2] = {{0, 0}, {0, 0}}; // [S_, MT_][max, previous .wad's max]
void DEH_UpdateMaxFreeslots(void)
{
freeslotusage[0][1] = freeslotusage[0][0];
freeslotusage[1][1] = freeslotusage[1][0];
}
// TODO: Figure out how to do undolines for this.... // TODO: Figure out how to do undolines for this....
// TODO: Warnings for running out of freeslots // TODO: Warnings for running out of freeslots
static void readfreeslots(MYFILE *f) static void readfreeslots(MYFILE *f)
@ -664,6 +672,7 @@ static void readfreeslots(MYFILE *f)
if (!FREE_STATES[i]) { if (!FREE_STATES[i]) {
FREE_STATES[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); FREE_STATES[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL);
strcpy(FREE_STATES[i],word); strcpy(FREE_STATES[i],word);
freeslotusage[0][0]++;
break; break;
} }
} }
@ -673,6 +682,7 @@ static void readfreeslots(MYFILE *f)
if (!FREE_MOBJS[i]) { if (!FREE_MOBJS[i]) {
FREE_MOBJS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); FREE_MOBJS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL);
strcpy(FREE_MOBJS[i],word); strcpy(FREE_MOBJS[i],word);
freeslotusage[1][0]++;
break; break;
} }
} }
@ -3417,7 +3427,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad)
if (fastcmp(word, "FREESLOT")) if (fastcmp(word, "FREESLOT"))
{ {
readfreeslots(f); readfreeslots(f);
majormods = true; //majormods = true;
continue; continue;
} }
else if (fastcmp(word, "MAINCFG")) else if (fastcmp(word, "MAINCFG"))
@ -3480,14 +3490,17 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad)
if (i == 0 && word2[0] != '0') // If word2 isn't a number if (i == 0 && word2[0] != '0') // If word2 isn't a number
i = get_mobjtype(word2); // find a thing by name i = get_mobjtype(word2); // find a thing by name
if (i < NUMMOBJTYPES && i >= 0) if (i < NUMMOBJTYPES && i >= 0)
{
if (i < (MT_FIRSTFREESLOT+freeslotusage[1][1]))
majormods = true; // affecting something earlier than the first freeslot allocated in this .wad? DENIED
readthing(f, i); readthing(f, i);
}
else else
{ {
deh_warning("Thing %d out of range (0 - %d)", i, NUMMOBJTYPES-1); deh_warning("Thing %d out of range (0 - %d)", i, NUMMOBJTYPES-1);
ignorelines(f); ignorelines(f);
} }
DEH_WriteUndoline(word, word2, UNDO_HEADER); DEH_WriteUndoline(word, word2, UNDO_HEADER);
majormods = true;
} }
/* else if (fastcmp(word, "ANIMTEX")) /* else if (fastcmp(word, "ANIMTEX"))
{ {
@ -3564,14 +3577,17 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad)
if (i == 0 && word2[0] != '0') // If word2 isn't a number if (i == 0 && word2[0] != '0') // If word2 isn't a number
i = get_state(word2); // find a state by name i = get_state(word2); // find a state by name
if (i < NUMSTATES && i >= 0) if (i < NUMSTATES && i >= 0)
{
if (i < (S_FIRSTFREESLOT+freeslotusage[0][1]))
majormods = true; // affecting something earlier than the first freeslot allocated in this .wad? DENIED
readframe(f, i); readframe(f, i);
}
else else
{ {
deh_warning("Frame %d out of range (0 - %d)", i, NUMSTATES-1); deh_warning("Frame %d out of range (0 - %d)", i, NUMSTATES-1);
ignorelines(f); ignorelines(f);
} }
DEH_WriteUndoline(word, word2, UNDO_HEADER); DEH_WriteUndoline(word, word2, UNDO_HEADER);
majormods = true;
} }
// <Callum> Added translations to this just in case its re-enabled // <Callum> Added translations to this just in case its re-enabled
/* else if (fastcmp(word, "POINTER")) /* else if (fastcmp(word, "POINTER"))
@ -3657,6 +3673,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad)
if (numemblems < i) if (numemblems < i)
numemblems = i; numemblems = i;
reademblemdata(f, i); reademblemdata(f, i);
majormods = true;
} }
else else
{ {
@ -3664,7 +3681,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad)
ignorelines(f); ignorelines(f);
} }
DEH_WriteUndoline(word, word2, UNDO_HEADER); DEH_WriteUndoline(word, word2, UNDO_HEADER);
majormods = true;
} }
else if (fastcmp(word, "EXTRAEMBLEM")) else if (fastcmp(word, "EXTRAEMBLEM"))
{ {
@ -3678,6 +3694,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad)
if (numextraemblems < i) if (numextraemblems < i)
numextraemblems = i; numextraemblems = i;
readextraemblemdata(f, i); readextraemblemdata(f, i);
majormods = true;
} }
else else
{ {
@ -3685,7 +3702,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad)
ignorelines(f); ignorelines(f);
} }
DEH_WriteUndoline(word, word2, UNDO_HEADER); DEH_WriteUndoline(word, word2, UNDO_HEADER);
majormods = true;
} }
else if (fastcmp(word, "UNLOCKABLE")) else if (fastcmp(word, "UNLOCKABLE"))
{ {
@ -3695,14 +3711,16 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad)
ignorelines(f); ignorelines(f);
} }
else if (i > 0 && i <= MAXUNLOCKABLES) else if (i > 0 && i <= MAXUNLOCKABLES)
{
readunlockable(f, i - 1); readunlockable(f, i - 1);
majormods = true;
}
else else
{ {
deh_warning("Unlockable number %d out of range (1 - %d)", i, MAXUNLOCKABLES); deh_warning("Unlockable number %d out of range (1 - %d)", i, MAXUNLOCKABLES);
ignorelines(f); ignorelines(f);
} }
DEH_WriteUndoline(word, word2, UNDO_HEADER); DEH_WriteUndoline(word, word2, UNDO_HEADER);
majormods = true;
} }
else if (fastcmp(word, "CONDITIONSET")) else if (fastcmp(word, "CONDITIONSET"))
{ {
@ -3712,7 +3730,10 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad)
ignorelines(f); ignorelines(f);
} }
else if (i > 0 && i <= MAXCONDITIONSETS) else if (i > 0 && i <= MAXCONDITIONSETS)
{
readconditionset(f, (UINT8)i); readconditionset(f, (UINT8)i);
majormods = true;
}
else else
{ {
deh_warning("Condition set number %d out of range (1 - %d)", i, MAXCONDITIONSETS); deh_warning("Condition set number %d out of range (1 - %d)", i, MAXCONDITIONSETS);
@ -3720,7 +3741,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad)
} }
// no undo support for this insanity yet // no undo support for this insanity yet
//DEH_WriteUndoline(word, word2, UNDO_HEADER); //DEH_WriteUndoline(word, word2, UNDO_HEADER);
majormods = true;
} }
else if (fastcmp(word, "SRB2KART")) else if (fastcmp(word, "SRB2KART"))
{ {
@ -9381,6 +9401,7 @@ static inline int lib_freeslot(lua_State *L)
CONS_Printf("State S_%s allocated.\n",word); CONS_Printf("State S_%s allocated.\n",word);
FREE_STATES[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); FREE_STATES[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL);
strcpy(FREE_STATES[i],word); strcpy(FREE_STATES[i],word);
freeslotusage[0][0]++;
lua_pushinteger(L, i); lua_pushinteger(L, i);
r++; r++;
break; break;
@ -9396,6 +9417,7 @@ static inline int lib_freeslot(lua_State *L)
CONS_Printf("MobjType MT_%s allocated.\n",word); CONS_Printf("MobjType MT_%s allocated.\n",word);
FREE_MOBJS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); FREE_MOBJS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL);
strcpy(FREE_MOBJS[i],word); strcpy(FREE_MOBJS[i],word);
freeslotusage[1][0]++;
lua_pushinteger(L, i); lua_pushinteger(L, i);
r++; r++;
break; break;

View file

@ -37,6 +37,8 @@ void DEH_UnloadDehackedWad(UINT16 wad);
void DEH_LoadDehackedLump(lumpnum_t lumpnum); void DEH_LoadDehackedLump(lumpnum_t lumpnum);
void DEH_LoadDehackedLumpPwad(UINT16 wad, UINT16 lump); void DEH_LoadDehackedLumpPwad(UINT16 wad, UINT16 lump);
void DEH_UpdateMaxFreeslots(void);
void DEH_Check(void); void DEH_Check(void);
fixed_t get_number(const char *word); fixed_t get_number(const char *word);

View file

@ -4551,9 +4551,14 @@ static char *M_AddonsHeaderPath(void)
#define CLEARNAME Z_Free(refreshdirname);\ #define CLEARNAME Z_Free(refreshdirname);\
refreshdirname = NULL refreshdirname = NULL
static boolean prevmajormods = false;
static void M_AddonsClearName(INT32 choice) static void M_AddonsClearName(INT32 choice)
{
if (majormods == prevmajormods || savemoddata)
{ {
CLEARNAME; CLEARNAME;
}
M_StopMessage(choice); M_StopMessage(choice);
} }
@ -4566,7 +4571,7 @@ static boolean M_AddonsRefresh(void)
return true; return true;
} }
if (refreshdirmenu & REFRESHDIR_ADDFILE) if ((refreshdirmenu & REFRESHDIR_ADDFILE) || (majormods != prevmajormods && !savemoddata))
{ {
char *message = NULL; char *message = NULL;
@ -4583,6 +4588,12 @@ static boolean M_AddonsRefresh(void)
S_StartSound(NULL, sfx_s224); S_StartSound(NULL, sfx_s224);
message = va("%c%s\x80\nA file was loaded with %s.\nCheck the console log for more information.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname, ((refreshdirmenu & REFRESHDIR_ERROR) ? "errors" : "warnings")); message = va("%c%s\x80\nA file was loaded with %s.\nCheck the console log for more information.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname, ((refreshdirmenu & REFRESHDIR_ERROR) ? "errors" : "warnings"));
} }
else if (majormods != prevmajormods && !savemoddata)
{
S_StartSound(NULL, sfx_s221);
message = va("%c%s\x80\nGameplay has now been modified.\nIf you want to play record attack mode, restart the game to clear existing add-ons.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname);
prevmajormods = majormods;
}
if (message) if (message)
{ {

View file

@ -799,6 +799,8 @@ UINT16 W_InitFile(const char *filename)
break; break;
} }
DEH_UpdateMaxFreeslots();
W_InvalidateLumpnumCache(); W_InvalidateLumpnumCache();
return wadfile->numlumps; return wadfile->numlumps;
} }