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

adapted to enum value name change #1564

Merged
merged 6 commits into from
Aug 6, 2020
Merged

Conversation

PatrikLundell
Copy link
Contributor

@PatrikLundell PatrikLundell commented May 2, 2020

@BenLubar : This PR is dependent upon PR DFHack/df-structures#400, and so needs linking.

Edit: Ignore the below. Attribute linking won't help in this case.
(Also, it would be better to make use of the new attributes rather than to use a switch statement, with the added benefit that no change of the code would be required when the last(?) enum value is identified, but I don't know how to get at them from C++, and this is probably as good a way to ask as any).

Edit: fix #1479

@lethosor
Copy link
Member

lethosor commented May 2, 2020

For reference, these macros would help with accessing enum attributes in C++. But you are correct that the attribute of identity_type doesn't map to the cases here.

@PatrikLundell
Copy link
Contributor Author

Thanks. Useful info.

@PatrikLundell
Copy link
Contributor Author

Since the getplants code relies on structures mapped in the same pending structures PR as the Units one does, both changes were crammed into the same PR.

The getplants code makes use of the logic provided by @quietust to determine the random actual growth period, although that hasn't been tested (would require an embark in the right time window and locating suitable plants within it, which is possible to do). The check to not designate plants that have already been picked was tested against horned melons in season. Running the command after all designations had been cleared designate 38 plants. Clearing the designations and manually designate one of them for picking and running the command once that plant had been picked resulted in 37 designation (and not the picked plant).

// Formula for determination of the variance in plant growth maturation time, determined via disassembly.
// The x and y parameters are in tiles relative to the embark.
bool ripe(int32_t x, int32_t y, int32_t start, int32_t end) {
int32_t time = ((435522653 - (((y + 3) * x + 5) * ((y + 7) * y * 400181475 + 289700012))) & 0x3FFFFFFF) % 2000 + (*cur_year_tick % 403200);
Copy link
Member

Choose a reason for hiding this comment

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

The % 403200 should be applied after adding cur_year_tick to the delta value (since cur_year_tick is already guaranteed to be within that range).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. It looked odd.

lethosor added a commit to PatrikLundell/dfhack that referenced this pull request Aug 6, 2020
@lethosor lethosor merged commit d3fc691 into DFHack:develop Aug 6, 2020
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.

getplants will mark plants for harvest that don't have usable growths
3 participants