Cataclysm-dda: Comestibles "fortified" with vitamins through 'relative' field with an integer will have everything that is implemented on top of vitamins system

Created on 29 Aug 2020  路  6Comments  路  Source: CleverRaven/Cataclysm-DDA

Describe the bug

item_factory.cpp

        if( relative.has_int( "vitamins" ) ) {
            // allows easy specification of 'fortified' comestibles
            for( const auto &v : vitamin::all() ) {
                slot.default_nutrition.vitamins[ v.first ] += relative.get_int( "vitamins" );

Steps To Reproduce

So far only read the code.

Expected behavior

From perspective of implementing a new deserializer on Python: vitamins defined explicitly, support for this removed. But I guess JSON authors and author(s) of this CPP code will want to just limit vitamins list in this block.

Additional context

43287

Good First Issue [C++]

All 6 comments

I don't see "vitamins": "?[0-9] used anywhere. Can we please just remove it?

Yep, I don't see it anywhere either, I think it can be removed.

Hi, I'm looking to improve my C++ by contributing to a few projects on github and I thought I might take a look at this issue if that's OK?

Yep! Feel free to ask questions if you need any help.

To be clear, it's only specifying an integer that you want to remove, an array should still be allowed? i.e. only this code:

if( relative.has_int( "vitamins" ) ) {
            // allows easy specification of 'fortified' comestibles
            for( const auto &v : vitamin::all() ) {
                slot.default_nutrition.vitamins[ v.first ] += relative.get_int( "vitamins" );
            }
}

and not the block below:

else if( relative.has_array( "vitamins" ) ) {
            for( JsonArray pair : relative.get_array( "vitamins" ) ) {
                vitamin_id vit( pair.get_string( 0 ) );
                slot.default_nutrition.vitamins[ vit ] += pair.get_int( 1 );
            }
}

Yes

Was this page helpful?
0 / 5 - 0 ratings