Commit 432c910
committed
[DataBuffer] Scripting can now use .SendData and .GetDataAndAppend
The bot has been refactored such that the interfaces for sending and
receiving packets through the DataBuffer can now be used through
scripting in the same way the bot does.
API:
Buffer.SendData(Socket, [PacketID], [ServerType], [HeaderType])
- By default, this sends the buffer over the socket unchanged.
- If the HeaderType supports it, PacketID will be used in a pre-pended header.
HeaderType values:
0 = phtNONE: no header
3 = phtMCP: MCP/BNLS-like 3-byte header
4 = phtBNCS: BNCS-like 4-byte header
- If ServerType is non-zero, the packet will be logged to your packet log and cache.
Buffer.GetDataAndAppend(Socket, Length)
- Reads up to Length bytes off the socket as a Byte(). This is locale-independent.
- Appends them to the end of Buffer.
Packet.GetPacketLength(HeaderLenStart)
- Returns an Integer (16-bit value) from position 0, 1, or 2 from the
start of the packet. Returns 0 for any other HeaderLenStart.
Does not change the value of the Buffer.Position property.
For the use of several Battle.net-like binary protocols.
Buffer.IsFullPacket(HeaderLenStart)
- Returns True if this is a full packet,
False if not, if invalid HeaderLenStart, or if empty buffer.
Does not change the value of the Buffer.Position property.
For the use of several Battle.net-like binary protocols.
Buffer.TakePacket(HeaderLenStart)
- Returns a new DataBuffer with a completed packet.
The DataBuffer is empty if IsFullPacket() would have failed.
For the use of several Battle.net-like binary protocols.
Suggested usage:
' Example: Data buffering in a script made to connect to vL's BotNet service
' Headers are of the form:
' (UINT8) Protocol version (0x01)
' (UINT8) Packet ID
' (UINT16) Packet length
Sub BotNetSock_DataArrival(Length)
Dim Packet
RecvBuffer.GetDataAndAppend BotNetSock, Length
Do While RecvBuffer.IsFullPacket(2)
Set Packet = RecvBuffer.TakePacket(2)
Call Recv_PacketSwitch(Packet)
Set Packet = Nothing
Loop
End Sub1 parent 00c3657 commit 432c910
File tree
5 files changed
+92
-98
lines changed- trunk
5 files changed
+92
-98
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
380 | 380 | | |
381 | 381 | | |
382 | 382 | | |
383 | | - | |
| 383 | + | |
384 | 384 | | |
385 | 385 | | |
386 | 386 | | |
| |||
426 | 426 | | |
427 | 427 | | |
428 | 428 | | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
429 | 437 | | |
430 | 438 | | |
431 | 439 | | |
| |||
459 | 467 | | |
460 | 468 | | |
461 | 469 | | |
462 | | - | |
| 470 | + | |
463 | 471 | | |
464 | 472 | | |
465 | 473 | | |
466 | 474 | | |
467 | 475 | | |
468 | | - | |
| 476 | + | |
469 | 477 | | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
476 | 481 | | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
499 | | - | |
500 | | - | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
505 | 485 | | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
506 | 489 | | |
507 | 490 | | |
508 | 491 | | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
509 | 514 | | |
510 | 515 | | |
511 | 516 | | |
512 | | - | |
| 517 | + | |
513 | 518 | | |
514 | | - | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
520 | | - | |
521 | | - | |
522 | | - | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
523 | 529 | | |
524 | 530 | | |
525 | 531 | | |
526 | | - | |
| 532 | + | |
527 | 533 | | |
528 | 534 | | |
529 | 535 | | |
530 | 536 | | |
531 | | - | |
| 537 | + | |
532 | 538 | | |
533 | 539 | | |
534 | 540 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5966 | 5966 | | |
5967 | 5967 | | |
5968 | 5968 | | |
5969 | | - | |
5970 | | - | |
| 5969 | + | |
5971 | 5970 | | |
5972 | | - | |
| 5971 | + | |
5973 | 5972 | | |
5974 | | - | |
5975 | | - | |
5976 | | - | |
5977 | | - | |
5978 | | - | |
| 5973 | + | |
| 5974 | + | |
5979 | 5975 | | |
5980 | 5976 | | |
5981 | 5977 | | |
5982 | 5978 | | |
5983 | | - | |
| 5979 | + | |
5984 | 5980 | | |
5985 | | - | |
| 5981 | + | |
5986 | 5982 | | |
5987 | 5983 | | |
5988 | 5984 | | |
| |||
5991 | 5987 | | |
5992 | 5988 | | |
5993 | 5989 | | |
5994 | | - | |
| 5990 | + | |
5995 | 5991 | | |
5996 | 5992 | | |
5997 | 5993 | | |
| |||
6431 | 6427 | | |
6432 | 6428 | | |
6433 | 6429 | | |
6434 | | - | |
| 6430 | + | |
6435 | 6431 | | |
6436 | 6432 | | |
6437 | 6433 | | |
| |||
7239 | 7235 | | |
7240 | 7236 | | |
7241 | 7237 | | |
7242 | | - | |
| 7238 | + | |
7243 | 7239 | | |
7244 | 7240 | | |
7245 | 7241 | | |
| |||
7429 | 7425 | | |
7430 | 7426 | | |
7431 | 7427 | | |
7432 | | - | |
7433 | | - | |
| 7428 | + | |
7434 | 7429 | | |
7435 | | - | |
| 7430 | + | |
7436 | 7431 | | |
7437 | 7432 | | |
7438 | | - | |
7439 | | - | |
7440 | | - | |
7441 | | - | |
7442 | | - | |
| 7433 | + | |
| 7434 | + | |
7443 | 7435 | | |
7444 | 7436 | | |
7445 | 7437 | | |
| |||
7449 | 7441 | | |
7450 | 7442 | | |
7451 | 7443 | | |
7452 | | - | |
| 7444 | + | |
7453 | 7445 | | |
7454 | | - | |
| 7446 | + | |
7455 | 7447 | | |
7456 | 7448 | | |
7457 | 7449 | | |
7458 | 7450 | | |
7459 | 7451 | | |
7460 | 7452 | | |
7461 | | - | |
| 7453 | + | |
7462 | 7454 | | |
7463 | 7455 | | |
7464 | 7456 | | |
| |||
7573 | 7565 | | |
7574 | 7566 | | |
7575 | 7567 | | |
7576 | | - | |
7577 | | - | |
| 7568 | + | |
7578 | 7569 | | |
7579 | 7570 | | |
7580 | 7571 | | |
7581 | | - | |
7582 | | - | |
7583 | | - | |
7584 | | - | |
7585 | | - | |
| 7572 | + | |
| 7573 | + | |
7586 | 7574 | | |
7587 | 7575 | | |
7588 | 7576 | | |
7589 | 7577 | | |
7590 | | - | |
| 7578 | + | |
7591 | 7579 | | |
7592 | | - | |
| 7580 | + | |
7593 | 7581 | | |
7594 | 7582 | | |
7595 | 7583 | | |
7596 | 7584 | | |
7597 | 7585 | | |
7598 | 7586 | | |
7599 | | - | |
| 7587 | + | |
7600 | 7588 | | |
7601 | 7589 | | |
7602 | 7590 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
| 24 | + | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
| 67 | + | |
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
| |||
225 | 227 | | |
226 | 228 | | |
227 | 229 | | |
228 | | - | |
| 230 | + | |
229 | 231 | | |
230 | 232 | | |
231 | 233 | | |
| |||
285 | 287 | | |
286 | 288 | | |
287 | 289 | | |
288 | | - | |
289 | | - | |
290 | | - | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
291 | 295 | | |
292 | 296 | | |
293 | 297 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | 6 | | |
11 | 7 | | |
12 | 8 | | |
| |||
0 commit comments