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

Fix protoype object updates changing cached prototype #3507

Merged
merged 1 commit into from
Apr 27, 2024

Conversation

chiizujin
Copy link
Contributor

@chiizujin chiizujin commented Apr 13, 2024

Brief overview of PR changes/additions

Fixes behaviour in #3505.

This was caused by the spawned object being used as a comparison for the update directly updating the dict in the prototype cache if it found one, rather than copy of it. This resulted in the cached prototype being changed to reflect the spawned object.

Motivation for adding to Evennia

Bug fix.

Other info

Note that this does not change the repeated save request behaviour mentioned in the bug report.

Before

Starting with an object spawned from a prototype and then adding a new tag ('tag_on_object') directly to the object:

>tag test
Tags on test: 'tag_on_object', 'test' (category: from_prototype)

Add a new tag to the prototype:

Actions: examine <num> | remove <num>
Back (attrs) | Forward (locks) | Index | Validate prototype | Quit

 1: new_tag          

Save and update spawned objects, then say "no" at the second save prompt:

Do you want to save/overwrite the existing prototype 'test'?
(...)
>n

View tags on prototype, without exiting the wizard:

Actions: examine <num> | remove <num>
Back (attrs) | Forward (locks) | Index | Validate prototype | Quit

 1: new_tag          

Reload the prototype while still in the wizard. The prototype in the wizard now has the tags that the spawned object had before it was updated:

Actions: examine <num> | remove <num>
Back (attrs) | Forward (locks) | Index | Validate prototype | Quit

 1: tag_on_object      
 2: test               

Note that the database has the correct tags. so quitting the wizard restarting the server and reloading the template will result in the correct tags.

The spawned object has the new tag:

>tag test
Tags on test: 'new_tag', 'tag_on_object', 'test' (category: from_prototype)

After

Starting from the same point as the start of the "before" test:

>tag test
Tags on test: 'tag_on_object', 'test' (category: from_prototype)

Go through the same steps to add a new tag, save, update, and say "no" at the second save prompt. Look at the tags on the prototype, without leaving the wizard:

Actions: examine <num> | remove <num>
Back (attrs) | Forward (locks) | Index | Validate prototype | Quit

 1: new_tag     

Reload the prototype while staying in the wizard and check the tags:

Actions: examine <num> | remove <num>
Back (attrs) | Forward (locks) | Index | Validate prototype | Quit

 1: new_tag          

The object has the new tag:

tag test
Tags on test: 'new_tag', 'tag_on_object', 'test' (category: from_prototype)

@chiizujin chiizujin changed the title Fix protoype object updates changing cached prototype. Resolves #3505 Fix protoype object updates changing cached prototype Apr 13, 2024
Copy link
Member

@Griatch Griatch left a comment

Choose a reason for hiding this comment

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

Nice investigation and good job finding the fix!

@Griatch Griatch merged commit 964e2af into evennia:main Apr 27, 2024
7 of 10 checks passed
@chiizujin chiizujin deleted the prototype_cache branch April 28, 2024 01:50
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.

None yet

2 participants