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