LoneRanger123
Programmer
Im making a program to Query Halflife Servers, using UDP, and when I send "info", it returns:
"info"
Server responds with the following packet:
(int32) -1
(byte) ASCII 'C' (info response, S2A_INFO)
(string) net address of server
(string) name of the host / server
(string) name of the map
(string) game directory (i.e. valve/)
(string) Game description (e.g. "half-life multiplay"
(byte) active client count
(byte) maximum clients allowed
(byte) protocol version (currently 7)
....
How can I split all that up into Strings?
Do AnsiStrings automatically truncate to the first NULL char?
here is my current code (dont work);
That returns everything up to the end of the net address of server (end of first String). That code trys to replace it, that was me testing. I would preferably like it in different strings, an array.
TY for any help You dont have to supply code if u dont want, just give me some pointers and ill try to figure it out.
"info"
Server responds with the following packet:
(int32) -1
(byte) ASCII 'C' (info response, S2A_INFO)
(string) net address of server
(string) name of the host / server
(string) name of the map
(string) game directory (i.e. valve/)
(string) Game description (e.g. "half-life multiplay"
(byte) active client count
(byte) maximum clients allowed
(byte) protocol version (currently 7)
....
How can I split all that up into Strings?
Do AnsiStrings automatically truncate to the first NULL char?
here is my current code (dont work);
Code:
AnsiString C;
TMemoryStream *MyStream = new TMemoryStream();
NMUDP1->ReadStream(MyStream);
C.SetLength(NumberBytes);
MyStream->Read(&C[1], NumberBytes);
int tempI= 1;
while (tempI <= NumberBytes) {
int Temp;
Temp = atoi(&C[tempI]);
if (Temp == 3) {
&C[tempI] == "-";
}
//MessageDlg(&C[tempI],mtError,TMsgDlgButtons() << mbOK,0);
tempI++;
}
MessageDlg(C,mtError,TMsgDlgButtons() << mbOK,0);
That returns everything up to the end of the net address of server (end of first String). That code trys to replace it, that was me testing. I would preferably like it in different strings, an array.
TY for any help You dont have to supply code if u dont want, just give me some pointers and ill try to figure it out.