From 5d5da755a66ac3940b7808c311323f200a8c1a23 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Sun, 31 Dec 2023 15:38:58 +0100 Subject: Reformatted player_find_pendfrom() --- FICS/playerdb.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/FICS/playerdb.c b/FICS/playerdb.c index 0be118b..9f6d4c7 100644 --- a/FICS/playerdb.c +++ b/FICS/playerdb.c @@ -1410,27 +1410,31 @@ PUBLIC int player_remove_pendto(int p, int p1, int type) return 0; } -PUBLIC int player_find_pendfrom(int p, int p1, int type) +PUBLIC int +player_find_pendfrom(int p, int p1, int type) { - int i; + for (int i = 0; i < parray[p].num_from; i++) { + if (parray[p].p_from_list[i].whofrom != p1 && p1 != -1) + continue; + if (type == PEND_ALL || parray[p].p_from_list[i].type == type) + return i; + if (type < 0 && parray[p].p_from_list[i].type != -type) + return i; + /* + * The above "if" allows a type of -PEND_SIMUL to + * match every request EXCEPT simuls, for example. I'm + * doing this because Heringer does not want to + * decline simul requests when he makes a move in a + * sumul. -- hersco. + */ + + if (type == PEND_BUGHOUSE && + parray[p].p_from_list[i].type == PEND_MATCH && + !strcmp(parray[p].p_from_list[i].char2, "bughouse")) + return i; + } - for (i = 0; i < parray[p].num_from; i++) { - if (parray[p].p_from_list[i].whofrom != p1 && p1 != -1) - continue; - if (type == PEND_ALL || parray[p].p_from_list[i].type == type) - return i; - if (type < 0 && parray[p].p_from_list[i].type != -type) - return i; - /* The above "if" allows a type of -PEND_SIMUL to match every request - EXCEPT simuls, for example. I'm doing this because Heringer does - not want to decline simul requests when he makes a move in a sumul. - -- hersco. */ - if (type == PEND_BUGHOUSE - && parray[p].p_from_list[i].type == PEND_MATCH - && !strcmp(parray[p].p_from_list[i].char2, "bughouse")) - return i; - } - return -1; + return -1; } PUBLIC int -- cgit v1.2.3