From b9e7ba4138728db9830de55aeba8abe1e954a454 Mon Sep 17 00:00:00 2001 From: Jamiras <32680403+Jamiras@users.noreply.github.com> Date: Mon, 19 Aug 2024 09:15:04 -0600 Subject: [PATCH] don't report OrNext chain as conflicting (#363) --- src/rcheevos/rc_validate.c | 17 ++++++++++++----- test/rcheevos/test_rc_validate.c | 9 +++++++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/rcheevos/rc_validate.c b/src/rcheevos/rc_validate.c index bd3b305a..f52e1d61 100644 --- a/src/rcheevos/rc_validate.c +++ b/src/rcheevos/rc_validate.c @@ -795,11 +795,8 @@ static int rc_validate_conflicting_conditions(const rc_condset_t* conditions, co if (compare_condition->oper != RC_OPERATOR_NONE && !rc_validate_are_operands_equal(&compare_condition->operand2, &condition_chain_iter->operand2)) { - if (compare_condition->operand2.type != condition_chain_iter->operand2.type) - { - chain_matches = 0; - break; - } + chain_matches = 0; + break; } if (!compare_condition->next) @@ -808,6 +805,16 @@ static int rc_validate_conflicting_conditions(const rc_condset_t* conditions, co break; } + if (compare_condition->type != RC_CONDITION_ADD_ADDRESS && + compare_condition->type != RC_CONDITION_ADD_SOURCE && + compare_condition->type != RC_CONDITION_SUB_SOURCE && + compare_condition->type != RC_CONDITION_AND_NEXT) + { + /* things like AddHits and OrNext are hard to definitively detect conflicts. ignore them. */ + chain_matches = 0; + break; + } + compare_condition = compare_condition->next; condition_chain_iter = condition_chain_iter->next; } diff --git a/test/rcheevos/test_rc_validate.c b/test/rcheevos/test_rc_validate.c index 9d640e80..3b4c44f5 100644 --- a/test/rcheevos/test_rc_validate.c +++ b/test/rcheevos/test_rc_validate.c @@ -342,6 +342,15 @@ void test_conflicting_conditions() { TEST_PARAMS2(test_validate_trigger, "P:0xH0000=1_R:0xH0000!=6", ""); /* PauseIf in alternate group does not affect the ResetIf*/ TEST_PARAMS2(test_validate_trigger, "P:0xH0000=1SR:0xH0000!=1", ""); + + /* cannot determine OrNext conflicts */ + TEST_PARAMS2(test_validate_trigger, "O:0xH0000=1_0xH0001=1_O:0xH0000=2_0xH0001=2", ""); + TEST_PARAMS2(test_validate_trigger, "O:0xH0000=1_0xH0001=1_O:0xH0000=1_0xH0001=2", ""); + + /* AndNext conflicts are limited to matching the last condition after exactly matching the others */ + TEST_PARAMS2(test_validate_trigger, "N:0xH0000=1_0xH0001=1_N:0xH0000=2_0xH0001=2", ""); + TEST_PARAMS2(test_validate_trigger, "N:0xH0000=1_0xH0001=1_N:0xH0000=2_0xH0001=1", ""); /* technically conflicting, but hard to detect */ + TEST_PARAMS2(test_validate_trigger, "N:0xH0000=1_0xH0001=1_N:0xH0000=1_0xH0001=2", "Condition 4: Conflicts with Condition 2"); } void test_redundant_conditions() {