Bug?

What do you want to see here? Some more categories, forums, and mods? Hmm...
User avatar
Rain
Round Winner
Posts: 300
Joined: Sat Apr 15, 2006 2:59 pm
Location: a random empty server playing with bots

Bug?

Post by Rain »

I took a look in the server list at the bottom of the forum and I noticed that the system was showing my nick (°°rain) as °°qain.

odd...

Screenshot attached.
Attachments
qain.jpg
User avatar
Tank Program
Forum & Project Admin, PhD
Posts: 6711
Joined: Thu Dec 18, 2003 7:03 pm

Post by Tank Program »

"Oh my."

Not a clue. Sure that was you? That aside, querying isn't exactly perfect. Not sure what could cause it to be just one letter off...
Image
User avatar
Rain
Round Winner
Posts: 300
Joined: Sat Apr 15, 2006 2:59 pm
Location: a random empty server playing with bots

Post by Rain »

yes, it was me.
not worried about it, qain is good for me, just informing...
greetings
User avatar
Rain
Round Winner
Posts: 300
Joined: Sat Apr 15, 2006 2:59 pm
Location: a random empty server playing with bots

Post by Rain »

Happened again with °°Plato, showed as °°Olato.
Seems that the first letter is changed in one position back after the °°.
For ex rain to qain
lmnop q<----r st
and Plato to Olato
lmn o<----p qrst

greetings
User avatar
Tank Program
Forum & Project Admin, PhD
Posts: 6711
Joined: Thu Dec 18, 2003 7:03 pm

Post by Tank Program »

Just names with the °°?
Image
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Post by Jonathan »

Square degrees eat too many resources, including part of the next character. Square radians should solve your problem.
ˌɑrməˈɡɛˌtrɑn
User avatar
Rain
Round Winner
Posts: 300
Joined: Sat Apr 15, 2006 2:59 pm
Location: a random empty server playing with bots

Post by Rain »

Tank: yea, I've noticed it only in nicks with °°.

Jonathan: as I said, it is not a problem for me. just informating about that. thanks anyway.
User avatar
kyle
Reverse Outside Corner Grinder
Posts: 1876
Joined: Thu Jun 08, 2006 3:33 pm
Location: Indiana, USA, Earth, Milky Way Galaxy, Universe, Multiverse
Contact:

Post by kyle »

WRTL has it fixed
Last edited by kyle on Wed Dec 12, 2007 10:48 pm, edited 8 times in total.
User avatar
wrtlprnft
Reverse Outside Corner Grinder
Posts: 1679
Joined: Wed Jan 04, 2006 4:42 am
Location: 0x08048000
Contact:

Post by wrtlprnft »

I finally figured it out:

Arma encodes all network traffic as 16- bit integers. Therefore, to send a string (like the player names), the individual characters are paired together, the first char of each pair becoming the lower byte of the new short, the second thar becoming the upper byte.

At least that's what tank was probably thinking when he originally wrote the script (and nobody noticed it afterwards).

Well, what actually happens is this:

Code: Select all

    char const * sRaw = s;
 
    // write first pairs of bytes
    for(i=0;i+1<len;i+=2)
        Write(sRaw[i]+(sRaw[i+1] << 8));
(nNetwork.cpp:~985)
It multiplies the second char by 256 and adds that to the first char to get the short to be sent. This works alright until the first char gets bigger than 127. Because sRaw is a signed char* sRaw is actually a negative number and gets subtracted from (sRaw[i+1] << 8), therefore causing some mess (the second char's ascii value gets lowered by 1).

Anyways, here's my fix. I don't know exactly how robust/correct/ugly it is, but it appears to work:

Code: Select all

              for ($c = 0; $c < strlen($this->rawpacket); $c = $c + 2)
                {
                        $this->swappedpacket[$c] = $this->rawpacket[$c + 1];
                        $this->swappedpacket[$c + 1] = $this->rawpacket[$c];
                }
becomes

Code: Select all

              for ($c = 0; $c < strlen($this->rawpacket); $c = $c + 2)
                {
                        $this->swappedpacket[$c] = $this->rawpacket[$c + 1];
                        $this->swappedpacket[$c + 1] = $this->rawpacket[$c];
                        if(ord($this->swappedpacket[$c]) > 127) {
                                $this->swappedpacket[$c + 1] = chr(1 + ord($this->swappedpacket[$c + 1])) ;
                        }
                }
There's no place like ::1
User avatar
Z-Man
God & Project Admin
Posts: 11585
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Post by Z-Man »

Interesting, I did not realize that :)
User avatar
wrtlprnft
Reverse Outside Corner Grinder
Posts: 1679
Joined: Wed Jan 04, 2006 4:42 am
Location: 0x08048000
Contact:

Post by wrtlprnft »

I guess it was luck that the receiving code compensates for that ;)
There's no place like ::1
User avatar
Z-Man
God & Project Admin
Posts: 11585
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Post by Z-Man »

Nah, luck had nothing to do with it :) The sending code uses signed arithmetics, so the receiving code uses signed arithmetics too.
User avatar
Tank Program
Forum & Project Admin, PhD
Posts: 6711
Joined: Thu Dec 18, 2003 7:03 pm

Post by Tank Program »

I believe what I was thinking was that all the letters in the packets were backwards in pairs of two. I (think) I reverse engineered the master server protocol almost exclusively from packet capturing rather than reading the code. Something like crazy byte swapping never even occurred to me.
Image
User avatar
wrtlprnft
Reverse Outside Corner Grinder
Posts: 1679
Joined: Wed Jan 04, 2006 4:42 am
Location: 0x08048000
Contact:

Post by wrtlprnft »

It appears to work so I committed it to aabeta. I also changed

Code: Select all

		$query = pack("xCxxxxxC", 0x35, 0x11);
to

Code: Select all

		$query = pack("xCxxxx", 0x35);
. I don't think that extra short is used from anywhere inside arma. Just because it took me a while to figure out, here's what the first shorts of a nMessage mean:
  • Packet “type”
  • Packet ID
  • Length of the actual message
Let me know if it had any meaning…
There's no place like ::1
User avatar
Tank Program
Forum & Project Admin, PhD
Posts: 6711
Joined: Thu Dec 18, 2003 7:03 pm

Post by Tank Program »

About that, I don't know. Again, I was just emulating what I saw my client doing.
Image
Post Reply