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

Convert islot_seed to generic_factory #40371

Merged
merged 1 commit into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions src/item_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1955,14 +1955,20 @@ void Item_factory::load_comestible( const JsonObject &jo, const std::string &src
}
}

void Item_factory::load( islot_seed &slot, const JsonObject &jo, const std::string & )
void islot_seed::load( const JsonObject &jo )
{
assign( jo, "grow", slot.grow, false, 1_days );
slot.fruit_div = jo.get_int( "fruit_div", 1 );
jo.read( "plant_name", slot.plant_name );
slot.fruit_id = jo.get_string( "fruit" );
slot.spawn_seeds = jo.get_bool( "seeds", true );
slot.byproducts = jo.get_string_array( "byproducts" );
assign( jo, "grow", grow, false, 1_days );
optional( jo, was_loaded, "fruit_div", fruit_div, 1 );
mandatory( jo, was_loaded, "plant_name", plant_name );
mandatory( jo, was_loaded, "fruit", fruit_id );
optional( jo, was_loaded, "seeds", spawn_seeds, true );
optional( jo, was_loaded, "byproducts", byproducts );
}

void islot_seed::deserialize( JsonIn &jsin )
{
const JsonObject jo = jsin.get_object();
load( jo );
}

void Item_factory::load( islot_gunmod &slot, const JsonObject &jo, const std::string &src )
Expand Down Expand Up @@ -2442,7 +2448,7 @@ void Item_factory::load_basic_info( const JsonObject &jo, itype &def, const std:
load_slot_optional( def.gun, jo, "gun_data", src );
load_slot_optional( def.bionic, jo, "bionic_data", src );
assign( jo, "ammo_data", def.ammo, src == "dda" );
load_slot_optional( def.seed, jo, "seed_data", src );
assign( jo, "seed_data", def.seed, src == "dda" );
load_slot_optional( def.artifact, jo, "artifact_data", src );
load_slot_optional( def.brewable, jo, "brewable", src );
load_slot_optional( def.fuel, jo, "fuel", src );
Expand Down
1 change: 0 additions & 1 deletion src/item_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ class Item_factory
void load( islot_magazine &slot, const JsonObject &jo, const std::string &src );
void load( islot_battery &slot, const JsonObject &jo, const std::string &src );
void load( islot_bionic &slot, const JsonObject &jo, const std::string &src );
void load( islot_seed &slot, const JsonObject &jo, const std::string &src );
void load( islot_artifact &slot, const JsonObject &jo, const std::string &src );
void load( relic &slot, const JsonObject &jo, const std::string &src );

Expand Down
8 changes: 7 additions & 1 deletion src/itype.h
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ struct islot_ammo : common_ranged_data {
*/
cata::optional<bool> force_stat_display;

bool was_loaded;
bool was_loaded = false;

void load( const JsonObject &jo );
void deserialize( JsonIn &jsin );
Expand All @@ -745,6 +745,12 @@ struct islot_bionic {
};

struct islot_seed {
// Generic factory stuff
bool was_loaded = false;

void load( const JsonObject &jo );
void deserialize( JsonIn &jsin );

/**
* Time it takes for a seed to grow (based of off a season length of 91 days).
*/
Expand Down