mcl_inventory: Remove _mcl_autogroup dependency from mcl_inventory #76

Merged
cora merged 2 commits from fix_inventory_depends into master 2021-06-25 17:25:46 +02:00
Owner
Problem

TRACKING ISSUE: #67

mcl_inventory has a dependency on _mcl_autogroup which should be avoided for all mods in Mineclonia. It uses this to compute item categories for creative inventory.

Solution

This is solved by moving the code into minetest.register_on_mods_loaded.

Details

We cannot simply remove the _mcl_autogroup dependency because the code needs to be executed after all items have been registered.

Testing Steps
The inventories does not change
  1. Go into creative mode
  2. Check that the creative inventory has the expected number of items for each of the categories:
    • Building blocks: 8 pages, 14 items on last page
    • Decoration blocks: 5 pages, 44 items on last page
    • Redstone: 2 pages, 11 items on last page
    • Transportation: 1 page, 16 items on last page
    • Brewing: 4 pages, 2 items on last page
    • Miscellaneous: 1 page, 19 items on last page
    • Foodstuffs: 1 page, 38 items on page
    • Tools: 1 page, 36 items on last page
    • Combat: 2 pages, 37 items on last page
    • Mobs: 2 pages, 1 item on last page
    • Materials: 2 pages, 13 items on last page
_mcl_autogroup is loaded as the last mod
  1. Switch to master branch using git checkout master
  2. Run minetest -v |& grep Mod | grep loaded on the master branch
  3. Verify that _mcl_autogroup is not loaded last
  4. Switch to the PR branch using git checkout fix_inventory_depends
  5. Run minetest -v |& grep Mod | grep loaded on the master branch
  6. Verify that _mcl_autogroup is loaded last
##### Problem TRACKING ISSUE: #67 `mcl_inventory` has a dependency on `_mcl_autogroup` which should be avoided for all mods in Mineclonia. It uses this to compute item categories for creative inventory. ##### Solution This is solved by moving the code into `minetest.register_on_mods_loaded`. ##### Details We cannot simply remove the `_mcl_autogroup` dependency because the code needs to be executed after all items have been registered. ##### Testing Steps ###### The inventories does not change 1. Go into creative mode 2. Check that the creative inventory has the expected number of items for each of the categories: - Building blocks: 8 pages, 14 items on last page - Decoration blocks: 5 pages, 44 items on last page - Redstone: 2 pages, 11 items on last page - Transportation: 1 page, 16 items on last page - Brewing: 4 pages, 2 items on last page - Miscellaneous: 1 page, 19 items on last page - Foodstuffs: 1 page, 38 items on page - Tools: 1 page, 36 items on last page - Combat: 2 pages, 37 items on last page - Mobs: 2 pages, 1 item on last page - Materials: 2 pages, 13 items on last page ###### `_mcl_autogroup` is loaded as the last mod 1. Switch to master branch using `git checkout master` 2. Run `minetest -v |& grep Mod | grep loaded` on the master branch 3. Verify that `_mcl_autogroup` is not loaded last 4. Switch to the PR branch using `git checkout fix_inventory_depends` 5. Run `minetest -v |& grep Mod | grep loaded` on the master branch 6. Verify that `_mcl_autogroup` is loaded last
ryvnf added 1 commit 2021-05-23 20:51:15 +02:00
4b4d40f158 Use register_on_mods_loaded in mcl_inventory
This removes the need to include _mcl_autogroup as a dependency for
mcl_inventory (which should be avoided) and decreases the likelihood
that the code used for populating item tables is executed before all
other mods are loaded.
ryvnf added the
code quality
label 2021-05-23 20:54:01 +02:00
ryvnf changed title from mcl_inventory: Use register_on_mods_loaded in mcl_inventory to mcl_inventory: Remove mcl_autogroup dependency from mcl_inventory 2021-05-23 22:59:05 +02:00
ryvnf changed title from mcl_inventory: Remove mcl_autogroup dependency from mcl_inventory to mcl_inventory: Remove _mcl_autogroup dependency from mcl_inventory 2021-05-23 22:59:12 +02:00
ryvnf requested review from Members 2021-06-19 19:20:47 +02:00
Author
Owner

Can this PR get some love?

Can this PR get some love?
Owner

Can this PR get some love?

Sorry for the delay.

How does this PR affect survival mode?

> Can this PR get some love? Sorry for the delay. How does this PR affect survival mode?
Owner

@ryvnf would this change affect the availability of items from third party mods in the creative inventory?

@ryvnf would this change affect the availability of items from third party mods in the creative inventory?
Author
Owner

How does this PR affect survival mode?

It should not have any effect.

@ryvnf would this change affect the availability of items from third party mods in the creative inventory?

No.

> How does this PR affect survival mode? It should not have any effect. > @ryvnf would this change affect the availability of items from third party mods in the creative inventory? No.
Owner

Thanks. Please include testing steps to verify that this does not break anything in survival or regarding third party mod items.

Thanks. Please include testing steps to verify that this does not break anything in survival or regarding third party mod items.
Author
Owner

Thanks. Please include testing steps to verify that this does not break anything in survival or regarding third party mod items.

What makes you think something could break in survival? Or regarding third party mod items?

> Thanks. Please include testing steps to verify that this does not break anything in survival or regarding third party mod items. What makes you think something could break in survival? Or regarding third party mod items?
Owner

What makes you think something could break in survival?

I remember the last time mod dependecies changed and it broke survival.

Or regarding third party mod items?

Basically, I would like to know: If a third party mod somehow manages to register items, are they listed correctly in the creative inventory?

> What makes you think something could break in survival? I remember the last time mod dependecies changed and it broke survival. > Or regarding third party mod items? Basically, I would like to know: If a third party mod somehow manages to register items, are they listed correctly in the creative inventory?
Author
Owner

I remember the last time mod dependecies changed and it broke survival.

Added steps to verify that _mcl_autogroup is the PR does what it is supposed to and _mcl_autogroup is loaded last. That also tests that it does not break digging like what happend previously.

Basically, I would like to know: If a third party mod somehow manages to register items, are they listed correctly in the creative inventory?

I will not make a test cases for this. There is no logical reason that this would break third party mods, as the minetest.register_on_mods_loaded callback will only be called after loading all mods. Internal and external mods are not loaded differently.

> I remember the last time mod dependecies changed and it broke survival. Added steps to verify that `_mcl_autogroup` is the PR does what it is supposed to and `_mcl_autogroup` is loaded last. That also tests that it does not break digging like what happend previously. > Basically, I would like to know: If a third party mod somehow manages to register items, are they listed correctly in the creative inventory? I will not make a test cases for this. There is no logical reason that this would break third party mods, as the `minetest.register_on_mods_loaded` callback will only be called after loading all mods. Internal and external mods are not loaded differently.
Owner

Run minetest |& grep Mod | grep loaded on the master branch

Which shell should be used for that? I have never seen the |& syntax before.

(I am pretty sure it is not Bourne Shell, though.)

> Run minetest |& grep Mod | grep loaded on the master branch Which shell should be used for that? I have never seen the `|&` syntax before. (I am pretty sure it is not Bourne Shell, though.)
Author
Owner

Which shell should be used for that? I have never seen the |& syntax before.

It's Bash syntax (but think it works in some other shells too). It is equivalent to 2>&1 |.

> Which shell should be used for that? I have never seen the |& syntax before. It's Bash syntax (but think it works in some other shells too). It is equivalent to `2>&1 |`.
Member

uhhm .. i just started testing this, it's probably a typo / not a big deal but please correct this in your testing steps:

Decoration blocks: 5 pages, 48 items on last page

there can not possibly be 48 items on a 9x5 page - it is 44 for me (one is missing from being full on the last page.

Tools: 1 page, 36 items on last page

This needs to be updated to 37 – the screwdrivers has been added to creative inv since (pr #99).

uhhm .. i just started testing this, it's probably a typo / not a big deal but please correct this in your testing steps: > Decoration blocks: 5 pages, 48 items on last page there can not possibly be 48 items on a 9x5 page - it is 44 for me (one is missing from being full on the last page. >Tools: 1 page, 36 items on last page This needs to be updated to 37 – the screwdrivers has been added to creative inv since (pr #99).
Member

minetest |& grep Mod | grep loaded

Also i think it needs to be minetest --verbose. It doesnt show anything for me otherwise.

> minetest |& grep Mod | grep loaded Also i think it needs to be minetest --verbose. It doesnt show anything for me otherwise.
Member

And it would also be good to specify on which exact commits something needs to be tested.

And it would also be good to specify on which exact commits something needs to be tested.
Member

otherwise all tests worked out.

otherwise all tests worked out.
Author
Owner

Also i think it needs to be minetest --verbose. It doesnt show anything for me otherwise.

Yes. Forgot to specify that. Nice you figured it out.

there can not possibly be 48 items on a 9x5 page - it is 44 for me (one is missing from being full on the last page.

Yes. I did the math wrong when counting the number of cells.

@cora Can you approve the PR so it can be merged?

> Also i think it needs to be minetest --verbose. It doesnt show anything for me otherwise. Yes. Forgot to specify that. Nice you figured it out. > there can not possibly be 48 items on a 9x5 page - it is 44 for me (one is missing from being full on the last page. Yes. I did the math wrong when counting the number of cells. @cora Can you approve the PR so it can be merged?
cora added 1 commit 2021-06-25 17:12:12 +02:00
cora approved these changes 2021-06-25 17:25:16 +02:00
cora left a comment
Member

Testing Steps
The inventories does not change

  • Switch to master branch using git checkout master
  • Run minetest -v |& grep Mod | grep loaded on the master branch
  • Verify that _mcl_autogroup is not loaded last
  • Switch to the PR branch using git checkout fix_inventory_depends
  • Run minetest -v |& grep Mod | grep loaded on the fixed branch
  • Verify that _mcl_autogroup is loaded last

I did these in both branches:

  • Go into creative mode
  • Check that the creative inventory has the expected number of items for each of the categories:-
  • Building blocks: 8 pages, 14 items on last page
  • Decoration blocks: 5 pages, 44 items on last page
  • Redstone: 2 pages, 11 items on last page
  • Transportation: 1 page, 16 items on last page
  • Brewing: 4 pages, 2 items on last page
  • Miscellaneous: 1 page, 19 items on last page
  • Foodstuffs: 1 page, 38 items on page
  • Tools: 1 page, 36 items on last page
    there's 37 items on the last page now since screwdriver was added to creative inv in pr #99
  • Combat: 2 pages, 37 items on last page
  • Mobs: 2 pages, 1 item on last page
  • Materials: 2 pages, 13 items on last page

I also verified that basic game actions still work in survival.

Since the only test that failed is the screwdriver thing and the changes seem simple enough i will approve it. Even though the testing instructions could have been clearer.

Testing Steps The inventories does not change - [x] Switch to master branch using git checkout master - [x] Run minetest -v |& grep Mod | grep loaded on the master branch - [x] Verify that _mcl_autogroup is not loaded last - [x] Switch to the PR branch using git checkout fix_inventory_depends - [x] Run minetest -v |& grep Mod | grep loaded on the fixed branch - [x] Verify that _mcl_autogroup is loaded last I did these in both branches: - [x] Go into creative mode - [x] Check that the creative inventory has the expected number of items for each of the categories:- [x] - [x] Building blocks: 8 pages, 14 items on last page - [x] Decoration blocks: 5 pages, 44 items on last page - [x] Redstone: 2 pages, 11 items on last page - [x] Transportation: 1 page, 16 items on last page - [x] Brewing: 4 pages, 2 items on last page - [x] Miscellaneous: 1 page, 19 items on last page - [x] Foodstuffs: 1 page, 38 items on page - [ ] Tools: 1 page, 36 items on last page *there's 37 items on the last page now since screwdriver was added to creative inv in pr #99* - [x] Combat: 2 pages, 37 items on last page - [x] Mobs: 2 pages, 1 item on last page - [x] Materials: 2 pages, 13 items on last page I also verified that basic game actions still work in survival. Since the only test that failed is the screwdriver thing and the changes seem simple enough i will approve it. Even though the testing instructions could have been clearer.
cora merged commit 926d5e2c37 into master 2021-06-25 17:25:46 +02:00
cora deleted branch fix_inventory_depends 2021-06-25 17:26:14 +02:00
This repo is archived. You cannot comment on pull requests.
No description provided.