Skip to content

Added null srcImage check to the other DrawTexture overload.#2785

Merged
KABoissonneault merged 2 commits into
Interkarma:masterfrom
RedRoryOTheGlen:CustomCloakFix
Apr 12, 2026
Merged

Added null srcImage check to the other DrawTexture overload.#2785
KABoissonneault merged 2 commits into
Interkarma:masterfrom
RedRoryOTheGlen:CustomCloakFix

Conversation

@RedRoryOTheGlen

Copy link
Copy Markdown
Contributor

Extends #2757 to prevent the exception in #2740 from happening by calling the overload.


void DrawTexture(ImageData srcImage, DaggerfallUnityItem item = null)
{
if (srcImage.texture == null)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question, why does this not check srcImage and srcImage.offset for null instead?

@RedRoryOTheGlen RedRoryOTheGlen Apr 11, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough about the first point, but the second point is irrelevant. The convention that matters here is checking for null before access. The third point is fine, you can check the texture for null even if it's not directly accessed, but for safety I'd wanna make sure any field that can be null is checked before access.
In short, you can have if(srcImage.texture == null || srcImage.offset == null)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood. I'll revise it as directed.

@KABoissonneault KABoissonneault merged commit d65947a into Interkarma:master Apr 12, 2026
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

Successfully merging this pull request may close these issues.

2 participants