Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: pianka on June 23, 2004, 04:41 PM

Title: Adron
Post by: pianka on June 23, 2004, 04:41 PM
The two functions in NBBot called UDPChecksum() and SubChecksum(), are they proven to work?
Title: Re:Adron
Post by: GoSuGaMING on June 23, 2004, 05:12 PM
Quote from: PiaNKA on June 23, 2004, 04:41 PM
The two functions in NBBot called UDPChecksum() and SubChecksum(), are they proven to work?

test them :X
Title: Re:Adron
Post by: MyndFyre on June 23, 2004, 06:11 PM
A little rant on forum etiquette...

1.) If you wanted this to go to Adron, you should have sent him a private message.  If you wanted other people to reply to your question, a more descriptive title, such as "Accuracy of NBBot Checksum functions" might have been more appropriate.

2.) Gosu -- this might be a bit of a suprise to you, but you don't have to reply to *every* thread.  You don't contribute much at all to the realm of original knowledge.  To suggest that he "test" the functions would be to suggest that he compile a list of all possible input and output values and run them through the function.  Impractical, I might say.  And warzone's thread -- your blinding revelation of "buy a book" (where one or two people had already suggested it) is the same way.  Perhaps suggesting a specific book would have been helpful, but what you said was just a way to get your name on the post.

And I'm spent.
Title: Re:Adron
Post by: pianka on June 23, 2004, 07:18 PM
Please accept my apology;)
Title: Re:Adron
Post by: GoSuGaMING on June 23, 2004, 08:52 PM
Quote from: Myndfyre on June 23, 2004, 06:11 PM
A little rant on forum etiquette...

1.) If you wanted this to go to Adron, you should have sent him a private message.  If you wanted other people to reply to your question, a more descriptive title, such as "Accuracy of NBBot Checksum functions" might have been more appropriate.

2.) Gosu -- this might be a bit of a suprise to you, but you don't have to reply to *every* thread.  You don't contribute much at all to the realm of original knowledge.  To suggest that he "test" the functions would be to suggest that he compile a list of all possible input and output values and run them through the function.  Impractical, I might say.  And warzone's thread -- your blinding revelation of "buy a book" (where one or two people had already suggested it) is the same way.  Perhaps suggesting a specific book would have been helpful, but what you said was just a way to get your name on the post.

And I'm spent.

is this a wasted post? just like wasted bandwidth to brighten the day!
Title: Re:Adron
Post by: Zakath on June 23, 2004, 08:54 PM
GoSuGaMING: This might also come as a surprise to you, but a lot of people here think you are a complete and total ass. If you don't clean up your act, I will request that you be banned from the forum - and I'm on excellent terms with the forum admins, so my request WILL be granted.

You have been warned.
Title: Re:Adron
Post by: Lenny on June 23, 2004, 09:10 PM
On a lighter note, can anyone post UDPChecksum() and SubChecksum() (maybe Pianka)?

I'm curious as to what it looks like and how it works....
Title: Re:Adron
Post by: Blaze on June 23, 2004, 09:14 PM
Quote from: Zakath on June 23, 2004, 08:54 PM
GoSuGaMING: This might also come as a surprise to you, but a lot of people here thing you are a complete and total ass.

I agree totally.
Title: Re:Adron
Post by: R.a.B.B.i.T on June 23, 2004, 09:20 PM
Quote from: Kk)Blaze(kK on June 23, 2004, 09:14 PM
Quote from: Zakath on June 23, 2004, 08:54 PM
GoSuGaMING: This might also come as a surprise to you, but a lot of people here thing you are a complete and total ass.

I agree totally.
Second.

Anyway, I'd also like to see these functions.
Title: Re:Adron
Post by: PaiD on June 23, 2004, 09:48 PM

unsigned long subchecksum(unsigned char *buf, int len)
{
   unsigned sum1=0, sum2=0;
   unsigned char *p;
   p = buf+len-1;
   while(len--) {
      sum2 += *p--;
      if(sum2 > 0xff)
         sum2 -= 0xff;
      sum1 += sum2;
   }
   return ((sum2 & 0xff)<<8) | ((sum1 % 0xff) & 0xff);
}


I cant find the other
Title: Re:Adron
Post by: Newby on June 24, 2004, 12:00 AM
Public Function UDPChecksum(ByVal buffer As String, ByVal size As Long) As Long
Dim a&, b&, n&, q&, sum&
   For n = 0 To size - 1
       a = a + ((n + 1) * Asc(Mid$(buffer, n + 1, 1)))
       b = b + ((n + 2) * Asc(Mid$(buffer, n + 1, 1)))
   Next n
   q = a
   While (q > &HFF)
       q = (q / &H100) + (q Mod &H100)
   Wend
   sum = q
   q = b
   While (q > &HFF)
       q = (q / &H100) + (q Mod &H100)
   Wend
   sum = sum + (LShift(&HFF - q, 8))
   UDPChecksum = sum
End Function
Title: Re:Adron
Post by: Blaze on June 24, 2004, 12:21 AM
And the vb version of checksum...


Public Sub InitCRC32()
   Dim i As Long, J As Long, K As Long, XorVal As Long
   Static CRC32Initialized As Boolean
   If CRC32Initialized Then Exit Sub
   CRC32Initialized = True
   For i = 0 To 255
       K = i
       For J = 1 To 8
           If K And 1 Then XorVal = CRC32_POLYNOMIAL Else XorVal = 0
           If K < 0 Then K = ((K And &H7FFFFFFF) \ 2) Or &H40000000 Else K = K \ 2
           K = K Xor XorVal
       Next
       CRC32Table(i) = K
   Next
End Sub
Public Function CRC32(ByVal data As String) As Long
   Dim i As Long, J As Long
   Call InitCRC32
   CRC32 = &HFFFFFFFF
   For i = 1 To Len(data)
       J = CByte(Asc(Mid(data, i, 1))) Xor (CRC32 And &HFF&)
       If CRC32 < 0 Then CRC32 = ((CRC32 And &H7FFFFFFF) \ &H100&) Or &H800000 Else CRC32 = CRC32 \ &H100&
       CRC32 = CRC32 Xor CRC32Table(J)
   Next
   CRC32 = Not CRC32
End Function

'Put this in some module...
Public Const CRC32_POLYNOMIAL As Long = &HEDB88320
Public CRC32Table(0 To 255) As Long
Title: Re:Adron
Post by: UserLoser. on June 24, 2004, 12:52 AM
Quote from: Kk)Blaze(kK on June 24, 2004, 12:21 AM
And the vb version of checksum...

Wrong checksum -- read the thread before replying.
Title: Re:Adron
Post by: pianka on June 27, 2004, 03:11 PM
So does that mean nobody is gonna post it for me? :(
Title: Re:Adron
Post by: hismajesty on June 27, 2004, 03:48 PM
Quote from: Zakath on June 23, 2004, 08:54 PM
GoSuGaMING: This might also come as a surprise to you, but a lot of people here think you are a complete and total ass. If you don't clean up your act, I will request that you be banned from the forum - and I'm on excellent terms with the forum admins, so my request WILL be granted.

You have been warned.

You forgot "moron!"
Title: Re:Adron
Post by: BaDDBLooD on June 27, 2004, 11:47 PM
Would someone explain what those 2 functions are used for? I am a little lost  >:(
Title: Re:Adron
Post by: l)ragon on June 27, 2004, 11:59 PM
Quote from: BaDDBLooD on June 27, 2004, 11:47 PM
Would someone explain what those 2 functions are used for? I am a little lost  >:(

udp packet checksum which is used for the games that use udp.
Title: Re:Adron
Post by: BaDDBLooD on June 28, 2004, 12:13 AM
Which games would that be?
Title: Re:Adron
Post by: GoSuGaMING on June 28, 2004, 12:20 AM
Quote from: BaDDBLooD on June 28, 2004, 12:13 AM
Which games would that be?

prolly starcraft & Broodwar
Title: Re:Adron
Post by: Grok on June 28, 2004, 06:27 AM
Quote from: GoSuGaMING on June 23, 2004, 08:52 PM
Quote from: Myndfyre on June 23, 2004, 06:11 PM
A little rant on forum etiquette...

1.) If you wanted this to go to Adron, you should have sent him a private message.  If you wanted other people to reply to your question, a more descriptive title, such as "Accuracy of NBBot Checksum functions" might have been more appropriate.

2.) Gosu -- this might be a bit of a suprise to you, but you don't have to reply to *every* thread.  You don't contribute much at all to the realm of original knowledge.  To suggest that he "test" the functions would be to suggest that he compile a list of all possible input and output values and run them through the function.  Impractical, I might say.  And warzone's thread -- your blinding revelation of "buy a book" (where one or two people had already suggested it) is the same way.  Perhaps suggesting a specific book would have been helpful, but what you said was just a way to get your name on the post.

And I'm spent.

is this a wasted post? just like wasted bandwidth to brighten the day!

It is only wasted if you don't learn from it that many forum regulars consider your posts to be drivel.
Title: Re:Adron
Post by: iago on June 28, 2004, 07:14 AM
Quote from: PiaNKA on June 23, 2004, 04:41 PM
The two functions in NBBot called UDPChecksum() and SubChecksum(), are they proven to work?

As far as I know, they work.  They've been around for years, so they must be doing something right.

Whoever asked for the function -- this can be gotten from the NBBot source code, which can be found at, among other places, at warz' site --> http://tks.slacktech.com (http://tks.slacktech.com) Ok, the actual page is Here (http://tks.slacktech.com/source/index.php?dir=cpp/&file=Nbbot107.rar) if you don't want to make the 2 clicks to find it (source, then cpp).