Optional override for SetSlot and ClearPlayerClasses

With this, a decade-long struggle can now be ended.

# Conflicts:
#	wadsrc/static/language.csv
This commit is contained in:
Ed the Bat 2019-08-19 18:13:40 -04:00 committed by Rachael Alexanderson
parent fdd17403e5
commit 001df17daa
3 changed files with 46 additions and 3 deletions

View file

@ -544,6 +544,9 @@ int FWeaponSlots::RestoreSlots(FConfigFile *config, const char *section)
//
//===========================================================================
// Strict handling of SetSlot and ClearPlayerClasses in KEYCONF
CVAR(Bool,setslotstrict,true,CVAR_ARCHIVE);
void FWeaponSlots::PrintSettings()
{
for (int i = 1; i <= NUM_WEAPON_SLOTS; ++i)
@ -588,8 +591,13 @@ CCMD (setslot)
KeyConfWeapons.Push(argv.args());
}
else if (PlayingKeyConf != nullptr)
{
// Only clear the slot first if setslotstrict is true
// If not, we'll just add to the slot without clearing it
if(setslotstrict)
{
PlayingKeyConf->ClearSlot(slot);
}
for (int i = 2; i < argv.argc(); ++i)
{
PlayingKeyConf->AddWeapon(slot, argv[i]);

View file

@ -223,11 +223,45 @@ void D_LoadWadSettings ()
ParsingKeyConf = false;
}
// Strict handling of SetSlot and ClearPlayerClasses in KEYCONF (see a_weapons.cpp)
EXTERN_CVAR (Bool, setslotstrict)
// Specifically hunt for and remove IWAD playerclasses
void ClearIWADPlayerClasses (PClassActor *ti)
{
for(unsigned i=0; i < PlayerClasses.Size(); i++)
{
if(PlayerClasses[i].Type==ti)
{
for(unsigned j = i; j < PlayerClasses.Size()-1; j++)
{
PlayerClasses[j] = PlayerClasses[j+1];
}
PlayerClasses.Pop();
}
}
}
CCMD(clearplayerclasses)
{
if (ParsingKeyConf)
{
// Only clear the playerclasses first if setslotstrict is true
// If not, we'll only remove the IWAD playerclasses
if(setslotstrict)
PlayerClasses.Clear();
else
{
// I wish I had a better way to pick out IWAD playerclasses
// without having to explicitly name them here...
ClearIWADPlayerClasses(PClass::FindActor("DoomPlayer"));
ClearIWADPlayerClasses(PClass::FindActor("HereticPlayer"));
ClearIWADPlayerClasses(PClass::FindActor("StrifePlayer"));
ClearIWADPlayerClasses(PClass::FindActor("FighterPlayer"));
ClearIWADPlayerClasses(PClass::FindActor("ClericPlayer"));
ClearIWADPlayerClasses(PClass::FindActor("MagePlayer"));
ClearIWADPlayerClasses(PClass::FindActor("ChexPlayer"));
}
}
}

View file

@ -1198,6 +1198,7 @@ OptionMenu "MiscOptions" protected
Option "$MISCMNU_QUICKSAVEROTATION", "quicksaverotation", "OnOff"
Slider "$MISCMNU_QUICKSAVECOUNT", "quicksaverotationcount", 1, 20, 1, 0
Option "$MISCMNU_DEHLOAD", "dehload", "dehopt"
Option "$MISCMNU_SETSLOTSTRICT", "setslotstrict", "YesNo"
Option "$MISCMNU_ENABLESCRIPTSCREENSHOTS", "enablescriptscreenshot", "OnOff"
Option "$MISCMNU_INTERSCROLL", "nointerscrollabort", "OffOn"
StaticText " "