Thread: Help me comprehend this please.

Results 1 to 6 of 6
  1. #1 Help me comprehend this please. 
    Registered Member
    Join Date
    Dec 2008
    Posts
    40
    Thanks given
    0
    Thanks received
    0
    Rep Power
    12
    Alright guys, quick question, how do you know on a code like this:
    public void sendItemArray(int frameId, int itemId, int slot, int itemAmount) {
    c.outStream.createFrameVarSizeWord(34);
    c.outStream.writeWord(frameId);
    c.outStream.writeByte(slot);
    c.outStream.writeWord(itemId+1);
    c.outStream.writeByte(255);
    c.outStream.writeDWord(itemAmount);
    c.outStream.endFrameVarSizeWord();
    }
    when is something a byte, when is something a word, a Dword, etc.. and why is it 34 on createframevarsizeword. I would love to be able to understand all of this. thanks.
    Reply With Quote  
     

  2. #2  
    Registered Member
    Mister Maggot's Avatar
    Join Date
    Dec 2008
    Posts
    7,227
    Thanks given
    3,283
    Thanks received
    2,875
    Rep Power
    5000
    It's called a"packet" and it's preset in the client. You won't be able to understand it unless you knew simple shit about Java, btw, you don't.
    Reply With Quote  
     

  3. #3  
    Registered Member
    Its paris's Avatar
    Join Date
    Apr 2009
    Posts
    1,141
    Thanks given
    56
    Thanks received
    234
    Rep Power
    689
    It's part of the protocol. The byte is a byte, the word is a short, the dword (double word) is an integer, it isn't used here but qword (quadruple word) is a long.
    A byte is 1 byte (8 bits) long, a short is 2 bytes (16 bits) long, an integer (double word -> double the size of a word) is 4 bytes (32 bits) long, a long (quadruple word -> quadruple the size of a word) is 8 bytes (64 bits) long.
    34 is the packetId and strangely enough, createFrameVarSizeWord would mean the packetSize isn't fixed, which actualy does seem to be the case.
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Dec 2008
    Posts
    40
    Thanks given
    0
    Thanks received
    0
    Rep Power
    12
    Quote Originally Posted by TheChosenOne View Post
    It's part of the protocol. The byte is a byte, the word is a short, the dword (double word) is an integer, it isn't used here but qword (quadruple word) is a long.
    A byte is 1 byte (8 bits) long, a short is 2 bytes (16 bits) long, an integer (double word -> double the size of a word) is 4 bytes (32 bits) long, a long (quadruple word -> quadruple the size of a word) is 8 bytes (64 bits) long.
    34 is the packetId and strangely enough, createFrameVarSizeWord would mean the packetSize isn't fixed, which actualy does seem to be the case.
    alright alright, but why is the (slot) for example a byte? is there anything in specific that makes it a byte? why isnt it a short for example.
    Reply With Quote  
     

  5. #5  
    Registered Member
    Mister Maggot's Avatar
    Join Date
    Dec 2008
    Posts
    7,227
    Thanks given
    3,283
    Thanks received
    2,875
    Rep Power
    5000
    It's smaller and can only reach a small value, a word was used later in the code because the number could reach a higher value than a byte can handle.
    Reply With Quote  
     

  6. #6  
    Registered Member
    Its paris's Avatar
    Join Date
    Apr 2009
    Posts
    1,141
    Thanks given
    56
    Thanks received
    234
    Rep Power
    689
    Quote Originally Posted by test2457 View Post
    alright alright, but why is the (slot) for example a byte? is there anything in specific that makes it a byte? why isnt it a short for example.
    Just as "i r magot" said, the value will never reach the max value of a byte and a byte is smaller than a short.
    With internet, you actually pay per byte sent over the internet (never wondered why most internet providers have download limits?).
    Therefor, a gaming company would do great to use small primitives instead of bigger ones if they can manage with the small ones. It saves them bandwidth.
    For the same reason, they sometimes manipulate bits on their own.
    Technically, writing or reading a byte is faster than writing or reading a short. Another advantage there.
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •