diff options
-rw-r--r-- | toxcore/assoc.c | 11 | ||||
-rw-r--r-- | toxcore/assoc.h | 3 |
2 files changed, 9 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]) { |
diff --git a/toxcore/assoc.h b/toxcore/assoc.h index b03792c3..9dbc75f2 100644 --- a/toxcore/assoc.h +++ b/toxcore/assoc.h | |||
@@ -7,6 +7,9 @@ | |||
7 | 7 | ||
8 | /* For the legalese parts, see tox.h. */ | 8 | /* For the legalese parts, see tox.h. */ |
9 | 9 | ||
10 | /* enumerated lists are superior to magic numbers */ | ||
11 | enum NODE_STATUS { BAD, SEENB_HEARDG, SEENG, USED }; | ||
12 | |||
10 | /* | 13 | /* |
11 | * Module to store currently unused ID <=> IP associations | 14 | * Module to store currently unused ID <=> IP associations |
12 | * for a potential future use | 15 | * for a potential future use |