diff options
| author | Mario Kilies <MarioKilies@GMX.net> | 2011-01-25 13:14:17 +0100 |
|---|---|---|
| committer | Mario Kilies <MarioKilies@GMX.net> | 2011-01-25 13:14:17 +0100 |
| commit | 52f95177eb8050f073a3d65413feb16cfce93baa (patch) | |
| tree | f94b78be6d4b09fe3ee7d93d4b40c80387a80f33 /src/player.c | |
| parent | 3fc586325f8fc8fb4f1990bf87ad4c37e722f381 (diff) | |
Removed awkward pnoc_t and refactored its contents to the new player_list_entry_t.
Diffstat (limited to 'src/player.c')
| -rw-r--r-- | src/player.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/player.c b/src/player.c index 3e03729..b264922 100644 --- a/src/player.c +++ b/src/player.c @@ -1,9 +1,12 @@ #include "player.h" #include <stdlib.h> +#include <assert.h> -pnoc_t* get_pnoc_from_playerid(player_list* pl, const uint8_t pid) +player_list_entry_t *get_player_list_entry_by_player_id(player_list_t *pl, const player_id_t pid) { - for(int i=0; i<pl->count; i++) + assert(pl != NULL); + + for(int i = 0; i < pl->count; i++) { if(pl->players[i].player_id != pid) continue; @@ -13,3 +16,17 @@ pnoc_t* get_pnoc_from_playerid(player_list* pl, const uint8_t pid) return NULL; } +static int ple_comparator(const void *a, const void *b) +{ + player_list_entry_t ple1 = *(player_list_entry_t *)a; + player_list_entry_t ple2 = *(player_list_entry_t *)b; + + return ple1.open_card - ple2.open_card; +} + +void player_list_sort_by_open_card(player_list_t *pl, const uint8_t num_entries) +{ + assert(pl != NULL); + + qsort(pl, num_entries, sizeof(player_list_entry_t), ple_comparator); +} |
