-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Using zone as firewood source while handling item activity #33372
Using zone as firewood source while handling item activity #33372
Conversation
src/activity_item_handling.cpp
Outdated
if( g->m.has_items( tile ) && | ||
g->m.accessible_items( tile ) && | ||
g->m.clear_path( center, tile, PICKUP_RANGE, 1, 100 ) ) { | ||
best_tile = tile; |
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.
You can return directly from here.
Btw. best_tile
is not really fitting anyway as it is not comparing different suitable tiles, it only returns the first encountered suitable tile.
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.
Indeed, you are right.
But, excuse my C++ newbe ignorance, but then how do I return en empty cata::optional<tripoint>
at the end of the function without declaring a variable of that type first ?
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.
CLIon is suggesting me to simply return cata::optional<tripoint>();
😯
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.
Or simply return {};
, which returns a default-constructed object.
I don't think it's appropriate to use the existing |
The way you've written this, it looks like the old way no longer works. If that's the case then references to it should certainly be removed (at least it should no longer appear in the construction menu to confuse players). Alternatively, you could add the new system while also retaining the old system, to allow a transition period. |
Yeah! I had the same thought while playing a little with this feature. I accidentally burn some plank I did not wanted to burn. I will do this change.
Indeed, I replaced the "search".
But should we retaining the old system ? This will not be hard at all to leave everything from the old system in place. |
My last push implements @jbytheway ideas:
|
I believe that since that documentation for the firewood source was written, things have changed such that the waiting activity now does trigger fire maintenance. See #31364. So that aspect of your description should probably be changed. |
@jbytheway you are right, waiting does trigger the refuel fire code. I changed the zone description accordingly.
Since I do not want to mix too many thing in this PR, I did NOT change the |
…y of marking firewood source still usable
…r the refuel fire code
c7dc4cd
to
105a601
Compare
…en#33372) * initial impl of using zone as firewood source while handling item activity * fix my C++ newbeness * astyle * new SOURCE_FIREWOOD zone (named "Source: Firewood") + make the old way of marking firewood source still usable * SOURCE_FIREWOOD zone description now state that waiting *does* trigger the refuel fire code
Summary
SUMMARY: Features "Use zone for designating a firewood source"
Purpose of change
I face the same problem described in issue #32979 (regarding the requirement of light). And I liked the proposal of using zone instead to designate firewood source.
Describe the solution
While handling item activity, when trying to fuel fire (
try_fuel_fire
inactivity_item_handling.cpp
), instead of searching for a tile with a special trap id, I change the code to usezone_manager::get_near
instead, with the already definedLOOT_WOOD
zone id.Describe alternatives you've considered
I have not considered other alternative, but I am willing to.
Additional context
Its been a while since I have done C++, I may have done something terribly wrong here, I am sorry for that :)
I did not clean up references linked to the old way of doing this (ie: the trap id
tr_firewood_source
), I will do this if you like this PR.