Discussion Anyone able to explain the new 'Flags' system in the status file

The status file looks like it contains some really valuable data I'd like to parse but I cannot for the life of me figure out the new flags system. Anyone able to point me in the right direction?
Cheers
 
You need to extract the needed bits.

In the first example above 16842765 (0x0101000d) has flags 24, 16, 3, 2, 0: In main ship, Mass
locked, Shields up, Landing gear down, Docked

The number 16842765 or 0x0101000d looks like this:
1000000010000000000001101

You see, bit 0, 2, 3, 16 and 24 are set. Now you have to extract the bits you want to read. For example: Bit 8 (Ligths on) is 0 -> not set.
 
You need to extract the needed bits.



The number 16842765 or 0x0101000d looks like this:
1000000010000000000001101

You see, bit 0, 2, 3, 16 and 24 are set. Now you have to extract the bits you want to read. For example: Bit 8 (Ligths on) is 0 -> not set.

Okay, Kind of but there are only 25 characters there, bits 0 through 24 - the documentation shows bit 25 & 26... if bit 25 is in fighter how would that be shown as there doesn't appear to be enough bits for it to be 0 or 1?
 
Last edited:
You dont write zeros on the left side of binäry or hex numbers
But its just optical and also syntax is correct in most programing languages. Its just an unwriten law

Example
Do: 0b1000000010000000000001101
Dont: 0b01000000010000000000001101

Do: 0x101000d
Also do (4 full visual bytes): 0x0101000d
Dont (first zero is unnecessary): 0x00101000d

Btw... if you use hexadezimal or binary numbers in comments or in posts, always use prefixes. After some Month you dont know which type of number you used... 10001 can be decimal, hex or binary
 
Last edited:
You dont write zeros on the left side of binäry or hex numbers
But its just optical and also syntax is correct in most programing languages. Its just an unwriten law

Example
Do: 0b1000000010000000000001101
Dont: 0b01000000010000000000001101

Do: 0x101000d
Also do (4 full visual bytes): 0x0101000d
Dont (first zero is unnecessary): 0x00101000d

Btw... if you use hexadezimal or binary numbers in comments or in posts, always use prefixes. After some Month you dont know which type of number you used... 10001 can be decimal, hex or binary

Any chance you could show me the example of bits 0, 2, 3, 16, 24, 25 & 26 set?

Thanks for your help BTW.
 
Any chance you could show me the example of bits 0, 2, 3, 16, 24, 25 & 26 set?

Thanks for your help BTW.

xmAFV1b.png


In OSX you can click in the 0's to toggle to 1.

If you want to do it manually: 1*2^0 + 1*2^2 + 1*2^3 + 1*2^16 + 1*2^24 + 1*2^25 + 1*2^26
 
Last edited:

Robert Maynard

Volunteer Moderator
To check whether the flag at bit 25 is set:

bool result = ((allflags & 0x02000000)>0);

For bit 26 the mask is 0x04000000.

So, for your 0, 2, 3, 16, 24, 25 & 26 example, the result = 0x1 | 0x4 | 0x8 | 0x10000 | 0x1000000 | 0x2000000 | 0x4000000 = 0x701000D
 
Last edited:
To check whether the flag at bit 25 is set:

bool result = ((allflags & 0x02000000)>0);

For bit 26 the mask is 0x04000000.

So, for your 0, 2, 3, 16, 24, 25 & 26 example, the result = 0x1 | 0x4 | 0x8 | 0x10000 | 0x1000000 | 0x2000000 | 0x4000000 = 0x701000D

I honestly wish that made it easier to understand but it doesn't :) I know I'm just being thick here and at the moment I wish they'd just used a standard JSON tag for each of those elements, I can parse that easily... this however I need to get my head around...

This is the string from 0, 2, 3, 16, 24 being set: 1000000010000000000001101 , I can see the bits at the right count flipped to 1's and there are 25 bits 0 -24 - I under that (I think). However, what would it look like if 0, 2, 3, 16, 24, 25 & 26 were set? 111000000010000000000001101?
 
Last edited:
Yup, its the 25 & 26 i need to visualise, if I can't see them as mLine suggested I have no idea how to parse the string.

you don't really need to parse the bit field. consider the string as a bunch of flags mashed together, just parse it as an integer. you can then test that integer against individual flags as listed on the doc with bitwise comparison.

eg #25 is 33554432 decimal. assume "flags" is an integer representing the flags field read from the api. then this expression (e.g. in javascript):

(flags & 33554432)

would be truthy if #25 is set, falsy otherwise. likewise,

(flags & 67108864)

would test for #26

for readability you would define those 'magic' powers of 2 as symbolic constants. e.g., in javascript:

var flagInFighter = 33554432;
var flagInSRV = 67108864;
// ...
if (flags & flagInFigther) ...

or you could even test several flags at once:

if (flags & (flagInFigther|flagInSRV)) // pilot is either in slf or in srv
 

This!

If you want to check a single bit just do this with a AND operation.

Example
Code:
var flags = 16842765 // you got this from status.json

// flag constances
const var flagDocked = 0x01;
const var flagLanded = 0x02;
...
const var flagFsdMasslocked = 0x010000;
...
const var flagInFighter = 0x02000000;

// check for Fsd Masslocked
if(flags & flagFsdMasslocked) {
  // Fsd Masslocked bit is set
}

// check for In Fighter
if(flags & flagInFighter) {
  // In Fighter bit is set
}

Sorry, but if you still dont know what to do, you should first learn basic programming.
 
Sorry, but if you still dont know what to do, you should first learn basic programming.

While I'm not a professional programmer by any stretch of the imagination I do quite well for someone who is entirely self taught. I've just never come across this method of storing flags in bits before so needed it explaining. Again thanks for your help, I really appreciate it.

Thanks to everyone else as well!
 
Guys - Just wanted to say a big thanks again. I've figured it all out now, it's actually really simple to get the flags and all of your examples now make complete sense. Sorry for being such a dimwit - I think I was just over complicating matters in my head!
 
Guys - Just wanted to say a big thanks again. I've figured it all out now, it's actually really simple to get the flags and all of your examples now make complete sense. Sorry for being such a dimwit - I think I was just over complicating matters in my head!

Now stop talking and go for it!! :D
 
Back
Top Bottom