| 1 | /* |
| 2 | * This program is free software; you can redistribute it and/or |
| 3 | * modify it under the terms of the GNU General Public License |
| 4 | * as published by the Free Software Foundation; either version 2 |
| 5 | * of the License, or (at your option) any later version. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | * |
| 12 | * You should have received a copy of the GNU General Public License |
| 13 | * along with this program; if not, write to the Free Software |
| 14 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 15 | */ |
| 16 | #ifndef INCLUDED_ANONGAME_TYPES |
| 17 | #define INCLUDED_ANONGAME_TYPES |
| 18 | |
| 19 | #include <cstdint> |
| 20 | |
| 21 | #ifdef JUST_NEED_TYPES |
| 22 | # include "account.h" |
| 23 | # include "connection.h" |
| 24 | #else |
| 25 | # define JUST_NEED_TYPES |
| 26 | # include "account.h" |
| 27 | # include "connection.h" |
| 28 | # undef JUST_NEED_TYPES |
| 29 | #endif |
| 30 | # include "anongame_gameresult.h" |
| 31 | |
| 32 | namespace pvpgn |
| 33 | { |
| 34 | |
| 35 | namespace bnetd |
| 36 | { |
| 37 | |
| 38 | typedef struct |
| 39 | { |
| 40 | int currentplayers; |
| 41 | int totalplayers; |
| 42 | struct connection * player[ANONGAME_MAX_GAMECOUNT]; |
| 43 | t_account * account[ANONGAME_MAX_GAMECOUNT]; |
| 44 | int result[ANONGAME_MAX_GAMECOUNT]; |
| 45 | t_anongame_gameresult * results[ANONGAME_MAX_GAMECOUNT]; |
| 46 | } t_anongameinfo; |
| 47 | |
| 48 | typedef struct |
| 49 | { |
| 50 | t_anongameinfo * info; |
| 51 | int count; |
| 52 | std::uint32_t id; |
| 53 | std::uint32_t tid; |
| 54 | struct connection * tc[ANONGAME_MAX_GAMECOUNT / 2]; |
| 55 | std::uint32_t race; |
| 56 | std::uint32_t handle; |
| 57 | unsigned int addr; |
| 58 | char loaded; |
| 59 | char joined; |
| 60 | std::uint8_t playernum; |
| 61 | std::uint32_t map_prefs; |
| 62 | std::uint8_t type; |
| 63 | std::uint8_t gametype; |
| 64 | int queue; |
| 65 | } t_anongame; |
| 66 | |
| 67 | typedef struct |
| 68 | { |
| 69 | struct connection * c; |
| 70 | std::uint32_t map_prefs; |
| 71 | char const * versiontag; |
| 72 | } t_matchdata; |
| 73 | |
| 74 | } |
| 75 | |
| 76 | } |
| 77 | |
| 78 | #endif |
| 79 | |
| 80 | /*****/ |
| 81 | #ifndef JUST_NEED_TYPES |
| 82 | #ifndef INCLUDED_ANONGAME_PROTOS |
| 83 | #define INCLUDED_ANONGAME_PROTOS |
| 84 | |
| 85 | #define JUST_NEED_TYPES |
| 86 | #include "common/packet.h" |
| 87 | #include "connection.h" |
| 88 | #undef JUST_NEED_TYPES |
| 89 | |
| 90 | namespace pvpgn |
| 91 | { |
| 92 | |
| 93 | namespace bnetd |
| 94 | { |
| 95 | |
| 96 | extern int anongame_matchlists_create(void); |
| 97 | extern int anongame_matchlists_destroy(void); |
| 98 | |
| 99 | extern int handle_anongame_search(t_connection * c, t_packet const * packet); |
| 100 | extern int anongame_unqueue(t_connection * c, int queue); |
| 101 | |
| 102 | extern char anongame_arranged(int queue); |
| 103 | extern int anongame_stats(t_connection * c); |
| 104 | |
| 105 | extern t_anongameinfo * anongameinfo_create(int totalplayers); |
| 106 | extern void anongameinfo_destroy(t_anongameinfo * i); |
| 107 | |
| 108 | extern t_anongameinfo * anongame_get_info(t_anongame * a); |
| 109 | extern int anongame_get_currentplayers(t_anongame *a); |
| 110 | extern int anongame_get_totalplayers(t_anongame *a); |
| 111 | extern t_connection * anongame_get_player(t_anongame * a, int plnum); |
| 112 | extern int anongame_get_count(t_anongame *a); |
| 113 | extern std::uint32_t anongame_get_id(t_anongame * a); |
| 114 | extern t_connection * anongame_get_tc(t_anongame *a, int tpnumber); |
| 115 | extern std::uint32_t anongame_get_race(t_anongame * a); |
| 116 | extern std::uint32_t anongame_get_handle(t_anongame * a); |
| 117 | extern unsigned int anongame_get_addr(t_anongame * a); |
| 118 | extern char anongame_get_loaded(t_anongame * a); |
| 119 | extern char anongame_get_joined(t_anongame * a); |
| 120 | extern std::uint8_t anongame_get_playernum(t_anongame * a); |
| 121 | extern std::uint8_t anongame_get_queue(t_anongame *a); |
| 122 | |
| 123 | extern void anongame_set_result(t_anongame * a, int result); |
| 124 | extern void anongame_set_gameresults(t_anongame * a, t_anongame_gameresult * results); |
| 125 | extern void anongame_set_handle(t_anongame *a, std::uint32_t h); |
| 126 | extern void anongame_set_addr(t_anongame *a, unsigned int addr); |
| 127 | extern void anongame_set_loaded(t_anongame * a, char loaded); |
| 128 | extern void anongame_set_joined(t_anongame * a, char joined); |
| 129 | |
| 130 | extern int handle_w3route_packet(t_connection * c, t_packet const * const packet); |
| 131 | extern int handle_anongame_join(t_connection * c); |
| 132 | |
| 133 | /* Currently used by WOL RAL2 and YURI clients*/ |
| 134 | extern const char * anongame_get_map_from_prefs(int queue, t_clienttag clienttag); |
| 135 | } |
| 136 | |
| 137 | } |
| 138 | |
| 139 | #endif |
| 140 | #endif |