Fixes #2369
This commit is contained in:
@@ -191,11 +191,10 @@ bool isLogicalSwitchAvailable(int index)
|
|||||||
|
|
||||||
bool isSwitchAvailable(int swtch, SwitchContext context)
|
bool isSwitchAvailable(int swtch, SwitchContext context)
|
||||||
{
|
{
|
||||||
uint32_t index = switchInfo(abs(swtch)).quot;
|
bool negative = false;
|
||||||
|
|
||||||
if (swtch < 0) {
|
if (swtch < 0) {
|
||||||
if (!IS_3POS(index))
|
negative = true;
|
||||||
return false;
|
|
||||||
if (swtch == -SWSRC_ON || swtch == -SWSRC_One) {
|
if (swtch == -SWSRC_ON || swtch == -SWSRC_One) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -203,10 +202,19 @@ bool isSwitchAvailable(int swtch, SwitchContext context)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (swtch >= SWSRC_SA0 && swtch <= SWSRC_LAST_SWITCH) {
|
if (swtch >= SWSRC_SA0 && swtch <= SWSRC_LAST_SWITCH) {
|
||||||
if (!SWITCH_EXISTS(index))
|
div_t swinfo = switchInfo(swtch);
|
||||||
|
if (!SWITCH_EXISTS(swinfo.quot)) {
|
||||||
return false;
|
return false;
|
||||||
if ((swtch-SWSRC_SA1)%3 == 0)
|
}
|
||||||
return IS_3POS(index);
|
if (!IS_3POS(swinfo.quot)) {
|
||||||
|
if (negative) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (IS_3POS_MIDDLE(swinfo.rem)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (swtch >= SWSRC_FIRST_MULTIPOS_SWITCH && swtch <= SWSRC_LAST_MULTIPOS_SWITCH) {
|
if (swtch >= SWSRC_FIRST_MULTIPOS_SWITCH && swtch <= SWSRC_LAST_MULTIPOS_SWITCH) {
|
||||||
|
|||||||
@@ -732,6 +732,7 @@ PACK(typedef struct {
|
|||||||
#define SWITCH_EXISTS(x) (SWITCH_CONFIG(x) != SWITCH_NONE)
|
#define SWITCH_EXISTS(x) (SWITCH_CONFIG(x) != SWITCH_NONE)
|
||||||
#define IS_3POS(x) (SWITCH_CONFIG(x) == SWITCH_3POS)
|
#define IS_3POS(x) (SWITCH_CONFIG(x) == SWITCH_3POS)
|
||||||
#define IS_TOGGLE(x) (SWITCH_CONFIG(x) == SWITCH_TOGGLE)
|
#define IS_TOGGLE(x) (SWITCH_CONFIG(x) == SWITCH_TOGGLE)
|
||||||
|
#define IS_3POS_MIDDLE(x) ((x) == 1)
|
||||||
#define SWITCH_WARNING_ALLOWED(x) (SWITCH_EXISTS(x) && !IS_TOGGLE(x))
|
#define SWITCH_WARNING_ALLOWED(x) (SWITCH_EXISTS(x) && !IS_TOGGLE(x))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user