diff options
Diffstat (limited to 'toxcore/assoc.c')
-rw-r--r-- | toxcore/assoc.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/toxcore/assoc.c b/toxcore/assoc.c index 2162ea78..adddb344 100644 --- a/toxcore/assoc.c +++ b/toxcore/assoc.c | |||
@@ -425,22 +425,23 @@ static uint8_t candidates_create_internal(Assoc *assoc, hash_t hash, uint8_t *id | |||
425 | * 1. seen bad, heard good | 425 | * 1. seen bad, heard good |
426 | * 2. seen good | 426 | * 2. seen good |
427 | * 3. used */ | 427 | * 3. used */ |
428 | // enumerated lists are superior to magic numbers | ||
428 | if (!is_timeout(entry->used_at, BAD_NODE_TIMEOUT)) | 429 | if (!is_timeout(entry->used_at, BAD_NODE_TIMEOUT)) |
429 | check = 3; | 430 | check = USED; |
430 | 431 | ||
431 | if (!is_timeout(entry->seen_at, CANDIDATES_SEEN_TIMEOUT)) | 432 | if (!is_timeout(entry->seen_at, CANDIDATES_SEEN_TIMEOUT)) |
432 | check = 2; | 433 | check = SEENG; |
433 | else if (!is_timeout(entry->heard_at, CANDIDATES_HEARD_TIMEOUT)) | 434 | else if (!is_timeout(entry->heard_at, CANDIDATES_HEARD_TIMEOUT)) |
434 | check = 1; | 435 | check = SEENB_HEARDG; |
435 | else | 436 | else |
436 | check = 0; | 437 | check = BAD; |
437 | 438 | ||
438 | if (!pos_check[check]) | 439 | if (!pos_check[check]) |
439 | pos_check[check] = pos + 1; | 440 | pos_check[check] = pos + 1; |
440 | } | 441 | } |
441 | 442 | ||
442 | /* used > seen > heard > bad */ | 443 | /* used > seen > heard > bad */ |
443 | size_t i, pos_max = used ? 3 : (seen ? 2 : 1); | 444 | size_t i, pos_max = used ? USED : (seen ? SEENG : SEENB_HEARDG); |
444 | 445 | ||
445 | for (i = 0; i < pos_max; i++) | 446 | for (i = 0; i < pos_max; i++) |
446 | if (pos_check[i]) { | 447 | if (pos_check[i]) { |