summaryrefslogtreecommitdiffstats
path: root/main.h
blob: 7acb25f58fe84d5252611f01b85004fe4ae5afc1 (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
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
#ifndef SAUERBOT_MAIN_H_
#define SAUERBOT_MAIN_H_

#include "auth.h"
#include "list.h"
#include "enet/enet.h"

#include <dirent.h>


#undef min
#define min(a, b)	((a) < (b) ? (a) : (b))
#undef max
#define max(a, b)	((a) < (b) ? (b) : (a))
#undef ARRAY_SIZE
#define ARRAY_SIZE(a)	(sizeof(a)/sizeof((a)[0]))
#define tostring__(x)	#x
#define tostring(x)	tostring__(x)
#define VERSION		tostring(_VERSION)


#define SBOT_SERVER_PORT	28785
#define SBOT_SERVINFO_PORT	28786
#define SBOT_RATE		(25000 / 8)
#define SBOT_NUM_CHANNELS	3
#define SBOT_PROT_VER		253

int random_int(void);

enum sbot_net_msg {
	SBOT_MSG_INITS2C = 0,
	SBOT_MSG_INITC2S,
	SBOT_MSG_POS,
	SBOT_MSG_TEXT,
	SBOT_MSG_SOUND,
	SBOT_MSG_CDIS,
	SBOT_MSG_DIED,
	SBOT_MSG_DAMAGE,
	SBOT_MSG_SHOT,
	SBOT_MSG_FRAGS,
	SBOT_MSG_GUNSELECT,
	SBOT_MSG_MAPCHANGE,
	SBOT_MSG_MAPVOTE,
	SBOT_MSG_ITEMSPAWN,
	SBOT_MSG_ITEMPICKUP,
	SBOT_MSG_DENIED,
	SBOT_MSG_PING,
	SBOT_MSG_PONG,
	SBOT_MSG_CLIENTPING,
	SBOT_MSG_TIMEUP,
	SBOT_MSG_MAPRELOAD,
	SBOT_MSG_ITEMACC,
	SBOT_MSG_SERVMSG,
	SBOT_MSG_ITEMLIST,
	SBOT_MSG_RESUME,
	SBOT_MSG_EDITENT,
	SBOT_MSG_EDITF,
	SBOT_MSG_EDITT,
	SBOT_MSG_EDITM,
	SBOT_MSG_FLIP,
	SBOT_MSG_COPY,
	SBOT_MSG_PASTE,
	SBOT_MSG_ROTATE,
	SBOT_MSG_REPLACE,
	SBOT_MSG_DELCUBE,
	SBOT_MSG_NEWMAP,
	SBOT_MSG_GETMAP,
	SBOT_MSG_MASTERMODE,
	SBOT_MSG_KICK,
	SBOT_MSG_CURRENTMASTER,
	SBOT_MSG_SPECTATOR,
	SBOT_MSG_SETMASTER,
	SBOT_MSG_SETTEAM,
	SBOT_MSG_BASES,
	SBOT_MSG_BASEINFO,
	SBOT_MSG_TEAMSCORE,
	SBOT_MSG_REPAMMO,
	SBOT_MSG_FORCEINTERMISSION,
	SBOT_MSG_ANNOUNCE,
	SBOT_MSG_CLIENT,
};

struct sbot_connection {
	ENetHost *client;
	ENetPeer *peer;
};

/* A client in the game */
struct sclient {
	int clientnum;
	char nick[50];
	char team[5];

	int is_spectator;
	int authenticated;
	/* Context while auth is in progress */
	struct auth_context auth;

	struct list_head list;
};

enum gamemode {
	GAMEMODE_UNKNOWN = 0,
	GAMEMODE_COOPEDIT,
	/* don't care for other modes, yet */
};

struct sbot {
	const char *nick;
	const char *team;

	/* Directory where the maps are stored. */
	DIR *maps_dir;
	const char *maps_dirname;

	/* The map in memory */
	unsigned char *map;
	size_t maplen;
	char mapname[128];

	enum gamemode mode;

	/* sauerbot's clientnum */
	int clientnum;
	/* List of connected clients */
	struct list_head clients;

	struct sbot_authmap authmap;

	struct sbot_connection conn;
};

#endif /* SAUERBOT_MAIN_H_ */
bues.ch cgit interface