| 1 | /* |
| 2 | * Copyright (C) 2000,2001 Onlyer ([email protected]) |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; either version 2 |
| 7 | * of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 17 | */ |
| 18 | #ifndef INCLUDED_D2GS_H |
| 19 | #define INCLUDED_D2GS_H |
| 20 | |
| 21 | #include "common/list.h" |
| 22 | #include "connection.h" |
| 23 | |
| 24 | namespace pvpgn |
| 25 | { |
| 26 | |
| 27 | namespace d2cs |
| 28 | { |
| 29 | |
| 30 | typedef enum |
| 31 | { |
| 32 | d2gs_state_none, |
| 33 | d2gs_state_connected, |
| 34 | d2gs_state_authed |
| 35 | } t_d2gs_state; |
| 36 | |
| 37 | typedef struct d2gs |
| 38 | { |
| 39 | unsigned int ip; |
| 40 | unsigned int id; |
| 41 | unsigned int flag; |
| 42 | unsigned int active; |
| 43 | unsigned int token; |
| 44 | t_d2gs_state state; |
| 45 | unsigned int maxgame; |
| 46 | unsigned int gamenum; |
| 47 | t_connection * connection; |
| 48 | } t_d2gs; |
| 49 | |
| 50 | #define D2GS_FLAG_VALID 0x01 |
| 51 | |
| 52 | extern t_list * d2gslist(void); |
| 53 | extern int d2gslist_create(void); |
| 54 | extern int d2gslist_destroy(void); |
| 55 | extern int d2gslist_reload(char const * gslist); |
| 56 | extern t_d2gs * d2gs_create(char const * ip); |
| 57 | extern int d2gs_destroy(t_d2gs * gs,t_elem ** curr); |
| 58 | extern t_d2gs * d2gslist_get_server_by_id(unsigned int id); |
| 59 | extern t_d2gs * d2gslist_choose_server(void); |
| 60 | extern t_d2gs * d2gslist_find_gs(unsigned int id); |
| 61 | extern t_d2gs * d2gslist_find_gs_by_ip(unsigned int ip); |
| 62 | extern unsigned int d2gs_get_id(t_d2gs const * gs); |
| 63 | extern unsigned int d2gs_get_ip(t_d2gs const * gs); |
| 64 | extern t_d2gs_state d2gs_get_state(t_d2gs const * gs); |
| 65 | extern int d2gs_set_state(t_d2gs * gs, t_d2gs_state state); |
| 66 | extern unsigned int d2gs_get_maxgame(t_d2gs const * gs); |
| 67 | extern int d2gs_set_maxgame(t_d2gs * gs,unsigned int maxgame); |
| 68 | extern unsigned int d2gs_get_gamenum(t_d2gs const * gs); |
| 69 | extern int d2gs_add_gamenum(t_d2gs * gs,int number); |
| 70 | extern unsigned int d2gs_get_token(t_d2gs const * gs); |
| 71 | extern unsigned int d2gs_make_token(t_d2gs * gs); |
| 72 | extern t_connection * d2gs_get_connection(t_d2gs const * gs); |
| 73 | extern int d2gs_active(t_d2gs * gs, t_connection * c); |
| 74 | extern int d2gs_deactive(t_d2gs * gs, t_connection * c); |
| 75 | extern unsigned int d2gs_calc_checksum(t_connection * c); |
| 76 | extern int d2gs_keepalive(void); |
| 77 | extern int d2gs_restart_all_gs(void); |
| 78 | |
| 79 | } |
| 80 | |
| 81 | } |
| 82 | |
| 83 | #define D2GS_MAJOR_VERSION_MASK 0xffffff00 |
| 84 | |
| 85 | #endif |