-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathclient.h
196 lines (167 loc) · 3.99 KB
/
client.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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#ifndef CLIENT_H
#define CLIENT_H
#include <stdio.h>
#include <sparrowNet.h>
#include <sparrow3d.h>
#include <string.h>
#define CLIENT_VERSION 18
#define TRACE_COUNT 16
#define MAP_JUMP 0
#define MAP_SHOOT 1
#define MAP_WEAPON 2
#define MAP_VIEW 3
#define MAP_POWER_UP 4
#define MAP_POWER_DN 5
#define MAP_CHAT 6
#define MAP_MENU 7
#define KEY_POLL_MASK (1 << spMapPoolByID(MAP_JUMP))
#define SPRITE_COUNT 26
#ifndef DATA_FOLDER
#define DATA_FOLDER "."
#endif
#define CIRCLE_CHECKPOINTS 32
#define W_POWER_DIVISOR 3
typedef struct sMessage *pMessage;
typedef struct sMessage
{
char name[256];
char content[1024];
int l;
pMessage next;
} tMessage;
typedef struct sPlayer *pPlayer;
typedef union
{
Uint32 compressed;
struct
{
Uint8 ap_health;
Uint8 ragnarok_border;
Uint8 distant_damage_handicap_count;
Uint8 handicap_health;
} bytewise;
} game_options_union;
typedef struct sGame *pGame;
typedef struct sGame
{
int id;
char name[33];
char level_string[512];
game_options_union options;
int player_count;
int create_date;
int seconds_per_turn;
int hares_per_player;
int status;
int admin_pw;
pGame next;
int local;
pPlayer local_player;
int local_counter;
int sprite_count[SPRITE_COUNT];
} tGame;
typedef struct sThreadData *pThreadData;
typedef struct sBullet *pBullet;
typedef struct sBulletTrace *pBulletTrace;
typedef struct sBulletTrace
{
Sint32 x,y;
pBullet bullet;
pBulletTrace next;
} tBulletTrace;
typedef struct sHare *pHare;
typedef struct sHare
{
int direction;
int w_direction;
int w_power;
int w_build_direction;
int w_build_distance;
Sint32 x,y;
Sint32 dx,dy;
Sint32 rotation;
int bums;
int hops;
int high_hops;
int health;
spSpriteCollectionPointer hase;
pHare before,next;
int wp_x,wp_y;
Sint32 cam_rotation;
int circle_checkpoint_hit[CIRCLE_CHECKPOINTS];
pHare circle_checkpoint_hare[CIRCLE_CHECKPOINTS];
int jump_failed;
} tHare;
typedef struct sPlayer
{
int id;
char name[33];
int pw;
int position_in_game;
pGame game;
pPlayer next;
SDL_Thread* input_thread;
SDL_mutex* input_mutex;
pThreadData input_data;
pThreadData last_input_data_write;
pThreadData last_input_data_read;
int input_message;
int computer;
int nr;
//ingame
pHare firstHare;
pHare activeHare;
pHare setActiveHare;
int local;
int time;
pBulletTrace trace[TRACE_COUNT];
int tracePos;
int d_health;
int d_time;
int weapon_points;
int next_round_extra;
int kicked;
SDL_Thread* heartbeat_thread;
int heartbeat_message;
} tPlayer;
typedef struct sThreadData
{
pPlayer player;
int second_of_player;
char data[1536];
pThreadData next;
} tThreadData;
extern int last_heartbeat_diff;
int server_info();
pGame create_game(char* game_name,Uint32 options,int seconds_per_turn,char* level_string,int local,int hares_per_player);
void delete_game_list(pGame game);
void delete_game(pGame game);
int get_games(pGame *gameList);
void delete_player_list(pPlayer player);
pPlayer join_game(pGame game,char* name,int ai,int nr);
void leave_game(pPlayer player);
void kick(pPlayer player);
int get_game(pGame game,pPlayer *playerList);
void set_status(pGame game,int status);
void change_game(pGame game,Uint32 options,int seconds_per_turn,int hares_per_player);
void set_level(pGame game,char* level_string);
int push_game(pPlayer player,int second_of_player,void* data);
void push_game_thread(pPlayer player,int second_of_player,void* data);
void start_push_thread();
int end_push_thread(int kill);
int pull_game(pPlayer player,int second_of_player,void* data);
int pull_game_thread(pPlayer player,int second_of_player,void* data);
void start_pull_thread(pPlayer player);
void end_pull_thread(pPlayer player);
int connect_to_server();
void log_message(char* name,char* message);
void start_irc_client(char* name);
void stop_irc_client();
void try_to_join();
spNetIRCChannelPointer get_channel();
void send_chat(pGame game,char* chat_message);
void start_heartbeat(pPlayer player);
void stop_heartbeat(pPlayer player);
char* ingame_message(char* message,char* game_name);
void start_random_music();
#endif