-
Notifications
You must be signed in to change notification settings - Fork 480
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
Conversation
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. |
Thanks. Useful info. |
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). |
plugins/getplants.cpp
Outdated
// 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); |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. It looked odd.
@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