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

Changing vacuum-packed food to work the same as canned food #26554

Merged

Conversation

Projects
None yet
5 participants
@lancewf
Copy link
Contributor

commented Nov 6, 2018

screen shot 2018-11-13 at 7 53 15 am

📋 Todo

  • Add migration
  • remove old items
  • Clean up tiles with multiple plastic_bag_vac
  • combine fish_salted and salted_fish
  • test migration

How to use

Recipes salted meat slice, salted fish, salted simpleton slices, salted veggy chunk, and fruit slice are vacuum-packed and do not spoil until unloaded or eatten.

Summary

SUMMARY: Bugfixes "Changing vacuum-packed food to work the same as canned foods"

Purpose of change

The crafting and eating of vacuum-packed foods should work the same as canned and jarred foods. Currently, vacuum-packed foods do not show up in the eating menu (pressing 'E'.) One has to first unseal the item to eat it. But canned items do show up in the eat menu and when eat them they automatically unseal the item. This change creates the same behavior for vacuum-packed food.

With these changes and this PR #26553 this fixes the problem where rotten food when vacuum-packed turns fresh.

Describe the solution

Describe alternatives you've considered

Additional context

migration items
bag_fish_vac -> plastic_bag_vac with fish_salted
bag_apple_vac -> plastic_bag_vac with apple_sugar
bag_hflesh_vac -> plastic_bag_vac with hflesh_salted
bag_meat_vac -> plastic_bag_vac with meat_salted
bag_veggy_vac -> plastic_bag_vac with veggy_salted

fish_vac -> fish_salted
apple_vac -> apple_sugar
hflesh_vac -> hflesh_salted
meat_vac -> meat_salted
veggy_vac -> veggy_salted

Testing

  • Create a character on master with vacuum-packed meat, fish, veggies, and fruit. Then update to branch and ensure no problems.
  • On this branch ensure a character can create vacuum-packed meat, fish, veggies, and fruit.
  • Ensure that vacuum-packed meat, fish, veggies, and fruit do not spoil

Not Tested

  • All the tileset updates.

Migration Warning!!!

When migrating vacuum-packed food it will become unsealed and will spoil in the 2 to 3 days. The reason for this is because we can not migrate an item to be in a container.

@Zetsukaze

This comment has been minimized.

Copy link
Contributor

commented Nov 6, 2018

Yes please

@lancewf lancewf force-pushed the lancewf:lancewf/vacuum_sealer_freshness branch 2 times, most recently to f95375b Nov 7, 2018

"type": "CONTAINER",
"category": "other",
"name": "vacuum-packed",
"description": "This is a bag of vacuum packed food",

This comment has been minimized.

Copy link
@Night-Pryanik

Night-Pryanik Nov 8, 2018

Member
Suggested change
"description": "This is a bag of vacuum packed food",
"description": "This is a bag of vacuum-packed food.",
"volume": 1,
"contains": 1,
"price": 750,
"material": "steel",

This comment has been minimized.

Copy link
@Night-Pryanik

This comment has been minimized.

Copy link
@lancewf

lancewf Nov 11, 2018

Author Contributor

Good catch. I copied this from the tin can.

"category": "other",
"name": "vacuum-packed",
"description": "This is a bag of vacuum packed food",
"weight": 240,

This comment has been minimized.

Copy link
@Night-Pryanik

Night-Pryanik Nov 8, 2018

Member

This is the weight of filled bag. Empty it should weight much less.

"weight": 240,
"volume": 1,
"contains": 1,
"price": 750,

This comment has been minimized.

Copy link
@Night-Pryanik

Night-Pryanik Nov 8, 2018

Member

Too much.

This comment has been minimized.

Copy link
@lancewf

lancewf Nov 11, 2018

Author Contributor

I made it the same price as a plastic bag

"id": "plastic_bag_vac",
"type": "CONTAINER",
"category": "other",
"name": "vacuum-packed",

This comment has been minimized.

Copy link
@Night-Pryanik

Night-Pryanik Nov 8, 2018

Member

Vacuum-packed bag?

This comment has been minimized.

Copy link
@lancewf

lancewf Nov 11, 2018

Author Contributor

screen shot 2018-11-11 at 10 44 49 am

Adding bag does look correct.

This comment has been minimized.

Copy link
@lancewf

lancewf Nov 11, 2018

Author Contributor

screen shot 2018-11-11 at 10 46 26 am

@lancewf lancewf force-pushed the lancewf:lancewf/vacuum_sealer_freshness branch 5 times, most recently from 10d34ec to ef05fc2 Nov 11, 2018

@@ -209,7 +209,7 @@
"name_plural": "salted fish",
"//": "Two fillets of fish needed here.",
"description": "Salty dried fish that lasts for a long time, but will make you thirsty.",
"weight": 44,
"weight": 84,

This comment has been minimized.

Copy link
@lancewf

lancewf Nov 11, 2018

Author Contributor

Update this to match the removed fish_vac item.

@lancewf lancewf force-pushed the lancewf:lancewf/vacuum_sealer_freshness branch 5 times, most recently from 089f339 to dc29bf8 Nov 11, 2018

Changing vacuum-packed food to work the same as canned soup
Signed-off-by: Lance Finfrock <lancewf@gmail.com>

@lancewf lancewf force-pushed the lancewf:lancewf/vacuum_sealer_freshness branch from dc29bf8 to 87970ee Nov 12, 2018

lancewf added some commits Nov 13, 2018

@lancewf

This comment has been minimized.

Copy link
Contributor Author

commented Nov 13, 2018

When migrating to this branch's changes the below errors will be seen.
screen shot 2018-11-13 at 7 31 19 am
There are 5 of these one for bag_meat_vac, bag_veggy_vac, bag_fruit_vac, bag_fish_vac, bag_hflesh_vac. All these recipes have been removed and the error does not affect the game.

Is this acceptable or is there a way to remove recipes in a migration?

@lancewf lancewf changed the title WIP: Changing vacuum-packed food to work the same as canned food Changing vacuum-packed food to work the same as canned food Nov 13, 2018

@kevingranade

This comment has been minimized.

Copy link
Member

commented Nov 13, 2018

The current status quo is that you get the error once and then never again since it also silently fails to save.
It would be a nice-to-have for a flag that would still make the recipe go away but would silence the warning, but that doesn't exist right now.

I think something like this would do it:
In src/recipe_dictionary.cpp

template<>
const recipe &string_id<recipe>::obj() const
{
    const auto iter = recipe_dict.recipes.find( *this );
    if( iter != recipe_dict.recipes.end() ) {
        if( iter->second.obsolete ) {
            return null_recipe;
        }
        return iter->second;
    }
    if( *this != NULL_ID() ) {
        debugmsg( "invalid recipe id \"%s\"", c_str() );
    }
    return null_recipe;
}

In src/recipe.cpp

void recipe::load( JsonObject &jo, const std::string &src )
{
...
    if( jo.has_bool( "obsolete" ) ) {
        assign( jo, "obsolete", obsolete );
    }

In src/recipe.h

class recipe {
...
    bool obsolete = false;
@lancewf

This comment has been minimized.

Copy link
Contributor Author

commented Nov 14, 2018

Thank you @kevingranade. I added your suggestion in this (cb8ad29) commit. I tested it out and I do not see any warnings or the old recipes.

{
"type": "recipe",
"result": "bag_meat_vac",
"obsolete": true,

This comment has been minimized.

Copy link
@lancewf

lancewf Nov 14, 2018

Author Contributor

Mark these recipes as obsolete instead of deleting them so they do not display the warning when a user migrates to this version. These recipes should later be deleted.

@kevingranade kevingranade merged commit 8382228 into CleverRaven:master Nov 17, 2018

4 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.2%) to 26.531%
Details
gorgon-ghprb Build finished.
Details

nornagon added a commit to nornagon/cdda-more-city-locations that referenced this pull request Dec 14, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.