Thread: Construct map region packet aka 'secondary map region packet'

Page 10 of 10 FirstFirst ... 8910
Results 91 to 96 of 96
  1. #91  
    Donator


    Join Date
    Sep 2007
    Age
    27
    Posts
    2,426
    Thanks given
    125
    Thanks received
    505
    Rep Power
    386
    I know this is old, and I'm not sure if I'm right here, but...
    Code:
    bldr.putBits(26, tile.getX() << 14 | tile.getY() << 3 | tile.getZ() << 24 | tile.getRotation() << 1);
    Doesn't putBits' functionality remove the need for all that bitshifting and ORing?
    Attached image
    Reply With Quote  
     

  2. Thankful users:


  3. #92  
    ???

    funkE's Avatar
    Join Date
    Feb 2008
    Posts
    2,612
    Thanks given
    255
    Thanks received
    989
    Rep Power
    1366
    Quote Originally Posted by donar fabian View Post
    I know this is old, and I'm not sure if I'm right here, but...
    Code:
    bldr.putBits(26, tile.getX() << 14 | tile.getY() << 3 | tile.getZ() << 24 | tile.getRotation() << 1);
    Doesn't putBits' functionality remove the need for all that bitshifting and ORing?
    yes, typically
    .
    Reply With Quote  
     

  4. Thankful user:


  5. #93  


    Major's Avatar
    Join Date
    Jan 2011
    Posts
    2,997
    Thanks given
    1,293
    Thanks received
    3,556
    Rep Power
    5000
    Quote Originally Posted by donar fabian View Post
    I know this is old, and I'm not sure if I'm right here, but...
    Code:
    bldr.putBits(26, tile.getX() << 14 | tile.getY() << 3 | tile.getZ() << 24 | tile.getRotation() << 1);
    Doesn't putBits' functionality remove the need for all that bitshifting and ORing?
    Only if you call it five times
    Reply With Quote  
     

  6. #94  


    Major's Avatar
    Join Date
    Jan 2011
    Posts
    2,997
    Thanks given
    1,293
    Thanks received
    3,556
    Rep Power
    5000
    Quote Originally Posted by packersfan84 View Post
    doing it in 1 call sounds like some sort of pre mature optimisations
    Optimisation isn't the only reason for this:

    Code:
    bldr.putBits(26, tile.getX() << 14 | tile.getY() << 3 | tile.getZ() << 24 | tile.getRotation() << 1);
    Code:
    bldr.putBits(2, tile.getZ());
    bldr.putBits(10, tile.getX());
    bldr.putBits(11, tile.getY());
    bldr.putBits(2, tile.getRotation());
    bldr.putBits(1, 0);
    Last edited by Major; 06-17-2015 at 08:28 AM.
    Reply With Quote  
     

  7. #95  
    Renown Programmer & Respected Member

    Ryley's Avatar
    Join Date
    Aug 2011
    Posts
    596
    Thanks given
    254
    Thanks received
    521
    Rep Power
    1332
    Quote Originally Posted by Major View Post
    Optimisation isn't the only reason for this:

    Code:
    bldr.putBits(26, tile.getX() << 14 | tile.getY() << 3 | tile.getZ() << 24 | tile.getRotation() << 1);
    Code:
    bldr.putBits(2, tile.getZ());
    bldr.putBits(10, tile.getX());
    bldr.putBits(11, tile.getY());
    bldr.putBits(2, tile.getRotation());
    bldr.putBits(1, 0);
    The second is more obvious and much more clear... why you would use the first is beyond me.
    Reply With Quote  
     

  8. Thankful user:


  9. #96  


    Major's Avatar
    Join Date
    Jan 2011
    Posts
    2,997
    Thanks given
    1,293
    Thanks received
    3,556
    Rep Power
    5000
    Quote Originally Posted by packersfan84 View Post
    the fact that i had to correct you on that shows that in fact the second one is much clearer
    Actually it just shows that i made a typo while I was writing it out in the reply box...

    Quote Originally Posted by Ryley View Post
    The second is more obvious and much more clear... why you would use the first is beyond me.
    Yeah I actually prefer the second one, not really sure what I was thinking the other day
    Reply With Quote  
     

Page 10 of 10 FirstFirst ... 8910

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
  •