( search forums )
Weird output
Soldat Forums - Soldat Talk - Developers Corner
February 25, 2006, 1:38 am
You may have noticed me bothering random posts about the program I am working on. I want to get it finished and able to accept plug-ins asap so I can get back to learning XPath and DTDs.

This is what the current output looks like.
Game type: Death Match
Time Limit: 0
Kill limit: 2000
Status: paused

First things first, to retrieve this information I am doing the fallowing.
1) connecting to the server
2) sending "REFRESH\n"
3) reading one byte at a time till I get to the first line break (char 10)
4) reading the first byte, then then next 24 for the players name
4.5) Repeat step 4 32 times in a row
5) Add content to the data set
6) Moving on down the list to reading the team ect.

Everything above the purple line is exactly what it should be.
What I have displayed on the image. After name value 6 for the name loop I displayed the byte values. Since there are a lot of chars below 25 displaying string values doesn't do crap. Each value is separated by the "|" char.
At the bottom of the screen you can see some text output. That is generated right after all fields where filled. Score should be the next value that is pulled. But instead it gives me eight 0s then the map name. It is set to loop to 17 but I keep getting an error at index 16.

1) I have no problem removing the rows that have team 255 but what is all that other random crap? Shouldn't it just return the value of 0.
2) Why did every other value show up except score?
3) Whats with the 8 0s before the map name. That couldn't be scores for the players.

Any ideas?

February 25, 2006, 6:22 am
Edit: addition, since I noticed that you use .net; be VERY careful over what data types you use, some types in .net are double the size compared to previous versions. check the required data storage for each type you use, so that its correct.

1) The server always returns data for 32 players no matter what the server limit. The unused player slots are just filled with garbage data. Send the maxplayers command to the server to determine how many names to display, or I believe the length of the other names is 0 so you just dont display names with a length of 0.

2) The 8 zeros before the map name are the teamscores as Word(2 byte) values.

3) The size of the refresh packet is a fixed size, so there is no need to read a byte at a time testing for a value; copy the entire packet to a buffer. The size is 1188 bytes. The server replies with REFRESH\r\n before the actual data to indicate that its a refresh packet, so thats the only thing you need to check.

4) It appears that you have some incorrect type sizes if you are skipping most of the packet, double check the sizes of the data, and the structure you are using. It should be this:

sizes of the types are the following:
word = 2 bytes
integer = 4 bytes

Name : array[1..32] of string[PLAYERNAME_CHARS];
Team : array[1..32] of byte;
Kills : array[1..32] of word;
Deaths : array[1..32] of word;
Ping : array[1..32] of byte;
Number : array[1..32] of byte;
IP : array[1..32,1..4] of byte;
TeamScore : array[1..4] of word;
MapName : string[16];
TimeLimit, CurrentTime : integer;
KillLimit : word;
GameStyle : byte;

February 25, 2006, 7:02 pm
1) The length for each string is random too... The screen shot posts 25 bytes which includes the first one showing length. So you can see the first one right after the last player starts with 24. I will probably remove the row from the data set is the team is 255.

2) Oh! I see now, team score comes after IP not individual score... Why isn't there a individual score?? Sure it wont matter in a death match game but you can see the leader in CTF.

3) I don't understand the "word" variable. I would think it is a string but there is also string. Since I could not find an easy way to convert this "word" to an integer I did it manually.
result = (data[1] * 256) + data[0];

Summary... the random crap is to be expected and I made a mistake on the last field.

February 26, 2006, 4:00 am
1) In that case, the team should probably work, as well as sending /maxplayers to the server and parsing the output (through the admin connection of course) and only using that many strings

2) There is an individual score, its under "kills", remember, Soldat doesn't differentiate between killing someone and capturing the flag (a flag cap gets counted as kills, 20 I believe)

3) a "word" is a 2 byte unsigned integer, in the range 0 - 65535. if you are using c++ and include windows stuff, it should be defined already as "WORD", if not, I believe its an "unsigned short", but I may be wrong and I'm too lazy to check. its a generic way to specify the size of data in bytes: word = 2 bytes, dword(double word) = 4 bytes, qword(quad word) = 8 bytes, and there is also nibble (4 bits, or 1/2 a byte... get the humor?)

February 26, 2006, 5:01 am
nibble... I've herd of that before but I never got it till now.

There is a uShort data type but I dont know how to convert 2 values of an array into one data type without srewing up the value. I'll work on that one.

Think you for your help. I think I know all will need to finish the program.