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

Fix for freezing bugs - part 2 #24905

Merged
merged 8 commits into from Aug 17, 2018
Merged

Fix for freezing bugs - part 2 #24905

merged 8 commits into from Aug 17, 2018

Conversation

nexusmrsep
Copy link
Contributor

@nexusmrsep nexusmrsep commented Aug 17, 2018

Resolves #24875 (this was solved only partially)
Resolves #24893
Resolves #24898

This patch solves few problems:

  1. As play-testing by @chaosvolt showed, previous patch Fix for multiple food temperature flags #24880 removed only a part of the problem of multiple opposite flags. This patch removes the second part of the problem, and my play-testing showed that flags don't multiply when heating frozen food or crafting hot food.
  2. As @jakub-niscior noticed in Frozen liquids in containers are impossible to defrost by heating #24893, liquids in containers couldn't be reheated for use. This PR solves this problem.
  3. As @Xhuis noticed in Misspell in mushy item descriptions #24898, MUSHY and No_FROST flag feedback needed some clarification and spelling errors removal.
  4. I'm still not entirely satisfied with the speed of cooling/freezing. For now I have done two things to bring it towards sane values.
  • One is adding (cold) state to all food not only to those that have EATEN_COLD flag. This new (cold) state activates before freezing, so its equal to more time before food realy starts to freeze. Flags now go HOT-->COLD-->FROZEN. If item is not HOT, it goes from normal to COLD then to FROZEN. From FROZEN in above freezing temperatures items go to COLD, and in low temperature (between freezing and refrigerator temperature) it will stay COLD, and above that it will get back to normal.
  • Second is lowering temperature difference influence on cooling quickness and increasing temperature of defrosted food.
    There might be more tweaks in this topic, but removing bugs gets priority over that.
  1. Fixes activation of non-food comestibles (bandages, meds) on spawn. This should prevent suffix (active) from being added. It might not prevent existing (active) meds, and deactivating them via code would endanger further implementation of active meds. Rotation of items in game should fix that eventually.

@stk2008
Copy link

stk2008 commented Aug 17, 2018

Yes thank you cant wait for merge :0

src/map.cpp Outdated
@@ -4580,11 +4580,11 @@ void map::apply_in_fridge( item &it, int temp )
{
unsigned int diff_freeze = abs(temp - FREEZING_TEMPERATURE);
diff_freeze = diff_freeze < 1 ? 1 : diff_freeze;
diff_freeze = diff_freeze > 10 ? 10 : diff_freeze;
diff_freeze = diff_freeze > 5 ? 5 : diff_freeze;
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use std::min( 5, diff_freeze ) for this and std::max( 1, diff_freeze ) above. The same for diff_cold below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

would it be better performance wise?

Copy link
Contributor

Choose a reason for hiding this comment

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

Honestly, I don't know. For me it's just more clear and readable. Need consulting from more competent guys.

Copy link
Contributor

Choose a reason for hiding this comment

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

would it be better performance wise?

It won't be more slow, but much more readable.

@nexusmrsep nexusmrsep added Translation I18n Items: Food / Vitamins Comestibles and drinks <Bugfix> This is a fix for a bug (or closes open issue) labels Aug 17, 2018
src/item.cpp Outdated
if( food_item->has_flag( "NO_FREEZE" ) && !food_item->rotten() ) {
info.emplace_back( "DESCRIPTION", _( "* Quality of this food suffers when it's <neutral>frozen.</neutral>." ) );
if( food_item->has_flag( "NO_FREEZE" ) && !food_item->rotten() && !food_item->has_flag( "MUSHY" ) ) {
info.emplace_back( "DESCRIPTION", _( "* Quality of this food suffers when it's <neutral>frozen, and it becames mushy after defrosting</neutral>." ) );
Copy link

Choose a reason for hiding this comment

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

This is still an error. Here's a suggestion:
(...), and it will become mushy after thawing out.

src/map.cpp Outdated
@@ -4579,12 +4579,12 @@ void map::make_active( item_location &loc )
void map::apply_in_fridge( item &it, int temp )
{
unsigned int diff_freeze = abs(temp - FREEZING_TEMPERATURE);
diff_freeze = diff_freeze < 1 ? 1 : diff_freeze;
diff_freeze = diff_freeze > 5 ? 5 : diff_freeze;
diff_freeze = std::max( 1, diff_freeze );
Copy link
Contributor

Choose a reason for hiding this comment

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

You can't put int and unsigned int together.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just noticed that in a compiler, sorry

@ZhilkinSerg ZhilkinSerg merged commit b8ef478 into CleverRaven:master Aug 17, 2018
@nexusmrsep nexusmrsep deleted the temp_fix_no_2 branch August 18, 2018 07:51
diff_cold = diff_cold < 1 ? 1 : diff_cold;
diff_cold = diff_cold > 10 ? 10 : diff_cold;
diff_freeze = std::max( static_cast<unsigned int>(1), diff_cold );
diff_freeze = std::min( static_cast<unsigned int>(5), diff_cold );
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for bothering. These two lines seems wierd as the above one keeps diff_cold and those two change to diff_freeze. I'm writing this just so that it can be double-checked.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right and fix is included in PR #24971 waiting to be merged.

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) Items: Food / Vitamins Comestibles and drinks Translation I18n
Projects
None yet
5 participants