From da7f99e51a9c2a999bf6b874175ee6e9931c58b3 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Sun, 28 Apr 2024 16:53:53 +0200 Subject: Reformatted GameNumFromParam() --- FICS/obsproc.c | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) (limited to 'FICS/obsproc.c') diff --git a/FICS/obsproc.c b/FICS/obsproc.c index 644a54b..08c1eaa 100644 --- a/FICS/obsproc.c +++ b/FICS/obsproc.c @@ -47,23 +47,34 @@ #include "rmalloc.h" #include "utils.h" -PUBLIC int GameNumFromParam(int p, int *p1, parameter *param) +PUBLIC int +GameNumFromParam(int p, int *p1, parameter *param) { - if (param->type == TYPE_WORD) { - *p1 = player_find_part_login(param->val.word); - if (*p1 < 0) { - pprintf(p, "No user named \"%s\" is logged in.\n", param->val.word); - return -1; - } - if (parray[*p1].game < 0) - pprintf(p, "%s is not playing a game.\n", parray[*p1].name); - return parray[*p1].game; - } else { /* Must be an integer */ - *p1 = -1; - if (param->val.integer <= 0) - pprintf(p, "%d is not a valid game number.\n", param->val.integer); - return param->val.integer - 1; - } + if (param->type == TYPE_WORD) { + *p1 = player_find_part_login(param->val.word); + + if (*p1 < 0) { + pprintf(p, "No user named \"%s\" is logged in.\n", + param->val.word); + return -1; + } + + if (parray[*p1].game < 0) { + pprintf(p, "%s is not playing a game.\n", + parray[*p1].name); + } + + return parray[*p1].game; + } else { // Must be an integer + *p1 = -1; + + if (param->val.integer <= 0) { + pprintf(p, "%d is not a valid game number.\n", + param->val.integer); + } + + return (param->val.integer - 1); + } } PRIVATE int -- cgit v1.2.3