-
Notifications
You must be signed in to change notification settings - Fork 290
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
MVP of grid furniture examine action #1613
MVP of grid furniture examine action #1613
Conversation
efd77b4
to
d1136d2
Compare
d1136d2
to
6de118d
Compare
// | ||
// This relies on fact that repairing with real tools | ||
// never use `player_activity::coords` | ||
// and use `player::activity::values` with only one item. |
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.
Check out activity_actor_definitions.h
for something better than the old, ugly coords/values vector hackery.
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.
Yes, this is the plan.
I would do that in further work on that issue.
#1612
I just want to split work into chunks to make it easier.
src/activity_handlers.cpp
Outdated
} | ||
} | ||
|
||
static void return_unused_charges( hack_type_t hack_type, item &tool, const tripoint &position ) { |
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.
Discharge/recharge "cycle" can change the way energy is distributed.
Would be better to note how much energy was in the grid at start, then consume the difference later.
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.
I reimplemented original algorithm. Probably, your version is better and more consistent with one time usages on examine action.
Would do it little later in that PR.
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.
Fixed.
4c8fd40
to
f6ac3b9
Compare
@Coolthulhu This PR is finished and works stable when I playing. |
const vehicle &veh, | ||
int interact_part_idx ) | ||
{ | ||
if( activity.id() != ACT_REPAIR_ITEM ) { |
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.
Does it happen? Is it expected to happen?
Needs a comment documenting when is this desirable or a debugmsg describing that an undesirable and unexpected event happened.
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.
It doesn't happen but allowed.
I moved this code from vehicle.cpp to make hack code more encapsulated in one place so it would be easier to remove later.
src/activity_handlers.cpp
Outdated
raii_fake_tool( const raii_fake_tool & ) = delete; | ||
raii_fake_tool( raii_fake_tool && ) = delete; | ||
raii_fake_tool( const player_activity &activity ): hack_type( get_hack_type( activity ) ) { | ||
if( !hack_type ) { |
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.
Expected or unexpected? Needs documentation or debugmsg.
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.
Was needed to make RAII easier. Removed now.
src/activity_handlers.cpp
Outdated
item &get_fake_tool() { | ||
return fake_tool; | ||
} | ||
~raii_fake_tool() { |
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.
RAII sounds unusual and fragile here. Resource consumption should be made explicit, even if it makes it more verbose.
RAII can print debugmsgs on skipped discharge or discharge being called twice.
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.
Well, old code used RAII here, I just didn't want to change it much.
Removed RAII.
Implementation parts: * Added new examine action `use_furn_fake_item` which allows players to activate crafting pseudo items from furniture. * Added `use_furn_fake_item` for grid welder and grid soldering iron. * Copied usages from soldering iron and welder to their fake counterparts. * Rewritten and generalized vehicle welding usage hack to use furniture too. * Little changes in tests. * Added TODOs for further improvements. Testings: * One time usages tested by placing soldering iron, spawning nurse, getting bleeding and cauterizing. * Repair activity changes tested using: - Repair items using spawned welding cart - Try to repair items using spawned welding cart without charges - Repair items using grid soldering iron and grid welder - Try to repair items using grid soldering iron without power in grid - Repair items using soldering iron and tailor kit in inventory - Repair items using soldering iron and tailor kit standing in nearby tile * Watched variable changes during all manual testing using debugger. Additional context: See cataclysmbnteam#1612
f6ac3b9
to
8ffaa86
Compare
@Coolthulhu Removed usage of RAII and added comments where requested. |
Alright, looks good on paper and I didn't manage to get it to break in manual testing. |
Well, I played with this patch 10 days and didn't got any issues yet. Now I would begin |
Summary
SUMMARY: Features "Allow use grid powered welders and soldering irons by [e]xamining"
Purpose of change
#1612
Grid powered furniture should be usable by examining it or it would be worse than vehicle powered ones.
Describe the solution
use_furn_fake_item
which allows players to activate crafting pseudo items from furniture.use_furn_fake_item
for grid welder and grid soldering iron.Describe alternatives you've considered
Testing
Additional context
See #1612