From 9970a2275a56d7835ba0c12a8586dc25cf7ec1cf Mon Sep 17 00:00:00 2001 From: scratko Date: Sun, 18 Aug 2024 01:33:08 +0300 Subject: Global fixes v4.0 Removed unnecessary comments. Added resource cleanup for client and server. Changed queue display. Added player indicator. It's possible to quit the game while typing or waiting for a connection. Fixed a bug with determining the limit of card tossing. --- server/card_queue.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'server/card_queue.c') diff --git a/server/card_queue.c b/server/card_queue.c index 194ea0c..c5d59a8 100644 --- a/server/card_queue.c +++ b/server/card_queue.c @@ -45,6 +45,8 @@ const char* pop_card_queue(struct card_queue *cq) cq->first = cq->first->next; card = tmp->str; free(tmp); + if(!cq->first) + cq->last = NULL; return card; } @@ -59,3 +61,16 @@ int find_out_card_quantity_in_cq(const struct card_queue *cq) } return counter; } + +void clear_queue(struct card_queue *cq) +{ + struct card_queue_item *tmp; + + while(cq->first) { + tmp = cq->first; + cq->first = cq->first->next; + free(tmp); + } + cq->first = NULL; + cq->last = NULL; +} -- cgit v1.2.3