summaryrefslogtreecommitdiff
path: root/lib/snapshot.h
blob: 022d989ba47d1ee1ed9225e4b1a9a9ed6cda63c2 (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
33
34
35
36
37
38
39
#include "types.h"
#include "constants.h"

enum {
	STATE_INACTIVE = 0,
	STATE_ACTIVE,
	STATE_REMOVED,
	STATE_DEAD
};

struct player {
	uint8_t state;
	uint8_t input;
	char pad[2];
	vec2 pos;
	vec2 vel;
};

struct ball {
	uint8_t state;
	vec2 pos;
	vec2 vel;
};

struct snapshot {
	char active;
	uint32_t tick;
	struct player players[WORLD_MAX_PLAYERS];
	struct ball balls[WORLD_MAX_BULLETS];
};

int dp_snapshot_put_player(struct snapshot *, uint32_t id, const struct player *);
struct player *dp_snapshot_get_player(struct snapshot *, uint32_t id);
int dp_snapshot_remove_player(struct snapshot *, uint32_t id);
int dp_snapshot_set_player_input(struct snapshot *, uint32_t id, uint8_t input);

int dp_snapshot_put_ball(struct snapshot *, uint32_t id, const struct ball *);
struct ball *dp_snapshot_get_ball(struct snapshot *, uint32_t id);
int dp_snapshot_remove_ball(struct snapshot *, uint32_t id);