Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: Joe[x86] on December 10, 2005, 03:00 PM

Title: [VB] ParseBNCS Stub Class
Post by: Joe[x86] on December 10, 2005, 03:00 PM
Poke Me Please (http://www.javaop.com/~joe/pbncs/)
Title: Re: [VB] ParseBNCS Stub Class
Post by: shout on December 10, 2005, 04:19 PM
*pokes Joe in the eye*

Why would you do something like this?
Title: Re: [VB] ParseBNCS Stub Class
Post by: Joe[x86] on December 10, 2005, 04:19 PM
Quote from: Topaz on December 10, 2005, 04:09 PM
So... ugly...

Go die in agony. ..!..

Quote from: Shout on December 10, 2005, 04:19 PM
*pokes Joe in the eye*

Why would you do something like this?
Because my old one was ugly! =p
Title: Re: [VB] ParseBNCS Stub Class
Post by: dxoigmn on December 10, 2005, 04:24 PM
You should be using a Buffer class, not strings to pass contents of packets around. Talk about eww:


Select Case Asc(Mid(sPacket, 2, 1))
Title: Re: [VB] ParseBNCS Stub Class
Post by: shout on December 10, 2005, 04:27 PM
Which is uglier, Joe's weird stubby thing or this from my bot I will never finish:


#pragma warning(disable:4996) //strcat is depreciated... works fine for me!
LPCSTR CheckRevision::GetNextFile()
{
PSTR ret = (PSTR)malloc(4000);
memset(ret, 0, 4000);
strcpy(ret, this->path);
switch (this->client)
{
case SEXP:
case STAR:
switch (this->currentfile)
{
case 0:
strcat(ret, "starcraft.exe");
break;
case 1:
strcat(ret, "storm.dll");
break;
case 2:
strcat(ret, "battle.snp");
break;
}
return ret;



case D2DS:
case D2XP:
switch (this->currentfile)
{
case 0:
strcat(ret, "game.exe");
break;
case 1:
strcat(ret, "bnclient.dll");
break;
case 2:
strcat(ret, "d2client.dll");
break;
}
return ret;



case W2BN:
switch (this->currentfile)
{
case 0:
strcat(ret, "Warcraft II BNE.exe");
break;
case 1:
strcat(ret, "storm.dll");
break;
case 2:
strcat(ret, "battle.snp");
break;
}
return ret;



case W3XP:
case WAR3:
switch (currentfile)
{
case 0:
strcat(ret, "war3.exe");
break;
case 1:
strcat(ret, "storm.dll");
break;
case 2:
strcat(ret, "game.dll");
break;
}
return ret;
}
}
#pragma warning(default:4669)
Title: Re: [VB] ParseBNCS Stub Class
Post by: Networks on December 10, 2005, 05:06 PM
Quote from: dxoigmn on December 10, 2005, 04:24 PM
You should be using a Buffer class, not strings to pass contents of packets around. Talk about eww:


Select Case Asc(Mid(sPacket, 2, 1))


I agree, it's fine to create functions for each packet for handling them and sending them. I did this in 'Vanquish Chat' and it worked out very well as far as organization.
Title: Re: [VB] ParseBNCS Stub Class
Post by: Joe[x86] on December 10, 2005, 06:02 PM
Yeah, I should be using a packet UDT. The point of creating this was so that they don't have to go through the agonizing pain of writing it themselves. If they want to use a packet UDT, find and replace String with udtPacket.
Title: Re: [VB] ParseBNCS Stub Class
Post by: shadypalm88 on December 11, 2005, 10:05 AM
Quote from: Joe on December 10, 2005, 06:02 PM
Yeah, I should be using a packet UDT. The point of creating this was so that they don't have to go through the agonizing pain of writing it themselves. If they want to use a packet UDT, find and replace String with udtPacket.
This is why you use a real text editor and learn to use regular expressions.  Suddenly, armed with the packet ID macros or constants from BnetDocs, creating your stubs is painless.

Also using a buffer, after processing the header, you can just pass the buffer object directly to your specific packet handlers.
Title: Re: [VB] ParseBNCS Stub Class
Post by: UserLoser. on December 11, 2005, 11:42 AM
Just to remove some ungliness, you should use names like "OnPing" instead of "Handle_SID_PING"
Title: Re: [VB] ParseBNCS Stub Class
Post by: rabbit on December 11, 2005, 12:35 PM
Just to make it better, you should add in specific chat event throwers (Events in VB).
Title: Re: [VB] ParseBNCS Stub Class
Post by: QwertyMonster on December 12, 2005, 09:57 AM
I like it Joe. Nice job. :)