/
player.h
169 lines (153 loc) · 4.53 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*
Copyright (c) 2017-2020 ByteBit
This file is part of BetterSpades.
BetterSpades is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
BetterSpades is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with BetterSpades. If not, see <http://www.gnu.org/licenses/>.
*/
#define PLAYERS_MAX 256 // just because 32 players are not enough
#define TEAM_1 0
#define TEAM_2 1
#define TEAM_SPECTATOR 255
extern struct GameState {
struct Team {
char name[11];
unsigned char red, green, blue;
} team_1;
struct Team team_2;
unsigned char gamemode_type;
union Gamemodes gamemode;
struct {
unsigned char team_capturing, tent;
float progress, rate, update;
} progressbar;
} gamestate;
#define GAMEMODE_CTF 0
#define GAMEMODE_TC 1
extern unsigned char local_player_id;
extern unsigned char local_player_health;
extern unsigned char local_player_blocks;
extern unsigned char local_player_grenades;
extern unsigned char local_player_ammo, local_player_ammo_reserved;
extern unsigned char local_player_respawn_time;
extern float local_player_death_time;
extern unsigned char local_player_respawn_cnt_last;
extern unsigned char local_player_newteam;
extern unsigned char local_player_lasttool;
extern float local_player_last_damage_timer;
extern float local_player_last_damage_x;
extern float local_player_last_damage_y;
extern float local_player_last_damage_z;
extern char local_player_drag_active;
extern int local_player_drag_x;
extern int local_player_drag_y;
extern int local_player_drag_z;
extern int player_intersection_type;
extern int player_intersection_player;
extern float player_intersection_dist;
struct player_intersection {
unsigned char head : 1;
unsigned char torso : 1;
unsigned char leg_left : 1;
unsigned char leg_right : 1;
unsigned char arms : 1;
union {
struct {
float head;
float torso;
float leg_left;
float leg_right;
float arms;
};
float values[5];
} distance;
};
int player_intersection_exists(struct player_intersection* s);
int player_intersection_choose(struct player_intersection* s);
float player_intersection_choose_dist(struct player_intersection* s);
extern struct Player {
char name[17];
struct Position {
float x, y, z;
} pos;
struct Orientation {
float x, y, z;
} orientation;
AABB bb_2d;
struct Orientation orientation_smooth;
struct Position gun_pos;
struct Position casing_dir;
float gun_shoot_timer;
int ammo, ammo_reserved;
float spade_use_timer;
unsigned char spade_used, spade_use_type;
unsigned int score;
unsigned char team, weapon, held_item;
unsigned char alive, connected;
float item_showup, item_disabled, items_show_start;
unsigned char items_show;
union {
unsigned int packed;
struct {
unsigned char red, green, blue;
};
} block;
struct {
union {
unsigned char packed; // useful to load PacketInput quickly
struct {
unsigned char up : 1;
unsigned char down : 1;
unsigned char left : 1;
unsigned char right : 1;
unsigned char jump : 1;
unsigned char crouch : 1;
unsigned char sneak : 1;
unsigned char sprint : 1;
};
} keys;
union {
unsigned char packed;
struct {
unsigned char lmb : 1;
unsigned char rmb : 1;
float lmb_start, rmb_start;
};
} buttons;
} input;
struct {
unsigned char jump, airborne, wade;
float lastclimb;
struct Velocity {
float x, y, z;
} velocity;
struct Position eye;
} physics;
struct {
struct Sound_source feet;
float feet_started, feet_started_cycle;
char feet_cylce;
struct Sound_source tool;
float tool_started;
} sound;
} players[PLAYERS_MAX];
// pyspades/pysnip/piqueserver sometimes uses ids that are out of range
int player_can_spectate(struct Player* p);
float player_section_height(int section);
void player_init(void);
float player_height(struct Player* p);
float player_height2(struct Player* p);
void player_reposition(struct Player* p);
void player_update(float dt, int locked);
void player_render_all(void);
void player_render(struct Player* p, int id, Ray* ray, char render, struct player_intersection* intersects);
void player_reset(struct Player* p);
int player_move(struct Player* p, float fsynctics, int id);
int player_uncrouch(struct Player* p);