PDA

View Full Version : Bitwise Shift Operations



joojooga
04-06-2003, 12:52 PM
I've gotten into bitwise shift operations in my C/C++ studies now. It's really cool and I had an insight and I wondered if it was true..

Using bitwise shift operations you can pack a lot of data into numbers. You can use something like 1001 0001 0011 0101 or 0x9135 to represent all kinds of things by just making the bits mean something. Then you can use bit masks to "and" or "or" data from the original value.

So my question is, do you think Verant uses this in their packets to represent things like dragons, spawn points, colors etc? It seems to me like this would really save a lot of bandwidth because you're only pushing a number.

Seems to me that if they do this, understanding this concept would be paramount to writing some good decode stuff.

fester
04-06-2003, 01:33 PM
They do use this at times. They have used this more in the past.
The problem is that it often can take more cpu time to decode a meaning than it takes to read a byte or word from ram.

It is often used for flags that are rarely used. For instance, the "magic" flag (when you look at an item, LORE, MAGIC, NO DROP, etc.) is a single bit in a byte with the other bits having different meanings.

iluvseq
04-06-2003, 09:03 PM
Class, Race and equipable slot all use bitmasks in the item data structure.