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

Resolve aliases in cost calculation #175

Merged
merged 1 commit into from Feb 10, 2021
Merged

Resolve aliases in cost calculation #175

merged 1 commit into from Feb 10, 2021

Conversation

Caellian
Copy link
Contributor

Fixes #174.

If stairs from stairs mod were crafted before moreblocks was enabled, the old (now aliased) stairs variant is kept in inventory. If the player tried to recycle that stair variant, inv:contains_item("output", stackname) would return true as contains_item resolves alias names, but circular_saw:get_cost would return nil as it's expecting exact stackname matches which would later crash due to nil arithmetic.

This PR fixes this issue by resolving alias using minetest.registered_aliases table.
circular_saw:get_cost should work now in every scenario where inv:contains_item("output", stackname) returns true.

@Caellian Caellian changed the title Resolve aliases in cost calculation. Resolve aliases in cost calculation Feb 10, 2021
@Calinou Calinou added the Bug label Feb 10, 2021
@Calinou Calinou merged commit b39bb31 into minetest-mods:master Feb 10, 2021
mckaygerhard added a commit to minenux/minetest-mod-moreblocks that referenced this pull request Feb 19, 2022
* If stairs from stairs mod were crafted before moreblocks was enabled,
  the old (now aliased) stairs variant is kept in inventory. If the player
  tried to recycle that stair variant, `inv:contains_item("output", stackname)`
  would return true as `contains_item` resolves alias names,
  but `circular_saw:get_cost` would return nil as it's expecting exact
  `stackname` matches which would later crash due to nil arithmetic.
  This PR fixes this issue by resolving alias using `minetest.registered_aliases` table.
  `circular_saw:get_cost` should work now in every scenario where
  `inv:contains_item("output", stackname)` returns true.
* backported from minetest-mods#175
* fixes minetest-mods#174
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash when recycling default stairs
2 participants