diff options
author | irungentoo <irungentoo@gmail.com> | 2014-02-17 09:18:27 -0500 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2014-02-17 09:18:27 -0500 |
commit | f152d4c94dc8ecb567a6882b97f2ff95d56893ce (patch) | |
tree | f9951c1c1799a001c681302ef1bd8763c2dd7a21 /toxcore/assoc.c | |
parent | baa4a2f11d9178e7506b24acaf7973cf17e0877d (diff) | |
parent | 96e3f7053fcfafa1bdd497e94a663837a0188e5a (diff) |
Merge branch 'lehi-dev' of https://github.com/lehitoskin/ProjectTox-Core into lehitoskin-lehi-dev
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]) { |