| 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 | |
| 17 | #ifndef INCLUDED_CLAN_TYPES |
| 18 | #define INCLUDED_CLAN_TYPES |
| 19 | |
| 20 | #include "common/tag.h" |
| 21 | #ifdef JUST_NEED_TYPES |
| 22 | # include "common/bn_type.h" |
| 23 | # include "connection.h" |
| 24 | # include "message.h" |
| 25 | # include "common/packet.h" |
| 26 | #else |
| 27 | # define JUST_NEED_TYPES |
| 28 | # include "common/bn_type.h" |
| 29 | # include "connection.h" |
| 30 | # include "message.h" |
| 31 | # include "common/packet.h" |
| 32 | # include "common/tag.h" |
| 33 | # undef JUST_NEED_TYPES |
| 34 | #endif |
| 35 | |
| 36 | #ifdef CLAN_INTERNAL_ACCESS |
| 37 | #ifdef JUST_NEED_TYPES |
| 38 | # include "common/list.h" |
| 39 | # include "account.h" |
| 40 | #else |
| 41 | # define JUST_NEED_TYPES |
| 42 | # include "common/list.h" |
| 43 | # include "account.h" |
| 44 | # undef JUST_NEED_TYPES |
| 45 | #endif |
| 46 | |
| 47 | #endif |
| 48 | |
| 49 | namespace pvpgn |
| 50 | { |
| 51 | |
| 52 | namespace bnetd |
| 53 | { |
| 54 | |
| 55 | typedef t_tag t_clantag; |
| 56 | |
| 57 | typedef struct clan |
| 58 | #ifdef CLAN_INTERNAL_ACCESS |
| 59 | { |
| 60 | unsigned int clanid; |
| 61 | t_clantag tag; |
| 62 | char const *clanname; |
| 63 | std::time_t creation_time; |
| 64 | char const *clan_motd; |
| 65 | t_list *members; |
| 66 | int created; |
| 67 | /* --by Soar |
| 68 | on create, set it to -count of invited members, |
| 69 | each accept packet will inc it by 1, |
| 70 | when it is increased to 0, means that all invited members have accepted, |
| 71 | then clan will be created and set this value to 1 |
| 72 | */ |
| 73 | char modified; |
| 74 | char channel_type; /* 0--public 1--private */ |
| 75 | } |
| 76 | #endif |
| 77 | t_clan; |
| 78 | |
| 79 | typedef struct _clanmember |
| 80 | #ifdef CLAN_INTERNAL_ACCESS |
| 81 | { |
| 82 | t_account * memberacc; |
| 83 | char status; |
| 84 | std::time_t join_time; |
| 85 | t_clan * clan; |
| 86 | int fullmember; /* PELISH: 0 -- clanmember is only invited, |
| 87 | 1 -- clanmember is fullmember */ |
| 88 | #ifdef WITH_SQL |
| 89 | char modified; |
| 90 | #endif |
| 91 | } |
| 92 | #endif |
| 93 | t_clanmember; |
| 94 | |
| 95 | } |
| 96 | |
| 97 | } |
| 98 | #define CLAN_CHIEFTAIN 0x04 |
| 99 | #define CLAN_SHAMAN 0x03 |
| 100 | #define CLAN_GRUNT 0x02 |
| 101 | #define CLAN_PEON 0x01 |
| 102 | #define CLAN_NEW 0x00 |
| 103 | |
| 104 | #endif |
| 105 | |
| 106 | #ifndef JUST_NEED_TYPES |
| 107 | #ifndef INCLUDED_CLAN_PROTOS |
| 108 | #define INCLUDED_CLAN_PROTOS |
| 109 | |
| 110 | #define JUST_NEED_TYPES |
| 111 | #include "common/list.h" |
| 112 | #undef JUST_NEED_TYPES |
| 113 | |
| 114 | |
| 115 | namespace pvpgn |
| 116 | { |
| 117 | |
| 118 | namespace bnetd |
| 119 | { |
| 120 | |
| 121 | extern t_list *clanlist(void); |
| 122 | extern int clanlist_load(void); |
| 123 | extern int clanlist_save(void); |
| 124 | extern int clanlist_unload(void); |
| 125 | extern int clanlist_remove_clan(t_clan * clan); |
| 126 | extern int clanlist_add_clan(t_clan * clan); |
| 127 | extern t_clan *clanlist_find_clan_by_clanid(unsigned cid); |
| 128 | extern t_clan *clanlist_find_clan_by_clantag(t_clantag clantag); |
| 129 | |
| 130 | |
| 131 | extern t_account *clanmember_get_account(t_clanmember * member); |
| 132 | extern int clanmember_set_account(t_clanmember * member, t_account * memberacc); |
| 133 | extern t_connection *clanmember_get_conn(t_clanmember * member); |
| 134 | extern char clanmember_get_status(t_clanmember * member); |
| 135 | extern int clanmember_set_status(t_clanmember * member, char status); |
| 136 | extern int clanmember_set_join_time(t_clanmember * member, std::time_t join_time); |
| 137 | extern std::time_t clanmember_get_join_time(t_clanmember * member); |
| 138 | extern t_clan * clanmember_get_clan(t_clanmember * member); |
| 139 | extern int clanmember_set_online(t_connection * c); |
| 140 | extern int clanmember_set_offline(t_connection * c); |
| 141 | extern int clanmember_get_fullmember(t_clanmember * member); |
| 142 | extern int clanmember_set_fullmember(t_clanmember * member, int fullmember); |
| 143 | |
| 144 | extern const char *clanmember_get_online_status(t_clanmember * member, char *status); |
| 145 | extern int clanmember_on_change_status(t_clanmember * member); |
| 146 | extern const char *clanmember_get_online_status_by_connection(t_connection * conn, char *status); |
| 147 | extern int clanmember_on_change_status_by_connection(t_connection * conn); |
| 148 | |
| 149 | extern t_clan *clan_create(t_account * chieftain_acc, t_clantag clantag, const char *clanname, const char *motd); |
| 150 | extern int clan_destroy(t_clan * clan); |
| 151 | |
| 152 | extern int clan_unload_members(t_clan * clan); |
| 153 | extern int clan_remove_all_members(t_clan * clan); |
| 154 | |
| 155 | extern int clan_save(t_clan * clan); |
| 156 | extern int clan_remove(t_clantag clantag); |
| 157 | |
| 158 | extern int clan_get_created(t_clan * clan); |
| 159 | extern int clan_set_created(t_clan * clan, int created); |
| 160 | extern char clan_get_modified(t_clan * clan); |
| 161 | extern int clan_set_modified(t_clan * clan, char modified); |
| 162 | extern char clan_get_channel_type(t_clan * clan); |
| 163 | extern int clan_set_channel_type(t_clan * clan, char channel_type); |
| 164 | extern t_list *clan_get_members(t_clan * clan); |
| 165 | extern char const *clan_get_name(t_clan * clan); |
| 166 | extern t_clantag clan_get_clantag(t_clan * clan); |
| 167 | extern char const *clan_get_motd(t_clan * clan); |
| 168 | extern int clan_set_motd(t_clan * clan, const char *motd); |
| 169 | extern unsigned int clan_get_clanid(t_clan * clan); |
| 170 | extern int clan_set_creation_time(t_clan * clan, std::time_t c_time); |
| 171 | extern std::time_t clan_get_creation_time(t_clan * clan); |
| 172 | extern unsigned clan_get_member_count(t_clan * clan); |
| 173 | |
| 174 | extern t_clanmember *clan_add_member(t_clan * clan, t_account * memberacc, char status); |
| 175 | extern int clan_remove_member(t_clan * clan, t_clanmember * member); |
| 176 | |
| 177 | extern t_clanmember *clan_find_member(t_clan * clan, t_account * memberacc); |
| 178 | extern t_clanmember *clan_find_member_by_name(t_clan * clan, char const *membername); |
| 179 | extern t_clanmember *clan_find_member_by_uid(t_clan * clan, unsigned int memberuid); |
| 180 | |
| 181 | extern int clan_send_message_to_online_members(t_clan * clan, t_message_type type, t_connection * me, char const * text); |
| 182 | extern int clan_send_packet_to_online_members(t_clan * clan, t_packet * packet); |
| 183 | extern int clan_get_possible_member(t_connection * c, t_packet const *const packet); |
| 184 | extern int clan_send_status_window(t_connection * c); |
| 185 | extern int clan_send_status_window_on_create(t_clan * clan); |
| 186 | extern int clan_close_status_window(t_connection * c); |
| 187 | extern int clan_close_status_window_on_disband(t_clan * clan); |
| 188 | extern int clan_send_memberlist(t_connection * c, t_packet const *const packet); |
| 189 | extern int clan_change_member_status(t_connection * c, t_packet const *const packet); |
| 190 | extern int clan_send_motd_reply(t_connection * c, t_packet const *const packet); |
| 191 | extern int clan_save_motd_chg(t_connection * c, t_packet const *const packet); |
| 192 | |
| 193 | extern t_clantag str_to_clantag(const char *str); |
| 194 | extern const char* clantag_to_str(t_clantag tag); |
| 195 | |
| 196 | } |
| 197 | |
| 198 | } |
| 199 | |
| 200 | #endif |
| 201 | #endif |