| 1 | /* |
| 2 | * Copyright (C) 1998 Mark Baysinger ([email protected]) |
| 3 | * Copyright (C) 1998,1999,2000,2001 Ross Combs ([email protected]) |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License |
| 7 | * as published by the Free Software Foundation; either version 2 |
| 8 | * of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 | */ |
| 19 | #ifndef INCLUDED_GAME_TYPES |
| 20 | #define INCLUDED_GAME_TYPES |
| 21 | |
| 22 | #ifdef GAME_INTERNAL_ACCESS |
| 23 | |
| 24 | #ifdef JUST_NEED_TYPES |
| 25 | # include "account.h" |
| 26 | # include "connection.h" |
| 27 | # include "channel.h" |
| 28 | # include "common/tag.h" |
| 29 | # include "common/elist.h" |
| 30 | #else |
| 31 | # define JUST_NEED_TYPES |
| 32 | # include "account.h" |
| 33 | # include "connection.h" |
| 34 | # include "channel.h" |
| 35 | # include "common/tag.h" |
| 36 | # include "common/elist.h" |
| 37 | # undef JUST_NEED_TYPES |
| 38 | #endif |
| 39 | |
| 40 | #endif |
| 41 | |
| 42 | namespace pvpgn |
| 43 | { |
| 44 | |
| 45 | namespace bnetd |
| 46 | { |
| 47 | |
| 48 | typedef enum |
| 49 | { |
| 50 | game_type_none, |
| 51 | game_type_all, |
| 52 | game_type_topvbot, |
| 53 | game_type_melee, |
| 54 | game_type_ffa, |
| 55 | game_type_oneonone, |
| 56 | game_type_ctf, |
| 57 | game_type_greed, |
| 58 | game_type_slaughter, |
| 59 | game_type_sdeath, |
| 60 | game_type_ladder, |
| 61 | game_type_ironman, |
| 62 | game_type_mapset, |
| 63 | game_type_teammelee, |
| 64 | game_type_teamffa, |
| 65 | game_type_teamctf, |
| 66 | game_type_pgl, |
| 67 | game_type_diablo, |
| 68 | game_type_diablo2open, |
| 69 | game_type_diablo2closed, |
| 70 | game_type_anongame |
| 71 | } t_game_type; |
| 72 | |
| 73 | typedef enum |
| 74 | { |
| 75 | game_status_started, |
| 76 | game_status_full, |
| 77 | game_status_open, |
| 78 | game_status_loaded, |
| 79 | game_status_done |
| 80 | } t_game_status; |
| 81 | |
| 82 | typedef enum |
| 83 | { |
| 84 | game_result_none, |
| 85 | game_result_win, |
| 86 | game_result_loss, |
| 87 | game_result_draw, |
| 88 | game_result_disconnect, |
| 89 | game_result_observer, |
| 90 | game_result_playing |
| 91 | } t_game_result; |
| 92 | |
| 93 | typedef enum |
| 94 | { |
| 95 | game_option_none, |
| 96 | game_option_melee_normal, |
| 97 | game_option_ffa_normal, |
| 98 | game_option_oneonone_normal, |
| 99 | game_option_ctf_normal, |
| 100 | game_option_greed_10000, |
| 101 | game_option_greed_7500, |
| 102 | game_option_greed_5000, |
| 103 | game_option_greed_2500, |
| 104 | game_option_slaughter_60, |
| 105 | game_option_slaughter_45, |
| 106 | game_option_slaughter_30, |
| 107 | game_option_slaughter_15, |
| 108 | game_option_sdeath_normal, |
| 109 | game_option_ladder_countasloss, |
| 110 | game_option_ladder_nopenalty, |
| 111 | game_option_mapset_normal, |
| 112 | game_option_teammelee_4, |
| 113 | game_option_teammelee_3, |
| 114 | game_option_teammelee_2, |
| 115 | game_option_teamffa_4, |
| 116 | game_option_teamffa_3, |
| 117 | game_option_teamffa_2, |
| 118 | game_option_teamctf_4, |
| 119 | game_option_teamctf_3, |
| 120 | game_option_teamctf_2, |
| 121 | game_option_topvbot_7, |
| 122 | game_option_topvbot_6, |
| 123 | game_option_topvbot_5, |
| 124 | game_option_topvbot_4, |
| 125 | game_option_topvbot_3, |
| 126 | game_option_topvbot_2, |
| 127 | game_option_topvbot_1 |
| 128 | } t_game_option; |
| 129 | |
| 130 | typedef enum |
| 131 | { |
| 132 | game_maptype_none, |
| 133 | game_maptype_selfmade, |
| 134 | game_maptype_blizzard, |
| 135 | game_maptype_ladder, |
| 136 | game_maptype_pgl, |
| 137 | game_maptype_kbk, |
| 138 | game_maptype_compusa |
| 139 | } t_game_maptype; |
| 140 | |
| 141 | typedef enum |
| 142 | { |
| 143 | game_tileset_none, |
| 144 | game_tileset_badlands, |
| 145 | game_tileset_space, |
| 146 | game_tileset_installation, |
| 147 | game_tileset_ashworld, |
| 148 | game_tileset_jungle, |
| 149 | game_tileset_desert, |
| 150 | game_tileset_ice, |
| 151 | game_tileset_twilight |
| 152 | } t_game_tileset; |
| 153 | |
| 154 | typedef enum |
| 155 | { |
| 156 | game_speed_none, |
| 157 | game_speed_slowest, |
| 158 | game_speed_slower, |
| 159 | game_speed_slow, |
| 160 | game_speed_normal, |
| 161 | game_speed_fast, |
| 162 | game_speed_faster, |
| 163 | game_speed_fastest |
| 164 | } t_game_speed; |
| 165 | |
| 166 | typedef enum |
| 167 | { |
| 168 | game_difficulty_none, |
| 169 | game_difficulty_normal, |
| 170 | game_difficulty_nightmare, |
| 171 | game_difficulty_hell, |
| 172 | game_difficulty_hardcore_normal, |
| 173 | game_difficulty_hardcore_nightmare, |
| 174 | game_difficulty_hardcore_hell |
| 175 | } t_game_difficulty; |
| 176 | |
| 177 | typedef enum { |
| 178 | game_flag_none, |
| 179 | game_flag_private |
| 180 | } t_game_flag; |
| 181 | |
| 182 | |
| 183 | typedef enum |
| 184 | { |
| 185 | gamelist_source_none, |
| 186 | gamelist_source_joinbutton /* show gamelist when user clicks "Join" button */ |
| 187 | } t_gamelist_source_type; |
| 188 | |
| 189 | typedef struct game |
| 190 | #ifdef GAME_INTERNAL_ACCESS |
| 191 | { |
| 192 | char const * name; |
| 193 | char const * pass; |
| 194 | char const * info; |
| 195 | t_game_type type; |
| 196 | unsigned int realm; |
| 197 | char const * realmname; |
| 198 | t_clienttag clienttag; /* type of client (STAR, SEXP, etc) */ |
| 199 | unsigned int addr; /* host IP */ |
| 200 | unsigned short port; /* host port */ |
| 201 | int startver; |
| 202 | unsigned long version; |
| 203 | t_game_status status; |
| 204 | unsigned int ref; /* current number of players */ |
| 205 | unsigned int count; /* max number of players */ |
| 206 | unsigned int id; |
| 207 | char const * mapname; |
| 208 | t_game_option option; |
| 209 | t_game_maptype maptype; |
| 210 | t_game_tileset tileset; |
| 211 | t_game_speed speed; |
| 212 | unsigned int mapsize_x; |
| 213 | unsigned int mapsize_y; |
| 214 | unsigned int maxplayers; |
| 215 | |
| 216 | t_connection * owner; |
| 217 | t_connection * * connections; |
| 218 | t_account * * players; |
| 219 | t_game_result * results; |
| 220 | t_game_result * * reported_results; |
| 221 | char const * * report_heads; |
| 222 | char const * * report_bodies; |
| 223 | |
| 224 | t_channel * channel; /* For Games with server-side chat support */ |
| 225 | |
| 226 | std::time_t create_time; |
| 227 | std::time_t start_time; |
| 228 | std::time_t lastaccess_time; |
| 229 | int bad; /* if 1, then the results will be ignored */ |
| 230 | unsigned difficulty; |
| 231 | char const * description; |
| 232 | t_game_flag flag; |
| 233 | t_elist glist_link; |
| 234 | } |
| 235 | #endif |
| 236 | t_game; |
| 237 | |
| 238 | typedef int(*t_glist_func)(t_game *, void *); |
| 239 | |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | #endif |
| 244 | |
| 245 | |
| 246 | #ifndef JUST_NEED_TYPES |
| 247 | #ifndef INCLUDED_GAME_PROTOS |
| 248 | #define INCLUDED_GAME_PROTOS |
| 249 | |
| 250 | #define MAX_GAME_EMPTY_TIME 300 |
| 251 | #define STARTVER_UNKNOWN 0 |
| 252 | #define STARTVER_GW1 1 |
| 253 | #define STARTVER_GW3 3 |
| 254 | #define STARTVER_GW4 4 |
| 255 | #define STARTVER_REALM1 104 |
| 256 | |
| 257 | #define JUST_NEED_TYPES |
| 258 | #include "account.h" |
| 259 | #include "connection.h" |
| 260 | #include "channel.h" |
| 261 | #include "common/list.h" |
| 262 | #include "common/tag.h" |
| 263 | #include "common/packet.h" |
| 264 | #undef JUST_NEED_TYPES |
| 265 | |
| 266 | namespace pvpgn |
| 267 | { |
| 268 | |
| 269 | namespace bnetd |
| 270 | { |
| 271 | // game list structure with custom data |
| 272 | struct glist_cbdata { |
| 273 | unsigned tcount, counter; |
| 274 | t_connection *c; |
| 275 | t_game_type gtype; |
| 276 | t_packet *rpacket; |
| 277 | }; |
| 278 | |
| 279 | extern char const * game_type_get_str(t_game_type type); |
| 280 | extern char const * game_status_get_str(t_game_status status); |
| 281 | extern char const * game_result_get_str(t_game_result result); |
| 282 | extern char const * game_option_get_str(t_game_option option); |
| 283 | extern char const * game_maptype_get_str(t_game_maptype maptype); |
| 284 | extern char const * game_tileset_get_str(t_game_tileset tileset); |
| 285 | extern char const * game_speed_get_str(t_game_speed speed); |
| 286 | extern char const * game_difficulty_get_str(unsigned difficulty); |
| 287 | extern t_game * game_create(char const * name, char const * pass, char const * info, t_game_type type, int startver, t_clienttag clienttag, unsigned long gameversion); |
| 288 | extern unsigned int game_get_id(t_game const * game); |
| 289 | extern char const * game_get_name(t_game const * game); |
| 290 | extern t_game_type game_get_type(t_game const * game); |
| 291 | extern t_game_maptype game_get_maptype(t_game const * game); |
| 292 | extern int game_set_maptype(t_game * game, t_game_maptype maptype); |
| 293 | extern t_game_tileset game_get_tileset(t_game const * game); |
| 294 | extern int game_set_tileset(t_game * game, t_game_tileset tileset); |
| 295 | extern t_game_speed game_get_speed(t_game const * game); |
| 296 | extern int game_set_speed(t_game * game, t_game_speed speed); |
| 297 | extern unsigned int game_get_mapsize_x(t_game const * game); |
| 298 | extern int game_set_mapsize_x(t_game * game, unsigned int x); |
| 299 | extern unsigned int game_get_mapsize_y(t_game const * game); |
| 300 | extern int game_set_mapsize_y(t_game * game, unsigned int y); |
| 301 | extern unsigned int game_get_maxplayers(t_game const * game); |
| 302 | extern int game_set_maxplayers(t_game * game, unsigned int maxplayers); |
| 303 | extern unsigned int game_get_difficulty(t_game const * game); |
| 304 | extern int game_set_difficulty(t_game * game, unsigned int difficulty); |
| 305 | extern char const * game_get_description(t_game const * game); |
| 306 | extern int game_set_description(t_game * game, char const * description); |
| 307 | extern char const * game_get_pass(t_game const * game); |
| 308 | extern char const * game_get_info(t_game const * game); |
| 309 | extern unsigned long game_get_version(t_game const * game); |
| 310 | extern int game_get_startver(t_game const * game); |
| 311 | extern unsigned int game_get_ref(t_game const * game); |
| 312 | extern unsigned int game_get_count(t_game const * game); |
| 313 | extern void game_set_status(t_game * game, t_game_status status); |
| 314 | extern t_game_status game_get_status(t_game const * game); |
| 315 | extern unsigned int game_get_addr(t_game const * game); |
| 316 | extern unsigned short game_get_port(t_game const * game); |
| 317 | extern unsigned int game_get_latency(t_game const * game); |
| 318 | extern t_connection * game_get_player_conn(t_game const * game, unsigned int i); |
| 319 | extern t_clienttag game_get_clienttag(t_game const * game); |
| 320 | extern int game_add_player(t_game * game, char const * pass, int startver, t_connection * c); |
| 321 | extern int game_del_player(t_game * game, t_connection * c); |
| 322 | extern t_account * game_get_player(t_game * game, unsigned int i); |
| 323 | extern int game_set_report(t_game * game, t_account * account, char const * head, char const * body); |
| 324 | extern int game_set_reported_results(t_game * game, t_account * account, t_game_result * results); |
| 325 | extern int game_set_self_report(t_game * game, t_account * account, t_game_result result); |
| 326 | extern t_game_result * game_get_reported_results(t_game * game, t_account * account); |
| 327 | extern char const * game_get_mapname(t_game const * game); |
| 328 | extern int game_set_mapname(t_game * game, char const * mapname); |
| 329 | extern t_connection * game_get_owner(t_game const * game); |
| 330 | extern std::time_t game_get_create_time(t_game const * game); |
| 331 | extern std::time_t game_get_start_time(t_game const * game); |
| 332 | extern int game_set_option(t_game * game, t_game_option option); |
| 333 | extern t_game_option game_get_option(t_game const * game); |
| 334 | extern int gamelist_create(void); |
| 335 | extern int gamelist_destroy(void); |
| 336 | extern t_elist * gamelist(void); |
| 337 | extern int gamelist_get_length(void); |
| 338 | extern t_game * gamelist_find_game(char const * name, t_clienttag ctag, t_game_type type); |
| 339 | extern t_game * gamelist_find_game_available(char const * name, t_clienttag ctag, t_game_type type); |
| 340 | extern t_game * gamelist_find_game_byid(unsigned int id); |
| 341 | extern void gamelist_traverse(t_glist_func cb, void *data, t_gamelist_source_type); |
| 342 | extern int gamelist_total_games(void); |
| 343 | extern int game_set_realm(t_game * game, unsigned int realm); |
| 344 | extern unsigned int game_get_realm(t_game const * game); |
| 345 | extern char const * game_get_realmname(t_game const * game); |
| 346 | extern int game_set_realmname(t_game * game, char const * realmname); |
| 347 | extern void gamelist_check_voidgame(void); |
| 348 | extern void game_set_flag(t_game * game, t_game_flag flag); |
| 349 | extern t_game_flag game_get_flag(t_game const * game); |
| 350 | extern int game_get_count_by_clienttag(t_clienttag ct); |
| 351 | extern int game_is_ladder(t_game *game); |
| 352 | extern int game_discisloss(t_game *game); |
| 353 | extern int game_set_channel(t_game * game, t_channel * channel); |
| 354 | extern t_channel * game_get_channel(t_game * game); |
| 355 | } |
| 356 | |
| 357 | } |
| 358 | |
| 359 | #endif |
| 360 | #endif |