-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.h
89 lines (78 loc) · 1.88 KB
/
common.h
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#ifndef _COMMON_H_
#define _COMMON_H_
#include <stdio.h>
#include <time.h>
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
enum CardType { YELLOW, RED };
enum PlayerRole { KEEPER, FIELD };
enum InputType {
WIDGET_SCOREBOARD_TOGGLE, WIDGET_GAMEPLAN_TOGGLE,
WIDGET_LIVEPLAN_TOGGLE, WIDGET_GAMESTART_TOGGLE, WIDGET_AD_TOGGLE,
OBS_STREAM_START, OBS_STREAM_STOP, OBS_REPLAY_START, OBS_REPLAY_STOP,
T1_SCORE_PLUS, T1_SCORE_MINUS, T2_SCORE_PLUS, T2_SCORE_MINUS,
GAME_NEXT, GAME_PREV, GAME_SWITCH_SIDES,
TIME_PLUS, TIME_MINUS, TIME_PLUS_20, TIME_MINUS_20,
TIME_TOGGLE_PAUSE, TIME_RESET, YELLOW_CARD, RED_CARD
};
#pragma pack(push, 1)
typedef struct {
u8 t1;
u8 t2;
} Score;
typedef struct {
u8 player_index;
enum CardType card_type;
} Card;
typedef struct {
char *name;
u8 team_index;
enum PlayerRole role;
} Player;
typedef struct {
u8 keeper_index;
u8 field_index;
char *name;
char *logo_filename;
char *color_light;
char *color_dark;
} Team;
typedef struct {
u8 t1_index;
u8 t2_index;
Score halftimescore;
Score score;
Card *cards;
u8 cards_count;
u8 replays_count;
} Game;
typedef struct {
struct {
u8 gameindex; // index of the current game played in the games array.
bool halftime; // 0: first half, 1: second half
bool pause;
u16 time;
time_t timestart;
} cur;
u16 deftime;
Game *games;
u8 games_count;
Team *teams;
u8 teams_count;
Player *players;
u8 players_count;
} Matchday;
#pragma pack(pop)
void matchday_init();
void matchday_free();
int player_index(const char *name);
int team_index(const char *name);
char *json_generate();
void json_load(const char *path);
char *file_read(const char *path);
bool file_write(const char *path, const char *s);
void merge_sort(void *base, size_t num, size_t size, int (*compar)(const void *, const void *));
char *gettimems();
u8 add_card(enum CardType type, u8 player_index);
#endif // _COMMON_H_