| 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_D2CS_PROTOCOL_H |
| 19 | #define INCLUDED_D2CS_PROTOCOL_H |
| 20 | |
| 21 | #include "common/bn_type.h" |
| 22 | |
| 23 | namespace pvpgn |
| 24 | { |
| 25 | |
| 26 | typedef struct |
| 27 | { |
| 28 | bn_short size; |
| 29 | bn_byte type; |
| 30 | } t_d2cs_client_header; |
| 31 | |
| 32 | typedef struct |
| 33 | { |
| 34 | t_d2cs_client_header h; |
| 35 | } t_d2cs_client_generic; |
| 36 | |
| 37 | #define CLIENT_D2CS_LOGINREQ 0x01 |
| 38 | typedef struct |
| 39 | { |
| 40 | t_d2cs_client_header h; |
| 41 | bn_int seqno; |
| 42 | bn_int u1; |
| 43 | bn_int bncs_addr1; |
| 44 | bn_int sessionnum; |
| 45 | bn_int sessionkey; /* always zero,self define */ |
| 46 | bn_int cdkey_id; |
| 47 | bn_int u5; |
| 48 | bn_int clienttag; |
| 49 | bn_int bnversion; |
| 50 | bn_int bncs_addr2; |
| 51 | bn_int u6; /* zero */ |
| 52 | bn_int secret_hash[5]; |
| 53 | /* account name */ |
| 54 | } t_client_d2cs_loginreq; |
| 55 | |
| 56 | #define D2CS_CLIENT_LOGINREPLY 0x01 |
| 57 | typedef struct |
| 58 | { |
| 59 | t_d2cs_client_header h; |
| 60 | bn_int reply; |
| 61 | } t_d2cs_client_loginreply; |
| 62 | #define D2CS_CLIENT_LOGINREPLY_SUCCEED 0x00 |
| 63 | #define D2CS_CLIENT_LOGINREPLY_BADPASS 0x0c |
| 64 | |
| 65 | #define CLIENT_D2CS_CREATECHARREQ 0x02 |
| 66 | typedef struct |
| 67 | { |
| 68 | t_d2cs_client_header h; |
| 69 | bn_short chclass; /* character class */ |
| 70 | bn_short u1; /* always zero */ |
| 71 | bn_short status; /* same as in .d2s file */ |
| 72 | /* character name */ |
| 73 | } t_client_d2cs_createcharreq; |
| 74 | |
| 75 | #define D2CS_CLIENT_CREATECHARREPLY 0x02 |
| 76 | typedef struct |
| 77 | { |
| 78 | t_d2cs_client_header h; |
| 79 | bn_int reply; |
| 80 | } t_d2cs_client_createcharreply; |
| 81 | #define D2CS_CLIENT_CREATECHARREPLY_SUCCEED 0x00 |
| 82 | #define D2CS_CLIENT_CREATECHARREPLY_FAILED 0x01 |
| 83 | #define D2CS_CLIENT_CREATECHARREPLY_ALREADY_EXIST 0x14 |
| 84 | #define D2CS_CLIENT_CREATECHARREPLY_NAME_REJECT 0x15 |
| 85 | |
| 86 | |
| 87 | #define CLIENT_D2CS_CREATEGAMEREQ 0x03 |
| 88 | typedef struct |
| 89 | { |
| 90 | t_d2cs_client_header h; |
| 91 | bn_short seqno; |
| 92 | bn_int gameflag; /* just difficulty is set here */ |
| 93 | bn_byte u1; /* always 1 */ |
| 94 | bn_byte leveldiff; /* Only allow people of +/- n level to join */ |
| 95 | bn_byte maxchar; /* Maximum number of chars allowed in game */ |
| 96 | /* game name */ |
| 97 | /* game pass */ |
| 98 | /* game desc */ |
| 99 | } t_client_d2cs_creategamereq; |
| 100 | |
| 101 | #define D2CS_CLIENT_CREATEGAMEREPLY 0x03 |
| 102 | typedef struct |
| 103 | { |
| 104 | t_d2cs_client_header h; |
| 105 | bn_short seqno; |
| 106 | bn_short gameid; |
| 107 | bn_short u1; /* always zero */ |
| 108 | bn_int reply; |
| 109 | } t_d2cs_client_creategamereply; |
| 110 | #define D2CS_CLIENT_CREATEGAMEREPLY_SUCCEED 0x00 |
| 111 | #define D2CS_CLIENT_CREATEGAMEREPLY_FAILED 0x01 |
| 112 | #define D2CS_CLIENT_CREATEGAMEREPLY_INVALID_NAME 0x1e |
| 113 | #define D2CS_CLIENT_CREATEGAMEREPLY_NAME_EXIST 0x1f |
| 114 | #define D2CS_CLIENT_CREATEGAMEREPLY_SERVER_DOWN 0x20 |
| 115 | #define D2CS_CLIENT_CREATEGAMEREPLY_NOT_AVAILABLE 0x32 |
| 116 | #define D2CS_CLIENT_CREATEGAMEREPLY_U1 0x33 |
| 117 | |
| 118 | #define CLIENT_D2CS_JOINGAMEREQ 0x04 |
| 119 | typedef struct |
| 120 | { |
| 121 | t_d2cs_client_header h; |
| 122 | bn_short seqno; |
| 123 | /* game name */ |
| 124 | /* game pass */ |
| 125 | } t_client_d2cs_joingamereq; |
| 126 | |
| 127 | #define D2CS_CLIENT_JOINGAMEREPLY 0x04 |
| 128 | typedef struct |
| 129 | { |
| 130 | t_d2cs_client_header h; |
| 131 | bn_short seqno; |
| 132 | bn_short gameid; |
| 133 | bn_short u1; /* always zero */ |
| 134 | bn_int addr; |
| 135 | bn_int token; |
| 136 | bn_int reply; |
| 137 | } t_d2cs_client_joingamereply; |
| 138 | #define D2CS_CLIENT_JOINGAMEREPLY_SUCCEED 0x00 |
| 139 | #define D2CS_CLIENT_JOINGAMEREPLY_BAD_PASS 0x29 |
| 140 | #define D2CS_CLIENT_JOINGAMEREPLY_NOT_EXIST 0x2a |
| 141 | #define D2CS_CLIENT_JOINGAMEREPLY_GAME_FULL 0x2b |
| 142 | #define D2CS_CLIENT_JOINGAMEREPLY_LEVEL_LIMIT 0x2c |
| 143 | #define D2CS_CLIENT_JOINGAMEREPLY_HARDCORE_SOFTCORE 0x71 |
| 144 | #define D2CS_CLIENT_JOINGAMEREPLY_NORMAL_NIGHTMARE 0x73 |
| 145 | #define D2CS_CLIENT_JOINGAMEREPLY_NIGHTMARE_HELL 0x74 |
| 146 | #define D2CS_CLIENT_JOINGAMEREPLY_CLASSIC_EXPANSION 0x78 |
| 147 | #define D2CS_CLIENT_JOINGAMEREPLY_EXPANSION_CLASSIC 0x79 |
| 148 | #define D2CS_CLIENT_JOINGAMEREPLY_NORMAL_LADDER 0x7D |
| 149 | #define D2CS_CLIENT_JOINGAMEREPLY_FAILED 0x01 |
| 150 | |
| 151 | #define CLIENT_D2CS_GAMELISTREQ 0x05 |
| 152 | typedef struct |
| 153 | { |
| 154 | t_d2cs_client_header h; |
| 155 | bn_short seqno; |
| 156 | bn_int gameflag; /* only hardcore is set here */ |
| 157 | /* bn_byte u1; string game name to search? */ |
| 158 | } t_client_d2cs_gamelistreq; |
| 159 | |
| 160 | #define D2CS_CLIENT_GAMELISTREPLY 0x05 |
| 161 | typedef struct |
| 162 | { |
| 163 | t_d2cs_client_header h; |
| 164 | bn_short seqno; |
| 165 | bn_int token; |
| 166 | bn_byte currchar; /* current number of characters in game */ |
| 167 | bn_int gameflag; /* 0x04 is always set here */ |
| 168 | /* game name */ |
| 169 | /* game desc */ |
| 170 | } t_d2cs_client_gamelistreply; |
| 171 | |
| 172 | #define CLIENT_D2CS_GAMEINFOREQ 0x06 |
| 173 | typedef struct |
| 174 | { |
| 175 | t_d2cs_client_header h; |
| 176 | bn_short seqno; |
| 177 | /* game name */ |
| 178 | } t_client_d2cs_gameinforeq; |
| 179 | |
| 180 | #define D2CS_CLIENT_GAMEINFOREPLY 0x06 |
| 181 | typedef struct |
| 182 | { |
| 183 | t_d2cs_client_header h; |
| 184 | bn_short seqno; |
| 185 | bn_int gameflag; |
| 186 | bn_int etime; |
| 187 | bn_byte charlevel; |
| 188 | bn_byte leveldiff; |
| 189 | bn_byte maxchar; |
| 190 | bn_byte currchar; |
| 191 | bn_byte chclass[16]; /* 16 character class */ |
| 192 | bn_byte level[16]; /* 16 character level */ |
| 193 | /* game description */ |
| 194 | /* currchar number of character names */ |
| 195 | } t_d2cs_client_gameinforeply; |
| 196 | |
| 197 | #define CLIENT_D2CS_CHARLOGINREQ 0x07 |
| 198 | typedef struct |
| 199 | { |
| 200 | t_d2cs_client_header h; |
| 201 | /* character name */ |
| 202 | } t_client_d2cs_charloginreq; |
| 203 | |
| 204 | #define D2CS_CLIENT_CHARLOGINREPLY 0x07 |
| 205 | typedef struct |
| 206 | { |
| 207 | t_d2cs_client_header h; |
| 208 | bn_int reply; |
| 209 | } t_d2cs_client_charloginreply; |
| 210 | #define D2CS_CLIENT_CHARLOGINREPLY_SUCCEED 0x00 |
| 211 | #define D2CS_CLIENT_CHARLOGINREPLY_FAILED 0x01 |
| 212 | #define D2CS_CLIENT_CHARLOGINREPLY_NOT_FOUND 0x46 |
| 213 | #define D2CS_CLIENT_CHARLOGINREPLY_EXPIRED 0x7b |
| 214 | |
| 215 | #define CLIENT_D2CS_DELETECHARREQ 0x0a |
| 216 | typedef struct |
| 217 | { |
| 218 | t_d2cs_client_header h; |
| 219 | bn_short u1; /* always zero */ |
| 220 | /* character name */ |
| 221 | } t_client_d2cs_deletecharreq; |
| 222 | |
| 223 | #define D2CS_CLIENT_DELETECHARREPLY 0x0a |
| 224 | typedef struct |
| 225 | { |
| 226 | t_d2cs_client_header h; |
| 227 | bn_short u1; /* always zero */ |
| 228 | bn_int reply; |
| 229 | } t_d2cs_client_deletecharreply; |
| 230 | #define D2CS_CLIENT_DELETECHARREPLY_SUCCEED 0x00 |
| 231 | #define D2CS_CLIENT_DELETECHARREPLY_FAILED 0x01 |
| 232 | |
| 233 | |
| 234 | #define CLIENT_D2CS_LADDERREQ 0x11 |
| 235 | typedef struct |
| 236 | { |
| 237 | t_d2cs_client_header h; |
| 238 | bn_byte type; /* jadder type request */ |
| 239 | bn_short start_pos; /* list ladder from what position */ |
| 240 | } t_client_d2cs_ladderreq; |
| 241 | |
| 242 | #define D2CS_CLIENT_LADDERREPLY 0x11 |
| 243 | typedef struct |
| 244 | { |
| 245 | t_d2cs_client_header h; |
| 246 | bn_byte type; /* ladder type request */ |
| 247 | bn_short total_len; /* total length of the ladder data */ |
| 248 | |
| 249 | bn_short curr_len; /* length of ladder data in this packet */ |
| 250 | bn_short cont_len; /* length of ladder data in previous packets */ |
| 251 | /* length here include the header but |
| 252 | exclude this packet */ |
| 253 | } t_d2cs_client_ladderreply; |
| 254 | |
| 255 | typedef struct |
| 256 | { |
| 257 | bn_short start_pos; /* start position of ladder */ |
| 258 | bn_short u1; /* always zero */ |
| 259 | bn_int count1; /* always 0x10 */ |
| 260 | } t_d2cs_client_ladderheader; |
| 261 | |
| 262 | typedef struct |
| 263 | { |
| 264 | bn_int count2; /* 0x10 for first packet or 0x0 for continue */ |
| 265 | } t_d2cs_client_ladderinfoheader; |
| 266 | |
| 267 | typedef struct |
| 268 | { |
| 269 | bn_int explow; |
| 270 | bn_int exphigh; /* always zero */ |
| 271 | bn_short status; |
| 272 | bn_byte level; |
| 273 | bn_byte u1; /* always zero */ |
| 274 | char charname[16]; |
| 275 | } t_d2cs_client_ladderinfo; |
| 276 | #define LADDERSTATUS_FLAG_DEAD 0x10 |
| 277 | #define LADDERSTATUS_FLAG_HARDCORE 0x20 |
| 278 | #define LADDERSTATUS_FLAG_EXPANSION 0x40 |
| 279 | #define LADDERSTATUS_FLAG_DIFFICULTY 0x0f00 |
| 280 | |
| 281 | #define CLIENT_D2CS_MOTDREQ 0x12 |
| 282 | typedef struct |
| 283 | { |
| 284 | t_d2cs_client_header h; |
| 285 | } t_client_d2cs_motdreq; |
| 286 | |
| 287 | #define D2CS_CLIENT_MOTDREPLY 0x12 |
| 288 | typedef struct |
| 289 | { |
| 290 | t_d2cs_client_header h; |
| 291 | bn_byte u1; |
| 292 | /* message */ |
| 293 | } t_d2cs_client_motdreply; |
| 294 | |
| 295 | #define CLIENT_D2CS_CANCELCREATEGAME 0x13 |
| 296 | typedef struct |
| 297 | { |
| 298 | t_d2cs_client_header h; |
| 299 | } t_client_d2cs_cancelcreategame; |
| 300 | |
| 301 | #define D2CS_CLIENT_CREATEGAMEWAIT 0x14 |
| 302 | typedef struct |
| 303 | { |
| 304 | t_d2cs_client_header h; |
| 305 | bn_int position; |
| 306 | } t_d2cs_client_creategamewait; |
| 307 | |
| 308 | #define D2CS_CLIENT_CHARLADDERREQ 0x16 |
| 309 | typedef struct |
| 310 | { |
| 311 | t_d2cs_client_header h; |
| 312 | bn_int hardcore; |
| 313 | bn_int expansion; |
| 314 | /* character name */ |
| 315 | } t_client_d2cs_charladderreq; |
| 316 | /* use 0x11 LADDER reply for this request */ |
| 317 | |
| 318 | #define CLIENT_D2CS_CHARLISTREQ 0x17 |
| 319 | typedef struct |
| 320 | { |
| 321 | t_d2cs_client_header h; |
| 322 | bn_short maxchar; |
| 323 | bn_short u1; |
| 324 | } t_client_d2cs_charlistreq; |
| 325 | |
| 326 | #define D2CS_CLIENT_CHARLISTREPLY 0x17 |
| 327 | typedef struct |
| 328 | { |
| 329 | t_d2cs_client_header h; |
| 330 | bn_short maxchar; |
| 331 | bn_short currchar; |
| 332 | bn_short u1; /* always zero */ |
| 333 | bn_short currchar2; |
| 334 | /* character name */ |
| 335 | /* character portrait blocks */ |
| 336 | /* each block is 0x22 bytes static length */ |
| 337 | } t_d2cs_client_charlistreply; |
| 338 | |
| 339 | #define CLIENT_D2CS_CONVERTCHARREQ 0x18 |
| 340 | typedef struct |
| 341 | { |
| 342 | t_d2cs_client_header h; |
| 343 | /* character name */ |
| 344 | } t_client_d2cs_convertcharreq; |
| 345 | |
| 346 | #define D2CS_CLIENT_CONVERTCHARREPLY 0x18 |
| 347 | typedef struct |
| 348 | { |
| 349 | t_d2cs_client_header h; |
| 350 | bn_int reply; |
| 351 | } t_d2cs_client_convertcharreply; |
| 352 | #define D2CS_CLIENT_CONVERTCHARREPLY_SUCCEED 0x00 |
| 353 | #define D2CS_CLIENT_CONVERTCHARREPLY_FAILED 0x01 |
| 354 | |
| 355 | #define CLIENT_D2CS_CHARLISTREQ_110 0x19 |
| 356 | typedef struct |
| 357 | { |
| 358 | t_d2cs_client_header h; |
| 359 | bn_short maxchar; |
| 360 | bn_short u1; |
| 361 | } t_client_d2cs_charlistreq_110; |
| 362 | |
| 363 | |
| 364 | #define D2CS_CLIENT_CHARLISTREPLY_110 0x19 |
| 365 | typedef struct |
| 366 | { |
| 367 | t_d2cs_client_header h; |
| 368 | bn_short maxchar; |
| 369 | bn_short currchar; |
| 370 | bn_short u1; /* always zero */ |
| 371 | bn_short currchar2; |
| 372 | } t_d2cs_client_charlistreply_110; |
| 373 | |
| 374 | typedef struct |
| 375 | { |
| 376 | bn_int expire_time; /* character expire time (in seconds) */ |
| 377 | /* character name */ |
| 378 | /* character portrait blocks */ |
| 379 | /* each block is 0x22 bytes static length */ |
| 380 | } t_d2cs_client_chardata; |
| 381 | |
| 382 | } |
| 383 | |
| 384 | #endif |