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

Ownership by dead actors is not cleared from picked items (Bug #4328) #1617

Merged
3 commits merged into from
Mar 7, 2018

Conversation

Capostrophic
Copy link
Collaborator

@Capostrophic Capostrophic commented Feb 26, 2018

Tracker

Prevent mStolenItems for specific item ID from increasing in this case.

Note: the stolen tag is not cleared from such items upon loading a saved game.

@akortunov
Copy link
Collaborator

akortunov commented Feb 27, 2018

I wonder how the game supposed to behave if the owner is not unique NPC, e.g. guard.

@ghost
Copy link

ghost commented Feb 27, 2018

I think you forgot to check if victimRef was not found, which because you set activeOnly could easily happen if they moved to another cell (but I'm not saying activeOnly should be false because that search is a whole lot more expensive). Also there are items in the starting cell owned by 'a shady smuggler' that don't actually exist.

akortunov's question is interesting, sure.

@Capostrophic
Copy link
Collaborator Author

Capostrophic commented Feb 28, 2018

Setting activeOnly to true was an accident... but I guess the owner of an item the player tries to steal is in the same cell as that item or in an adjacent cell in case of, say, towns in most cases.
As it works now, the engine will essentially try to find a dead reference of the unique owner in active cells or grab a random (for all intents and purposes) reference of not unique owner and learn if it's dead and increment the stolen items counter otherwise, if I understand what am I doing. I don't

@ghost
Copy link

ghost commented Feb 28, 2018

That if test bothers me a bit. Isn't it the same as empty || !dead ?

@ghost
Copy link

ghost commented Mar 2, 2018

A nuance I didn't mention: for performance reasons, OpenMW will always consider owners that don't have a dead reference in the cells that were loaded at the time you were taking an item alive for the purpose of increasing the stolen item counter - this includes NPCs like "a shady smuggler" which don't have a reference in the world at all, and regular NPCs that happened not to be loaded while you were taking the item.

Coming to think of it, this includes actors which were cleared during corpse clearing.

I'm not sure if that's so. Did you test? Deleted or 'cleared' objects can still be accessible. (Yes, very unintuitive, but that was required to make a broken-ass script for the gateway ghost quest work..)

@Capostrophic
Copy link
Collaborator Author

Capostrophic commented Mar 2, 2018

Nope, I just took a wild guess, went through the corpse clearing code and it, um, looked that way. Well, good to know.
I'll test this right now to be safe, though.

@Capostrophic
Copy link
Collaborator Author

Capostrophic commented Mar 2, 2018

Just tested it. Unless I'm imagining things, it appears not to work when an item is stolen from a container owned by a dead NPC lying nearby, but it works fine otherwise, even if the corpse is disposed.
...That's because I used item.getCellRef().getOwner() instead of ownerCellRef->getOwner(). Silly me.
The "show owned" tint is always applied if an item with an owner is taken. Should I change its behavior?

Edit: phew, now everything works just right.

@ghost
Copy link

ghost commented Mar 3, 2018

I think the intention of show owned is to indicate whether taking is a crime, which it still is with this PR if I understood right. So we don't need to change anything else.

@ghost
Copy link

ghost commented Mar 3, 2018

Could you rebase the commit that doesn't build (empty/isEmpty), and maybe a few others while already at it.

@Capostrophic
Copy link
Collaborator Author

Done.

@ghost ghost merged commit d371beb into OpenMW:master Mar 7, 2018
ghost pushed a commit that referenced this pull request Mar 7, 2018
@Capostrophic Capostrophic deleted the ownership branch March 9, 2018 12:47
Capostrophic added a commit to Capostrophic/openmw that referenced this pull request Aug 29, 2018
Capostrophic added a commit to Capostrophic/openmw that referenced this pull request Sep 3, 2018
Capostrophic added a commit to Capostrophic/openmw that referenced this pull request Sep 11, 2018
Capostrophic added a commit to Capostrophic/openmw that referenced this pull request Sep 11, 2018
Capostrophic added a commit to Capostrophic/openmw that referenced this pull request Sep 14, 2018
Capostrophic added a commit to Capostrophic/openmw that referenced this pull request Sep 14, 2018
This pull request was closed.
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