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

Support item_locations on NPCs #35538

Merged
merged 2 commits into from
Nov 17, 2019

Conversation

ifreund
Copy link
Contributor

@ifreund ifreund commented Nov 15, 2019

Summary

SUMMARY: Bugfixes "Support item_locations on NPCs"

Purpose of change

Fixes #35352
This commit fixes serialization of ACT_READ for NPCs

Describe the solution

Add a new character_id field to item_on_person for serialization
Lazily turn the character_id into a Character pointer on first access
Also add a sanity check in the finish function of ACT_READ to prevent
a crash if something goes wrong

Describe alternatives you've considered

Lazy loading of the Character pointers seemed like the way to go here, though if it turns out there's a way to guarantee all Characters are loaded before the item_locations, that would be preferable

Testing

Tested serialization/deserialization of NPCs while reading, no more crashes or debug messages!

This commit fixes serialization of ACT_READ for NPCs

Add a new `character_id` field to `item_on_person` for serialization
Lazily turn the character_id into a Character pointer on first access
Also add a sainity check in the finish function of ACT_READ to prevent
a crash if something goes wrong
@ifreund ifreund added NPC / Factions NPCs, AI, Speech, Factions, Ownership [C++] Changes (can be) made in C++. Previously named `Code` Items / Item Actions / Item Qualities Items and how they work and interact <Bugfix> This is a fix for a bug (or closes open issue) labels Nov 15, 2019
@ifreund
Copy link
Contributor Author

ifreund commented Nov 15, 2019

Made things a little more safe to avoid crashes and hopefully appease clang tidy. It doesn't feel super clean, so any suggestions on how to make the code nicer are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Items / Item Actions / Item Qualities Items and how they work and interact NPC / Factions NPCs, AI, Speech, Factions, Ownership
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NPC reading activity segfault
2 participants