Skip to content

Commit

Permalink
don't report OrNext chain as conflicting (#363)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamiras authored Aug 19, 2024
1 parent f1d6965 commit b9e7ba4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/rcheevos/rc_validate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
}
Expand Down
9 changes: 9 additions & 0 deletions test/rcheevos/test_rc_validate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit b9e7ba4

Please sign in to comment.