Poke Me Please (http://www.javaop.com/~joe/pbncs/)
*pokes Joe in the eye*
Why would you do something like this?
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
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))
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)
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.
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.
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.
Just to remove some ungliness, you should use names like "OnPing" instead of "Handle_SID_PING"
Just to make it better, you should add in specific chat event throwers (Events in VB).
I like it Joe. Nice job. :)