Logic fixes

This commit is contained in:
teejusb
2021-12-10 21:12:11 -08:00
parent c10d8e4eb5
commit 2967165235
+21 -7
View File
@@ -661,7 +661,7 @@ bool PlayerOptions::FromOneModString( const RString &sOneMod, RString &sErrorOut
const bool on = (level > 0.5f); const bool on = (level > 0.5f);
static Regex mult("^([0-9]+(\\.[0-9]+)?)x$"); static Regex mult("^([0-9]+(\\.[0-9]+)?)x$");
static Regex disabledWindows("(w[1-5])/{0,1}"); static Regex disabledWindows("(w[1-5])");
vector<RString> matches; vector<RString> matches;
if( mult.Compare(sBit, matches) ) if( mult.Compare(sBit, matches) )
{ {
@@ -1160,18 +1160,29 @@ bool PlayerOptions::FromOneModString( const RString &sOneMod, RString &sErrorOut
else if( sBit == "zbuffer" ) m_bZBuffer = on; else if( sBit == "zbuffer" ) m_bZBuffer = on;
else if( sBit == "cosecant" ) m_bCosecant = on; else if( sBit == "cosecant" ) m_bCosecant = on;
else if( sBit == "visualdelay" ) m_fVisualDelay = level; else if( sBit == "visualdelay" ) m_fVisualDelay = level;
else if( disabledWindows.Compare(sBit, matches)) { else if( level == 0 && disabledWindows.Compare(sBit)) // "No w1" etc.
for (auto& match : matches) { {
static std::map<RString, TimingWindow> name_to_window = { static std::map<RString, TimingWindow> nameToWindow = {
{"w1", TW_W1}, {"w1", TW_W1},
{"w2", TW_W2}, {"w2", TW_W2},
{"w3", TW_W3}, {"w3", TW_W3},
{"w4", TW_W4}, {"w4", TW_W4},
{"w5", TW_W5}, {"w5", TW_W5},
}; };
if (name_to_window.find(match) != name_to_window.end()) { // We come into this condition if there is at least a single window present but there may be more.
m_twDisabledWindows.insert(name_to_window[match]); // To get all of the windows, we go through in a loop to extract all of them.
static Regex allDisabledWindows("(w[1-5])(.*)$");
RString input = sBit;
while (true)
{
if (!allDisabledWindows.Compare(input, matches))
break;
if (nameToWindow.find(matches[0]) != nameToWindow.end())
{
m_twDisabledWindows.insert(nameToWindow[matches[0]]);
} }
input = matches[1];
} }
} }
// deprecated mods/left in for compatibility // deprecated mods/left in for compatibility
@@ -2032,7 +2043,7 @@ public:
int original_top= lua_gettop(L); int original_top= lua_gettop(L);
if (original_top >= 1 && !lua_isnil(L, 1)) if (original_top >= 1 && !lua_isnil(L, 1))
{ {
// Insert the specified TNS into the disabled windows set. // Insert the specified TimingWindow into the disabled windows set.
p->m_twDisabledWindows.insert(Enum::Check<TimingWindow>(L, 1)); p->m_twDisabledWindows.insert(Enum::Check<TimingWindow>(L, 1));
} }
// Construct a new table indicating all of the disabled windows. // Construct a new table indicating all of the disabled windows.
@@ -2057,9 +2068,12 @@ public:
{ {
int original_top= lua_gettop(L); int original_top= lua_gettop(L);
lua_newtable( L ); lua_newtable( L );
int i = 0;
for (TimingWindow window : p->m_twDisabledWindows) for (TimingWindow window : p->m_twDisabledWindows)
{ {
Enum::Push(L, window); Enum::Push(L, window);
lua_rawseti( L, -2, i+1 );
++i;
} }
OPTIONAL_RETURN_SELF(original_top); OPTIONAL_RETURN_SELF(original_top);
return 1; return 1;