| 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_GAME_H |
| 19 | #define INCLUDED_GAME_H |
| 20 | |
| 21 | #include "d2gs.h" |
| 22 | #include "connection.h" |
| 23 | #include "bit.h" |
| 24 | |
| 25 | namespace pvpgn |
| 26 | { |
| 27 | |
| 28 | namespace d2cs |
| 29 | { |
| 30 | |
| 31 | typedef struct |
| 32 | { |
| 33 | unsigned char chclass; |
| 34 | unsigned char level; |
| 35 | char const * charname; |
| 36 | } t_game_charinfo; |
| 37 | |
| 38 | typedef struct |
| 39 | { |
| 40 | unsigned int id; |
| 41 | char const * name; |
| 42 | char const * pass; |
| 43 | char const * desc; |
| 44 | int create_time; |
| 45 | int lastaccess_time; |
| 46 | unsigned int created; |
| 47 | unsigned int gameflag; |
| 48 | unsigned int charlevel; |
| 49 | unsigned int leveldiff; |
| 50 | unsigned int d2gs_gameid; |
| 51 | unsigned int maxchar; |
| 52 | unsigned int currchar; |
| 53 | t_list * charlist; |
| 54 | t_d2gs * d2gs; |
| 55 | } t_game; |
| 56 | |
| 57 | #define D2_GAMEFLAG_BETA 0x00000001 |
| 58 | #define D2_GAMEFLAG_RELEASE 0x00000002 |
| 59 | #define D2_GAMEFLAG_TEMPLATE 0x00000008 |
| 60 | #define D2_GAMEFLAG_SINGLE 0x00000010 |
| 61 | #define D2_GAMEFLAG_HARDCORE 0x00000800 |
| 62 | #define D2_GAMEFLAG_EXPANSION 0x00100000 |
| 63 | #define D2_GAMEFLAG_LADDER 0x00200000 |
| 64 | |
| 65 | #define gameflag_get_difficulty(gameflag) ( (gameflag >> 0x0C) & 0x07 ) |
| 66 | #define gameflag_get_expansion(gameflag) BIT_TST_FLAG(gameflag, D2_GAMEFLAG_EXPANSION) |
| 67 | #define gameflag_get_ladder(gameflag) BIT_TST_FLAG(gameflag, D2_GAMEFLAG_LADDER) |
| 68 | #define gameflag_get_hardcore(gameflag) BIT_TST_FLAG(gameflag, D2_GAMEFLAG_HARDCORE) |
| 69 | #define gameflag_get_beta(gameflag) BIT_TST_FLAG(gameflag, D2_GAMEFLAG_BETA) /* true if the game is a beta version with limitations */ |
| 70 | #define gameflag_get_release(gameflag) BIT_TST_FLAG(gameflag, D2_GAMEFLAG_RELEASE) /* this bit must always not be zero */ |
| 71 | #define gameflag_get_single(gameflag) BIT_TST_FLAG(gameflag, D2_GAMEFLAG_SINGLE) /* true if the game is single mode without party */ |
| 72 | #define gameflag_get_template(gameflag) BIT_TST_FLAG(gameflag, D2_GAMEFLAG_TEMPLATE) /* true if use template settings */ |
| 73 | |
| 74 | #define gameflag_set_difficulty(gameflag,n) ( gameflag |= ((n & 0x07) << 0x0C) ) |
| 75 | #define gameflag_set_expansion(gameflag,n) BIT_SET_CLR_FLAG(gameflag, D2_GAMEFLAG_EXPANSION, n) |
| 76 | #define gameflag_set_ladder(gameflag,n) BIT_SET_CLR_FLAG(gameflag, D2_GAMEFLAG_LADDER, n) |
| 77 | #define gameflag_set_hardcore(gameflag,n) BIT_SET_CLR_FLAG(gameflag, D2_GAMEFLAG_HARDCORE, n) |
| 78 | |
| 79 | #define gameflag_create(l,e,h,d) (0x04|(e?D2_GAMEFLAG_EXPANSION:0) | (h?D2_GAMEFLAG_HARDCORE:0) | ((d & 0x07) << 0x0c) | (l?D2_GAMEFLAG_LADDER:0)) |
| 80 | |
| 81 | |
| 82 | extern t_list * d2cs_gamelist(void); |
| 83 | extern int d2cs_gamelist_destroy(void); |
| 84 | extern int d2cs_gamelist_create(void); |
| 85 | extern t_game * d2cs_gamelist_find_game(char const * gamename); |
| 86 | extern t_game * gamelist_find_game_by_id(unsigned int id); |
| 87 | extern t_game * gamelist_find_game_by_d2gs_and_id(unsigned int d2gs_id, unsigned int d2gs_gameid); |
| 88 | extern void d2cs_gamelist_check_voidgame(void); |
| 89 | extern t_game * d2cs_game_create(char const * gamename, char const * gamepass, char const * gamedesc, |
| 90 | unsigned int gameflag); |
| 91 | extern int game_destroy(t_game * game, t_elem ** elem); |
| 92 | extern int game_add_character(t_game * game, char const * charname, |
| 93 | unsigned char chclass, unsigned char level); |
| 94 | extern int game_del_character(t_game * game, char const * charname); |
| 95 | |
| 96 | extern t_d2gs * game_get_d2gs(t_game const * game); |
| 97 | extern int game_set_d2gs(t_game * game, t_d2gs * gs); |
| 98 | extern int game_set_d2gs_gameid(t_game * game, unsigned int gameid); |
| 99 | extern unsigned int game_get_d2gs_gameid(t_game const * game); |
| 100 | extern int game_set_id(t_game * game, unsigned int id); |
| 101 | extern unsigned int d2cs_game_get_id(t_game const * game); |
| 102 | extern int game_set_created(t_game * game, unsigned int created); |
| 103 | extern unsigned int game_get_created(t_game const * game); |
| 104 | extern int game_set_leveldiff(t_game * game, unsigned int leveldiff); |
| 105 | extern int game_set_charlevel(t_game * game, unsigned int charlevel); |
| 106 | extern unsigned int game_get_charlevel(t_game const * game); |
| 107 | extern unsigned int game_get_leveldiff(t_game const * game); |
| 108 | extern unsigned int game_get_maxlevel(t_game const * game); |
| 109 | extern unsigned int game_get_minlevel(t_game const * game); |
| 110 | extern int game_set_gameflag_ladder(t_game * game, unsigned int ladder); |
| 111 | extern int game_set_gameflag_expansion(t_game * game, unsigned int expansion); |
| 112 | extern int game_set_gameflag_hardcore(t_game * game, unsigned int hardcore); |
| 113 | extern int game_set_gameflag_difficulty(t_game * game, unsigned int difficulty); |
| 114 | extern unsigned int game_get_gameflag_ladder(t_game const * game); |
| 115 | extern unsigned int game_get_gameflag_expansion(t_game const * game); |
| 116 | extern unsigned int game_get_gameflag_hardcore(t_game const * game); |
| 117 | extern unsigned int game_get_gameflag_difficulty(t_game const * game); |
| 118 | extern int game_set_maxchar(t_game * game, unsigned int maxchar); |
| 119 | extern unsigned int game_get_maxchar(t_game const * game); |
| 120 | extern unsigned int game_get_currchar(t_game const * game); |
| 121 | extern char const * d2cs_game_get_name(t_game const * game); |
| 122 | extern char const * d2cs_game_get_pass(t_game const * game); |
| 123 | extern char const * game_get_desc(t_game const * game); |
| 124 | extern unsigned int game_get_gameflag(t_game const * game); |
| 125 | extern int d2cs_game_get_create_time(t_game const * game); |
| 126 | extern int game_set_create_time(t_game * game,int create_time); |
| 127 | extern t_list * game_get_charlist(t_game const * game); |
| 128 | extern t_game * gamelist_find_character(char const * charname); |
| 129 | extern unsigned int gamelist_get_totalgame(void); |
| 130 | extern t_elem const * gamelist_get_curr_elem(void); |
| 131 | extern void gamelist_set_curr_elem(t_elem const * elem); |
| 132 | |
| 133 | } |
| 134 | |
| 135 | } |
| 136 | |
| 137 | #endif |