X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2Fmodules%2FNeonFun.mod%2Fgame_uno.c;h=6481683981ba7805cd048bc9dddd5874ae96f168;hb=55428a9588d97fe59cbe9d1b497ec6bce0baeae5;hp=4f17aebe40ac4188844bab73883f51ce72d8f13d;hpb=eb2aab55a1f97b329c0409d32d35d1f112facedb;p=NeonServV5.git diff --git a/src/modules/NeonFun.mod/game_uno.c b/src/modules/NeonFun.mod/game_uno.c index 4f17aeb..6481683 100644 --- a/src/modules/NeonFun.mod/game_uno.c +++ b/src/modules/NeonFun.mod/game_uno.c @@ -1,4 +1,4 @@ -/* game_uno.c - NeonServ v5.4 +/* game_uno.c - NeonServ v5.5 * Copyright (C) 2011-2012 Philipp Kreil (pk910) * * This program is free software: you can redistribute it and/or modify @@ -141,6 +141,7 @@ void uno_free_deck(struct uno_card_deck *deck) { free(card); } } + free(deck); } void uno_free_player(struct uno_player *player, struct uno_card_deck *deck) { @@ -276,7 +277,7 @@ TIMEQ_CALLBACK(uno_game_wait_timeout) { struct uno_game *game = data; game->timer = NULL; if(game->players == 1) { - //TEXT: too less users + uno_reply(game, NULL, "NF_UNO_LESS_PLAYERS"); uno_free_game(game); return; } @@ -479,7 +480,7 @@ struct uno_card *uno_parse_card(struct uno_game *game, struct uno_player *player int uno_check_card_valid(struct uno_game *game, struct uno_card *card) { if(game->take_cards_pending && card->card != game->top_card->card) return 1; - if(card->color == UNO_COLOR_BLACK) + if(card->color == UNO_COLOR_BLACK || game->top_card->color == UNO_COLOR_BLACK) return 0; if(card->color != game->top_card->color && card->card != game->top_card->card) return 1; @@ -510,6 +511,8 @@ void uno_play_card(struct uno_game *game, struct uno_player *player, struct uno_ uno_reply(game, NULL, "NF_UNO_USER_WIN", game->active_player->chanuser->user->nick); if(player->prev) player->prev->next = player->next; + else + game->player = player->next; if(player->next) player->next->prev = player->prev; player->next = NULL; @@ -555,7 +558,7 @@ void uno_play_card(struct uno_game *game, struct uno_player *player, struct uno_ winner_count = 1; char rank_buf[20], won_buf[50], total_won_buf[50]; char *tmp, *tmp2; - for(cplayer = game->winner; cplayer->next; cplayer = cplayer->next) { + for(cplayer = game->winner; cplayer; cplayer = cplayer->next) { sprintf(rank_buf, "%d", winner_count++); content[0] = rank_buf; content[1] = cplayer->chanuser->user->nick; @@ -634,19 +637,6 @@ void uno_event_part(struct ChanUser *chanuser) { } } -void uno_event_quit(struct UserNode *user) { - struct uno_game *game; - for(game = uno_active_games; game; game = game->next) { - struct uno_player *player; - for(player = game->player; player; player = player->next) { - if(player->chanuser->user == user) { - uno_free_player(player, game->deck); - break; - } - } - } -} - void uno_event_freechan(struct ChanNode *chan) { struct uno_game *game; for(game = uno_active_games; game; game = game->next) {