blob: 235add8e8df150ae7ded13cfb1dd11353a0686db (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#include "player.h"
#include <stdlib.h>
#include <assert.h>
player_list_entry_t *get_player_list_entry_by_player_id(player_list_t *pl, const player_id_t pid)
{
assert(pl != NULL);
for(int i = 0; i < pl->count; i++)
{
if(pl->players[i].player_id != pid)
continue;
return &pl->players[i];
}
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->players, num_entries, sizeof(player_list_entry_t), ple_comparator);
}
|