Valkyrie: Bug: NULL pointer dereference because valkyrie will import Tokens with no images

Created on 3 Dec 2018  路  6Comments  路  Source: NPBruce/valkyrie

Description of Problem or Question

Hello people,

I'm just playing around with valkyrie for fun using a995c2ce from development-2.2 branch as my HEAD.

I noticed that when I tried to make a scenario and I was trying to add some tokens, some tokens did not have images (in particular darkness and fire). After I tried to select those (because why not), the scenario builder crashed with a NULL pointer dereference:

NullReferenceException: Object reference not set to an instance of an object
Quest + Token..ctor(.Token questToken, .Game gameObject)(at Assets / Scripts / Quest / Quest.cs:1522)
Quest.Add(System.String name, Boolean shop)(at Assets / Scripts / Quest / Quest.cs:1063)

which is basically because:

            Texture2D newTex = ContentData.FileToTexture(game.cd.tokens[tokenName].image, texPos, texSize);

returned NULL because game.cd.tokens[tokenName].image was NULL in the case of darkness and fire.

So I'm not entirely sure what happened there, but it seems like Valkyrie failed to import the darkness and fire images?

PS: Thanks a lot for Valkyrie! A very fun project!

bug

Most helpful comment

If you feel like playing a bit more with Valkyrie code, I can suggest some more accessible change request that have been requested:

959 Code puzzles question. Specific codes

943 add previous/next button on events,quest etc.

Now feel free to work on whatever you want, just tell us so we are sure not to work on it at the same time :)

I'm available to help mostly through discord.

All 6 comments

Please see my PR for a patch that blocks the import of tokens without images: https://github.com/NPBruce/valkyrie/pull/969

IIUC, it's basically useless to import those tokens anyway since we cant use them, and they will also trigger a NULL ptr dereference if used....

BTW, any idea what happened during the import that made it fail?

Here is how the import dialog looked like FWIW. Also, why is the yellow search token missing and we only have the blue exclamation mark?
unitybug

Hi @asn-d6,
thanks for the PR, I'll merge into the dev branch, it's good to have a bit more stability 馃憤

The problem you describe here is related to #966 MoM 1.7.0 - Broken image (sprites) on Windows
I've fixed it yesterday.

So if you have cloned the branch, you need to take this commit : https://github.com/NPBruce/valkyrie/commit/35842cfaf891b746ec473c8375ff795f8fb9c522

If you already have this patch, then you need to upgrade MoM version on steam.

If you feel like playing a bit more with Valkyrie code, I can suggest some more accessible change request that have been requested:

959 Code puzzles question. Specific codes

943 add previous/next button on events,quest etc.

Now feel free to work on whatever you want, just tell us so we are sure not to work on it at the same time :)

I'm available to help mostly through discord.

Thanks for the ticket suggestions. That's really helpful :)

Fix is merged, closing.
Thanks @asn-d6

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dalembraun picture dalembraun  路  9Comments

scrubbless picture scrubbless  路  4Comments

MatthieuLPro picture MatthieuLPro  路  6Comments

scrubbless picture scrubbless  路  3Comments

EMILIPULIDO picture EMILIPULIDO  路  8Comments