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

game: refactor handle_liquids() #24684

Merged
merged 2 commits into from
Aug 8, 2018

Conversation

mlangsdorf
Copy link
Contributor

split the logic of handle_liquids() into two functions:

  • get_liquid_target() handles the menu items to get the target of
    the liquid transfer and populated a liquid_dest_opt structure
  • perform_liquid_transfer() handles transfering liquids from the
    source to the target, according to the liquid_dest_opt structure

handle_liquids() is now a wrapper for the new functions.

in the future, this will make it easier to write activity handlers
that need special cases for handling liquid transfers, because
they can call get_liquid_target() without commiting to
perform_liquid_transfer(). I intend to use this functionality in
a future PR that will turn milking into a player_activity.

Fixes #24679

@DracoGriffin DracoGriffin added [C++] Changes (can be) made in C++. Previously named `Code` <Bugfix> This is a fix for a bug (or closes open issue) Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style labels Aug 7, 2018
Copy link
Contributor

@DracoGriffin DracoGriffin left a comment

Choose a reason for hiding this comment

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

Compiled and tested successfully. Tried milking cows, siphoning gas from vehicle and messing around with standing tanks/kegs. Did not review code.

The only issue I observed is this:
weirdmessagelog_kegfilling

The filling a keg and creating a an activity aren't present in current experimentals. I'm assuming this is temporarily intended?

src/game.cpp Outdated
break;
case LD_KEG:
case LD_GROUND:
add_msg( "filling a %s", target.dest_opt == LD_KEG ? "keg" : "ground" );
Copy link
Contributor

Choose a reason for hiding this comment

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

If intended to remain, filling would need capitalization.

src/game.cpp Outdated
case LD_GROUND:
add_msg( "filling a %s", target.dest_opt == LD_KEG ? "keg" : "ground" );
if( create_activity() ) {
add_msg( "created a an activity" );
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is intended to remain, will need a new context as it is a bit abrupt and strange.

@DracoGriffin DracoGriffin added the (P2 - High) High priority (for ex. important bugfixes) label Aug 7, 2018
@mlangsdorf mlangsdorf force-pushed the refactor_handle_liquids branch from 0a63e92 to 0c9a884 Compare August 8, 2018 00:01
split the logic of handle_liquids() into two functions:
* get_liquid_target() handles the menu items to get the target of
  the liquid transfer and populated a liquid_dest_opt structure
* perform_liquid_transfer() handles transfering liquids from the
  source to the target, according to the liquid_dest_opt structure

handle_liquids() is now a wrapper for the new functions.

in the future, this will make it easier to write activity handlers
that need special cases for handling liquid transfers, because
they can call get_liquid_target() without commiting to
perform_liquid_transfer(). I intend to use this functionality in
a future PR that will turn milking into a player_activity.
@mlangsdorf mlangsdorf force-pushed the refactor_handle_liquids branch from 0c9a884 to 2161474 Compare August 8, 2018 00:57
@mlangsdorf
Copy link
Contributor Author

Cleaned up the merge issue.

@ZhilkinSerg ZhilkinSerg merged commit 5da42a0 into CleverRaven:master Aug 8, 2018
@mlangsdorf mlangsdorf deleted the refactor_handle_liquids branch August 8, 2018 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style (P2 - High) High priority (for ex. important bugfixes)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants