-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.h
118 lines (97 loc) · 2.65 KB
/
player.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#ifndef PLAYER_H
#define PLAYER_H
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include "rank.h"
#include "block.h"
#include "colour.h"
#include "list.h"
#include "position.h"
struct client_t;
struct level_t;
enum
{
FLAG_PLACE_FIXED,
FLAG_PAINT,
FLAG_DISOWN,
FLAG_GLOBAL,
FLAG_GAMES,
};
enum mode_t
{
MODE_NORMAL,
MODE_INFO,
MODE_CUBOID,
MODE_REPLACE,
MODE_REMOVE_PILLAR,
MODE_PLACE_SOLID,
MODE_PLACE_WATER,
MODE_PLACE_LAVA,
MODE_PLACE_ACTIVE_WATER,
MODE_PLACE_ACTIVE_LAVA,
};
struct player_t
{
unsigned globalid;
unsigned levelid;
char *username;
char colourusername[67];
char gameusername[67];
char gamealias[67];
enum rank_t rank;
enum mode_t mode;
uint8_t flags;
uint8_t teleport;
uint8_t namemode;
unsigned last_active;
char afk[64];
struct position_t pos;
struct position_t oldpos;
struct position_t lastpos;
int speed;
int speeds[10];
int warnings;
unsigned spam[60];
int spampos1, spampos2;
struct level_t *level, *new_level;
struct client_t *client;
struct player_t *following;
unsigned filter;
unsigned cuboid_start;
enum blocktype_t cuboid_type;
enum blocktype_t replace_type;
enum blocktype_t bindings[BLOCK_END];
const char *hook_data;
};
bool player_t_compare(struct player_t **a, struct player_t **b);
LIST(player, struct player_t *, player_t_compare);
struct player_t *player_add(const char *username, struct client_t *c, bool *newuser, int *identified);
void player_del(struct player_t *player);
struct player_t *player_get_by_name(const char *username, bool partial);
bool player_change_level(struct player_t *player, struct level_t *level);
void player_move(struct player_t *player, struct position_t *pos);
void player_teleport(struct player_t *player, const struct position_t *pos, bool instant);
void player_undo(struct client_t *c, const char *username, const char *levelname, const char *timestamp);
enum rank_t rank_get_by_name(const char *rank);
const char *rank_get_name(enum rank_t rank);
enum colour_t rank_get_colour(enum rank_t rank);
static inline void player_toggle_mode(struct player_t *player, enum mode_t mode)
{
player->mode = (player->mode == mode) ? MODE_NORMAL : mode;
}
static inline const char *playername(const struct player_t *p, uint8_t mode)
{
switch (mode)
{
default:
case 0: if (*p->gamealias) return p->gamealias;
case 1: if (*p->gameusername) return p->gameusername;
case 2: return p->colourusername;
}
}
void player_send_positions(unsigned cur_tick);
bool player_check_spam(struct player_t *player);
void player_set_alias(struct player_t *player, const char *alias, bool send_spawn);
void player_list(struct client_t *c, const struct level_t *l);
#endif /* PLAYER_H */