Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign up[RDY] Vehicle mounted washing machine #21650
Conversation
Night-Pryanik
added some commits
Aug 17, 2017
This comment has been minimized.
This comment has been minimized.
|
Gorgon says that something is not good with astyle:
|
This comment has been minimized.
This comment has been minimized.
|
Also it ironically states |
ZhilkinSerg
reviewed
Aug 17, 2017
| cur_veh->parts[part].enabled = false; | ||
| counter = 0; | ||
| } else if( calendar::once_every( MINUTES( 15 ) ) ) { | ||
| add_msg( _("It should take %d minutes to finish washing."), time_left / MINUTES( 1 ) + 1 ); |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Statics are unacceptable here.
This only gets worse as more machines are in the bubble. The easiest way to fix it would be to have washing machine note in its item ( |
This comment has been minimized.
This comment has been minimized.
Umm, need some help on this. |
Coolthulhu
reviewed
Aug 17, 2017
| @@ -83,6 +83,9 @@ interact_results interact_with_vehicle( vehicle *veh, const tripoint &pos, | |||
| const bool can_be_folded = veh->is_foldable(); | |||
| const bool is_convertible = ( veh->tags.count( "convertible" ) > 0 ); | |||
| const bool remotely_controlled = g->remoteveh() == veh; | |||
| const bool has_washmachine = ( veh->part_with_feature( veh_root_part, "WASHING_MACHINE" ) >= 0 ); | |||
| bool working = false; | |||
This comment has been minimized.
This comment has been minimized.
Coolthulhu
Aug 17, 2017
Contributor
washing_machine_on or something like that. Ambiguous variable names make code harder to read.
This comment has been minimized.
This comment has been minimized.
Night-Pryanik
Aug 18, 2017
Author
Member
Well, I'm not against renaming, but the name has_washmachine was taken by an analogy of has_kitchen, has_weldrig and so on just above.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Coolthulhu
reviewed
Aug 17, 2017
| @@ -83,6 +83,9 @@ interact_results interact_with_vehicle( vehicle *veh, const tripoint &pos, | |||
| const bool can_be_folded = veh->is_foldable(); | |||
| const bool is_convertible = ( veh->tags.count( "convertible" ) > 0 ); | |||
| const bool remotely_controlled = g->remoteveh() == veh; | |||
| const bool has_washmachine = ( veh->part_with_feature( veh_root_part, "WASHING_MACHINE" ) >= 0 ); | |||
| bool working = false; | |||
| bool detergent_is_enough = false; | |||
This comment has been minimized.
This comment has been minimized.
Coolthulhu
Aug 17, 2017
Contributor
Move this variable into the case.
You can have variable declarations inside a case if you wrap the block in braces, like this:
switch( x ) {
case y: {
bool is_happening = true;
if( is_happening ) add_msg( m_good, "It's happening!" );
}
}
This comment has been minimized.
This comment has been minimized.
Night-Pryanik
Aug 18, 2017
Author
Member
Move this variable into the case.
You mean move bool detergent_is_enough = false into the USE_WASHMACHINE case?
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Night-Pryanik
Aug 18, 2017
Author
Member
Moving bool detergent_is_enough = false into the USE_WASHMACHINE case generates crosses initialization of 'bool detergent_is_enough' error.
This comment has been minimized.
This comment has been minimized.
Coolthulhu
Aug 18, 2017
Contributor
As I said: you need an extra pair of braces inside the case.
Look at my example above.
This comment has been minimized.
This comment has been minimized.
Coolthulhu
reviewed
Aug 17, 2017
| veh->tags.erase( "manual_stop" ); | ||
| add_msg( m_neutral, _( "You close the lid of the washing machine, and turn it on. The washing machine is being filled with soapy water." ) ); | ||
| } | ||
| } |
This comment has been minimized.
This comment has been minimized.
Coolthulhu
Aug 17, 2017
Contributor
Would be better if you moved the whole block to interact_with_vehicle in pickup.cpp.
Washing machine should not require you to go to vehicle controls to activate it, but rather should be interacted with directly.
This comment has been minimized.
This comment has been minimized.
Night-Pryanik
Aug 18, 2017
Author
Member
But it is already in interact_with_vehicle in pickup.cpp. And it indeed working by interacting with it directly, not through controls.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This isn't exactly easy. Vehicle parts aren't easy to work with. I think I have an easier idea, though:
That way it would work similarly to furniture charcoal kiln. |
Night-Pryanik
added some commits
Aug 18, 2017
This comment has been minimized.
This comment has been minimized.
|
I was able to get rid of the static counters. |
This comment has been minimized.
This comment has been minimized.
|
There are still some issues:
EDIT: Also check gorgon/travis complaints. |
Night-Pryanik
added some commits
Aug 18, 2017
This comment has been minimized.
This comment has been minimized.
Fixed in abaca20.
Fixed in da82944.
Fixed in 1b09a2d. |
This comment has been minimized.
This comment has been minimized.
|
I just can't to figure out what are the problems with astyle in |
Night-Pryanik
added some commits
Aug 18, 2017
This comment has been minimized.
This comment has been minimized.
|
It would be easiest if you just downloaded the astyle binary version 2.05.1 and ran it (from command line), like this:
Astyle sometimes has really stupid requirements that you won't figure out yourself. For example, it may require very strict line breaks that look ugly, or weird alignment. |
Coolthulhu
reviewed
Aug 18, 2017
| @@ -4672,6 +4672,28 @@ static void process_vehicle_items( vehicle *cur_veh, int part ) | |||
| apply_in_fridge(n); | |||
| } | |||
| } | |||
|
|
|||
| const bool washmachine_here = cur_veh->part_flag( part, VPFLAG_WASHING_MACHINE ) && cur_veh->has_part( "WASHING_MACHINE", true ); | |||
| bool washing_machine_finished = false; | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Night-Pryanik
Aug 18, 2017
Author
Member
You mean outside of if( time_left <= 0 ) or if( finished )?
Coolthulhu
reviewed
Aug 18, 2017
| @@ -4672,6 +4672,28 @@ static void process_vehicle_items( vehicle *cur_veh, int part ) | |||
| apply_in_fridge(n); | |||
| } | |||
| } | |||
|
|
|||
| const bool washmachine_here = cur_veh->part_flag( part, VPFLAG_WASHING_MACHINE ) && cur_veh->has_part( "WASHING_MACHINE", true ); | |||
This comment has been minimized.
This comment has been minimized.
Coolthulhu
Aug 18, 2017
Contributor
This check is not correct.
Consider more than one washing machine: in this case this check is true if any of the washing machines is turned on.
The check should be:
if( cur_veh->part_flag( part, VPFLAG_WASHING_MACHINE ) && cur_veh->is_part_on( part ) ) {
This comment has been minimized.
This comment has been minimized.
Night-Pryanik
added some commits
Aug 19, 2017
codemime
reviewed
Aug 19, 2017
| bool detergent_is_enough = g->u.crafting_inventory().has_charges( "detergent", 5 ); | ||
| static const std::string filthy( "FILTHY" ); | ||
| bool filthy_items = std::any_of( veh->get_items( washing_machine_part ).begin(), | ||
| veh->get_items( washing_machine_part ).end(), |
This comment has been minimized.
This comment has been minimized.
codemime
Aug 19, 2017
Member
Though the function doesn't look expensive, it would be safer to stash the result of veh->get_items( washing_machine_part ) in a temp variable: const auto items = veh->get_items( washing_machine_part ).
This comment has been minimized.
This comment has been minimized.
Night-Pryanik
Aug 19, 2017
Author
Member
Implemented in 6114c40, but had to made it without const, as items are changed below, where we set the bday.
Night-Pryanik
added some commits
Aug 19, 2017
AMurkin
reviewed
Aug 19, 2017
| } else { | ||
| veh->parts[washing_machine_part].enabled = true; | ||
| for( auto &n : items ) { | ||
| if( filthy_items ) { |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
AMurkin
reviewed
Aug 19, 2017
| add_msg( m_bad, _( "You need 5 charges of detergent for the washing machine." ) ); | ||
| } else if( !filthy_items ) { | ||
| add_msg( m_bad, | ||
| _( "There are only non-filthy items in the washing machine. There is no need to wash them." ) ); |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Night-Pryanik
added some commits
Oct 5, 2017
Night-Pryanik
changed the title
Vehicle mounted washing machine
[RDY] Vehicle mounted washing machine
Oct 18, 2017
This comment has been minimized.
This comment has been minimized.
|
Jenkins, rebuild. |
codemime
reviewed
Dec 22, 2017
| @@ -4677,15 +4677,15 @@ static void process_vehicle_items( vehicle *cur_veh, int part ) | |||
| bool washing_machine_finished = false; | |||
| if( washmachine_here ) { | |||
| for( auto &n : cur_veh->get_items( part ) ) { | |||
| const int washing_time = MINUTES( 90 ); | |||
| const int time_left = washing_time - n.age(); | |||
| const time_duration washing_time = 2_hours; | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
ZhilkinSerg
Dec 22, 2017
Contributor
don't know how to translate 90 minutes in to new for.
90_minutes and most probably 1.5_hours will also work
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
I'm sorry for possibly being annoying, but is there something critical that blocks this from merging? |
This comment has been minimized.
This comment has been minimized.
Possibly lack of time for contributors with merge rights. |
Night-Pryanik
added some commits
Jan 24, 2018
kevingranade
approved these changes
Jan 25, 2018
| @@ -83,9 +83,13 @@ interact_results interact_with_vehicle( vehicle *veh, const tripoint &pos, | |||
| const bool can_be_folded = veh->is_foldable(); | |||
| const bool is_convertible = ( veh->tags.count( "convertible" ) > 0 ); | |||
| const bool remotely_controlled = g->remoteveh() == veh; | |||
| const int washing_machine_part = veh->part_with_feature( veh_root_part, "WASHING_MACHINE" ); | |||
| const bool has_washmachine = washing_machine_part >= 0; | |||
| bool washing_machine_on = veh->parts[washing_machine_part].enabled; | |||
This comment has been minimized.
This comment has been minimized.
kevingranade
Jan 25, 2018
Member
Segfault on this line, you cannot dereference an array with the -1 returned by veh->part_with_feature( veh_root_part, "WASHING_MACHINE" ); if there is no washing machine in the vehicle.
This would work:
bool washing_machine_on = ( washing_machine_part == -1 ) ? false : veh->parts[washing_machine_part].enabled;
This comment has been minimized.
This comment has been minimized.
kevingranade
Jan 25, 2018
Member
I fixed this during the merge, looks like it works flawlessly otherwise
This comment has been minimized.
This comment has been minimized.
Night-Pryanik
Jan 25, 2018
Author
Member
Thanks!
Though I'd like to know at which moment does it segfault?
Night-Pryanik commentedAug 17, 2017
•
edited