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

Make farm plots re-tillable in farming extension version 2 #74344

Merged
merged 7 commits into from
Jun 15, 2024

Conversation

silvadomi
Copy link
Contributor

Summary

Bugfixes "Make farm plots re-tillable in farming extension version 2"

Purpose of change

Farming plots in the basecamp farming extension version 2 that have changed terrain (due to plants being harvested / smashed, dirt mounds being tamped, ...) could not be re-tilled through the basecamp mission menu even though there's a mission "Plow fields" intended to do this (issue #73761).

Describe the solution

This PR fixes this issue by making sure the field plots (dirt mounds) which have been built into the expansion are inserted correctly into the reference map which is used by the farming mission to check where tilling needs to be done (closes #73761).

The new code applies mapgen updates according to the upgrades which have been built into the expansion to the farming reference map.
This farming reference map is used by existing code to decide how many / where dirt mounds need to be put.

Since the new code requires access to the expansion's upgrade list, the calling interface needed to be changed slightly (make farm_action a member of basecamp class, use relative coordinates instead of absolute ones).

Describe alternatives you've considered

Missions to build farm plots, and the mission to (re-)plow fields is in a way two times the same thing. More extensive changes could try to unify that. That would go beyond what should be a direct bugfix though.

Testing

Made a field basecamp, created a farming extension version 1 in one tile, and three farming extensions version 2 (to test rotations and mirroring) in three other tiles. Built fields, planted a through seeds through the basecamp mission, went around and smashed plants / tamped dirt:

Debug silvadomi _2024-06-06T11-19-35

Coming back to the bulletin board shows the correct number of spaces to plow:

Debug silvadomi _2024-06-06T11-23-10

Performing the "Plow fields" mission in all expansions restores the reference state with dirt mounds, leaving existing plants intact:

Debug silvadomi _2024-06-06T11-25-12

Additional context

silvadomi added 3 commits June 6, 2024 09:25
Preparation to infer plots for plowing from expansion data
so that CleverRaven#73761 can be fixed.
Using dir instead of absolute overmap coordinates allows to access
available upgrades from basecamp expansions.
This is also more in line with other basecamp missions.
Necessary to get dirtmound terrain from basecamp upgrades into the
reference map that farm_action compares to.
Fixes CleverRaven#73761.
@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` Player Faction Base / Camp All about the player faction base/camp/site <Bugfix> This is a fix for a bug (or closes open issue) new contributor labels Jun 6, 2024
src/basecamp.h Outdated Show resolved Hide resolved
src/faction_camp.cpp Outdated Show resolved Hide resolved
src/faction_camp.cpp Outdated Show resolved Hide resolved
src/faction_camp.cpp Outdated Show resolved Hide resolved
@github-actions github-actions bot added the json-styled JSON lint passed, label assigned by github actions label Jun 6, 2024
Whitespace formatting corrected.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@github-actions github-actions bot added BasicBuildPassed This PR builds correctly, label assigned by github actions astyled astyled PR, label is assigned by github actions labels Jun 6, 2024
@silvadomi silvadomi marked this pull request as draft June 7, 2024 06:35
@silvadomi
Copy link
Contributor Author

I did another test with one of the basecamps where farming is provided on the central tile (modular outpost normal), and with this fix re-tilling works as expected for this.

The farming expansion version 1 still might have issues beyond the first upgrade, I'll need to look more into this.

silvadomi added 3 commits June 7, 2024 09:48
This will ensure that blueprints having multiple z-levels can be
applied correctly to the reference farm map.
Ensure that mission description is consistent with what happens in the
mission.
@silvadomi
Copy link
Contributor Author

Had to replace tinymap by smallmap so that z levels in upgrade blueprints don't give debug messages during generation of the reference json map.

Farm expansion version 1 is now also tested, and re-tilling works there as well throughout the upgrade path. I realized the upgrade path seems a bit strange though: first upgrade adds three double-rows of plots, second upgrade starts the shed and does nothing else. However, after the second upgrade there's the option to "re"-plow a fourth double-row of farm plots, which were not created by the upgrade itself. Is this as intended? I think it has to do with these lines in primitive_farm.json:

        { "chunks": [ "bc_prim_farm_long_fields" ], "x": 1, "y": 6 },
        { "chunks": [ "bc_prim_farm_long_fields" ], "x": 9, "y": 6 },
        { "chunks": [ "bc_prim_farm_long_fields" ], "x": 17, "y": 6 }

which appear in both faction_base_field_camp_farm_1 and faction_base_field_camp_farm_2. It's strange that they seem to behave differently though for the second upgrade. I think it is a separate issue though and need not be handled in this PR.

@silvadomi silvadomi marked this pull request as ready for review June 10, 2024 12:29
@github-actions github-actions bot removed the BasicBuildPassed This PR builds correctly, label assigned by github actions label Jun 10, 2024
@silvadomi
Copy link
Contributor Author

Not sure why the test is failing, but I don't think it has to do with this patch. Seems to be related to item descriptions:

(~[slow] ~[.],starting_items)=> ../tests/iteminfo_test.cpp:1304: FAILED:
(~[slow] ~[.],starting_items)=>   CHECK( item_info_str( hazmat, protection ) == "--\n" "<color_c_white>Protection for</color>: The <color_c_cyan>arms</color>. The <color_c_cyan>eyes</color>. The <color_c_cyan>feet</color>. The <color_c_cyan>hands</color>. The <color_c_cyan>head</color>. The <color_c_cyan>legs</color>. The <color_c_cyan>mouth</color>. The <color_c_cyan>torso</color>.\n" "<color_c_white>Coverage</color>: <color_c_light_blue>Outer</color>.\n" "  Default:  <color_c_yellow>100</color>\n" "<color_c_white>Protection</color>:\n" "  Bash: <color_c_yellow>4.00</color>\n" "  Cut: <color_c_yellow>4.00</color>\n" "  Ballistic: <color_c_yellow>2.00</color>\n" "  Pierce: <color_c_yellow>3.20</color>\n" "  Acid: <color_c_yellow>9.00</color>\n" "  Fire: <color_c_yellow>1.00</color>\n" "  Environmental: <color_c_yellow>20</color>\n" )
(~[slow] ~[.],starting_items)=> with expansion:
Error: (~[slow] ~[.],starting_items)=>   "--

...

(~[slow] ~[.],starting_items)=> ../tests/iteminfo_test.cpp:1328: FAILED:
(~[slow] ~[.],starting_items)=>   CHECK( item_info_str( zentai, protection ) == "--\n" "<color_c_white>Protection for</color>: The <color_c_cyan>arms</color>. The <color_c_cyan>eyes</color>. The <color_c_cyan>feet</color>. The <color_c_cyan>hands</color>. The <color_c_cyan>head</color>. The <color_c_cyan>legs</color>. The <color_c_cyan>mouth</color>. The <color_c_cyan>torso</color>.\n" "<color_c_white>Coverage</color>: <color_c_light_blue>Close to skin</color>.\n" "  Default:  <color_c_yellow>100</color>\n" "<color_c_white>Protection</color>:\n" "  Bash: <color_c_yellow>2.00</color>\n" "  Cut: <color_c_yellow>2.00</color>\n" "  Ballistic: <color_c_yellow>2.00</color>\n" "  Pierce: <color_c_yellow>50.00</color>\n" "  Acid: <color_c_yellow>9.00</color>\n" "  Fire: <color_c_yellow>2.00</color>\n" "  Environmental: <color_c_yellow>10</color>\n" )
(~[slow] ~[.],starting_items)=> with expansion:
Error: (~[slow] ~[.],starting_items)=>   "--

@silvadomi silvadomi marked this pull request as draft June 13, 2024 10:49
@silvadomi silvadomi marked this pull request as ready for review June 13, 2024 10:49
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Jun 15, 2024
@Maleclypse Maleclypse merged commit e3af8f0 into CleverRaven:master Jun 15, 2024
41 of 50 checks passed
@Maleclypse
Copy link
Member

Very cool! Thank you for your work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` json-styled JSON lint passed, label assigned by github actions new contributor Player Faction Base / Camp All about the player faction base/camp/site
Projects
None yet
Development

Successfully merging this pull request may close these issues.

disappear upturned dirt, unable to plant or plow
2 participants