Page 1 of 1

packet.SetInt16

Posted: Sat Feb 22, 2014 11:28 am
by Harley
Hi guys! I use StatHook from last Distro SVN.
There is some difficult in function Send_ResistInfos() in sendstat.inc
!!!.jpg
Like you see, fire resistances -7936
But, there isn't FireProtection on character!

Code: Select all

         var resistances := GetObjProtections( character );

         var fire := CInt( resistances["FireProtection"] );
         if( fire > 0 )
                  packet.SetInt16( 70, fire );
         else
                  packet.SetInt16( 70, 0x10000 + fire );
         endif

         var cold := CInt( resistances["WaterProtection"] );
         if( cold > 0 )
                  packet.SetInt16( 72, cold);
         else
                  packet.SetInt16( 72, 0x10000 + cold );
         endif
This error only at Fire Protection!
I have delete 0x10000 from packet.SetInt16( 70, 0x10000 + fire );
packet.SetInt16( 70, fire );
And all was right, but I can't understand, what cause in 0x10000 ?
Remind, this error only in Fire Protection!

Thanks, with best regards!

Re: packet.SetInt16

Posted: Sun Feb 23, 2014 7:26 am
by RusseL
Resistances
Resistances can be negatives. Easiest method for handling this correctly is, if a negative is to be sent is: 0x10000+amount
http://docs.polserver.com/packets/index.php?Packet=0x11
:|

Re: packet.SetInt16

Posted: Mon Feb 24, 2014 10:11 am
by Harley
RusseL, unfortunately, do not understand in packets.. But, I have removed 0x10000 and now it's ok)

Re: packet.SetInt16

Posted: Mon Feb 24, 2014 1:05 pm
by Turley
The bug is the if clause:
If (res > 0)
It should be instead:
If (res >= 0)