#ifndef SAUERBOT_MAIN_H_ #define SAUERBOT_MAIN_H_ #include "auth.h" #include "list.h" #include "enet/enet.h" #include #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_ */