Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Some objective values not found in Manifest? #50

Closed
jgayfer opened this issue Sep 6, 2017 · 8 comments
Closed

[Question] Some objective values not found in Manifest? #50

jgayfer opened this issue Sep 6, 2017 · 8 comments

Comments

@jgayfer
Copy link

jgayfer commented Sep 6, 2017

I've been working on getting values for the weekly nightfall, and I'm having an issue fetching one of the 'challenges' from the Manifest database. The other two values are both there, but the third isn't for some reason.

The hash ID is 4148319260, and I'm looking in DestinyObjectiveDefinition. Does anyone know why this is happening?

@vthornheart-bng
Copy link
Contributor

Hmm, that's odd - I see it in there, look for index 925 (name = "Speed of Dark"). Oh, could it be that the hash is being converted to an int instead of a uint in your code? I know this has tripped people up before. Let me know!

@jgayfer
Copy link
Author

jgayfer commented Sep 6, 2017

I'm not quite sure where 925 is coming from. I'm still a bit confused.

If the hashes are all unsigned ints, how come I am seeing negative values in my sqlite viewer? Could it be displaying the numbers as signed values?

@vthornheart-bng
Copy link
Contributor

Ah, yeah - the index property of the contained item will be 925 when you pull it out of the database.

Indeed: sqlite viewer must be treating those as signed values. Convert your unsigned value into a signed one and make the query again in sqlite viewer, and you should find the result. It's the same limitation and trick that people had to pull in Destiny 1:

http://destinydevs.github.io/BungieNetPlatform/docs/Manifest
(take a look in here under "Entry IDs")

I still need to add a section to our wiki about the Manifest and these... er... quirks.

@jgayfer
Copy link
Author

jgayfer commented Sep 6, 2017

Ah! I got it working. You were right; Just had to convert the unsigned values into signed ones 🙂

I used this function to convert the number, if anyone else is having the same issue (Python).

def twos_comp_32(val):
    val = int(val)
     if (val & (1 << (32 - 1))) != 0:
        val = val - (1 << 32)
    return val

Thank you for your help!

@jgayfer jgayfer closed this as completed Sep 6, 2017
@vthornheart-bng
Copy link
Contributor

Sweet, no problem - and glad you got it working! That is definitely an extremely unintuitive problem with the Manifest, and warrants a new FAQ entry on my part (and eventual Wiki article about the manifest in general)

@artem-galas
Copy link

Hm...I don't understand how we can check signed or unsigned number?

@jgayfer
Copy link
Author

jgayfer commented Sep 10, 2017

If you're using unsigned, you'll never have negative numbers. Whereas with signed, you will (approximately half the time).

@vthornheart-bng
Copy link
Contributor

vthornheart-bng commented Sep 10, 2017

@artem-galas A good, quick formula you can use to convert is the following, that'll convert the values when needed for you: (or you can do the bitshifting jgayfer is doing above of course! That's arguably faster and truer to what's actually happening under the surface, but whatever floats your boat)

if (hash < 0)
{
hash = hash + 4294967296;
}

That will push it up to its unsigned equivalent value.

... indeed, this is a most inconvenient hack, and one that the community has had to endure for quite some time. When we get around to putting out JSON files directly, this won't be an issue anymore (though you will have to convert strings to unsigned ints... but you're already having to do that, so I imagine that's a more obvious problem than this signed/unsigned problem)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants