Author | Message | Time |
---|---|---|
Tech | Hello. I need some help with converting this code to VB. [code] int GamePacketDecode(unsigned char *indata, unsigned int insize, unsigned char *outdata, unsigned int outmax, unsigned int *outsize) { unsigned int a, b, c, d; unsigned int maxcnt, index, cnt; unsigned char *outptr, *inptr; int size; b = 0; size = insize; inptr = indata; maxcnt = outmax; outptr = outdata; cnt = 0x20; while (1) { if (cnt >= 0x8) { while (size > 0 && cnt >= 8) { cnt -= 0x8; size--; a = *inptr++ << cnt; b |= a; }; } index = CharIndex[b >> 0x18]; a = CharTable[index]; d = (b >> (0x18 - a)) & BitMasks[a]; c = CharTable[index + 2*d + 2]; cnt += c; if (cnt > 0x20) { *outsize = outmax - maxcnt; return 1; } if (maxcnt-- == 0) return 0; a = CharTable[index + 2*d + 1]; *outptr++ = (unsigned char)a; b <<= (c & 0xFF); } assert(0); return 0; } [/code] So far I have converted everything but these 2 lines [code] a = *inptr++ << cnt; [/code] [code] *outptr++ = (unsigned char)a; [/code] I took a guess, but no luck..heres my code [code] Dim lInptr As Long lInptr = Len(Inptr) lInptr = lInptr + 1 A = LeftShift(lInptr, CNT) and.. Outptr = A [/code] Any help would be greatly appreciated. p.s: for those who don't know..this code decompress a d2gs packet into data. It was found here: https://davnit.net/bnet/vL/phpbbs/index.php?topic=585.0 | June 21, 2005, 6:17 PM |
Ringo | MyndFyre explained alot of that here I persionaly wouldnt bother porting the tables to VB6, as its fairly slow. | June 21, 2005, 6:33 PM |
Yegg | a = *inptr++ << cnt; [code]Dim tmp_inptr As Integer tmp_inptr= inptr + 1 a = LeftShift(tmp_inptr, cnt)[/code] *outptr++ = (unsigned char)a; [code]Dim tmp_outptr As String tmp_outptr = outptr + 1 tmp_outptr = a ' Convert a to a string (character) (Havn't used VB in a while, I forgot how to do that[/code] | June 21, 2005, 7:36 PM |