aboutsummaryrefslogtreecommitdiffstats
path: root/FICS/playerdb.c
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2023-12-31 20:38:22 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2023-12-31 20:38:22 +0100
commit62faa7c848be51198dcbdb6645edfe6cbfeb4a42 (patch)
treec00e123075060bcd7d00b420fdf59c4c5fb5e8f2 /FICS/playerdb.c
parentd61396abe3ec958e8d619a3a8f9567ba90730580 (diff)
Reformatted get_empty_slot()
Diffstat (limited to 'FICS/playerdb.c')
-rw-r--r--FICS/playerdb.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/FICS/playerdb.c b/FICS/playerdb.c
index feb5f8f..051dd98 100644
--- a/FICS/playerdb.c
+++ b/FICS/playerdb.c
@@ -45,26 +45,24 @@
PUBLIC player parray[PARRAY_SIZE];
PUBLIC int p_num = 0;
-PRIVATE int get_empty_slot(void)
+PRIVATE int
+get_empty_slot(void)
{
- int i;
+ for (int i = 0; i < p_num; i++) {
+ if (parray[i].status == PLAYER_EMPTY)
+ return i;
+ }
- for (i = 0; i < p_num; i++) {
- if (parray[i].status == PLAYER_EMPTY) {
-/*** fprintf(stderr,"New player put in parray[%d/%d]\n", i, p_num-1);*/
- return i;
- }
- }
+ p_num++;
- p_num++;
+ if ((p_num + 1) >= PARRAY_SIZE) {
+ fprintf(stderr, "*** Bogus attempt to %s() past end of parray "
+ "***\n", __func__);
+ }
- if (p_num+1 >= PARRAY_SIZE) {
- fprintf(stderr, "*** Bogus attempt to get_empty_slot() past end of parray ***\n");
- }
+ parray[p_num - 1].status = PLAYER_EMPTY;
-/*** fprintf(stderr,"New player added in parray[%d]\n", p_num-1); */
- parray[p_num - 1].status = PLAYER_EMPTY;
- return p_num - 1;
+ return (p_num - 1);
}
PUBLIC void