-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Control laptop activity enhancement #28465
Control laptop activity enhancement #28465
Conversation
Serialize weak_ptr<monster> as a temporary critter tracker index Serialize a monster reference as an object indicating ref type Use position rather than temp_id to serialize a monster reference serialize weak_ptr<monster> using location data
Seems to be occurring here |
I'll look into it. I'm currently not able to reproduce. Do you have a save-game I could try? Did you do anything special to trigger it? I just now started a new random game, set skills to 10, wished for a laptop+batteries, spawned a chicken walker, and was able to hack it. My local build shows 0.C-37641-g262644def3-dirty (the dirty is only because astyle thinks boots.json is checked in with invalid style, so I had to run astyle before I could build). |
All I did was spawn, give myself a tent to hide in, spawn a chicken walker nearby and try to hack it. |
I develop on macOS. I just tried it on linux, and I can reproduce your crash there. I'll investigate. |
I'm leaning toward compiler bug on this one. This is a very very stripped-down model of the line in question, with abstracted versions of the non_dead_range business. https://wandbox.org/permlink/jSGfrHzmzFs4tmd7 It assert fails in gcc 7.3 (default on Ubuntu Bionic), but not in 8.2 or later. It also works at least as far back as clang 6.0.1. From everything I've read, this should work due to lifetime extension rules. But, clearly it doesn't in some cases in practice. Anyhow, the following works as a workaround:
I'm accessing the I could also do something like (untested):
Preferences? |
I just discovered |
In addition to breaking encapsulation, the old way crashed in gcc 7.3.
* origin/development: Control laptop activity enhancement (#28465)
Summary
SUMMARY: Infrastructure "Allow a player_activity to refer to specific monster(s)"
SUMMARY: Content "Control laptop activity now keeps track of target"
Purpose of change
When #27816 turned hacking into an activity (yay!), it necessitated choosing a target at the end, since player_activity can't reference a monster. Now it can. The player selects a target, just as was the case prior to e089877, but this is now stored in the player_activity.
Describe the solution
Adds a list of monsters to player_activity, allowing activities to refer to monsters, at least as long as they continue to exist.
player_activity
gains a membermonsters
, stored as avector<weak_ptr<monster>>
.Because
monster
s don't have unique IDs, serialization/deserialization is added forweak_ptr<monster>
using the last known location to refer to the monster. To allow for a future possible transition to a different reference mechanism, the location is serialized as a json object{"monster_at": [x, y, z] }
instead of just the raw integer.Describe alternatives you've considered
player
does have a unique ID. This could in principle be hoisted into theCreature
superclass. If that happens, the serialization can be changed to emit{ "unique_id": <integer> }
instead.Additional context
This supersedes pull request #27954.