void load_furniture(JsonObject &jsobj) { if ( furnlist.empty() ) { furn_t new_null = null_furniture_t(); furnmap[new_null.id] = new_null; furnlist.push_back(new_null); } furn_t new_furniture; new_furniture.id = jsobj.get_string("id"); if ( new_furniture.id == "f_null" ) { return; } new_furniture.name = _(jsobj.get_string("name").c_str()); new_furniture.sym = jsobj.get_string("symbol").c_str()[0]; bool has_color = jsobj.has_member("color"); bool has_bgcolor = jsobj.has_member("bgcolor"); if(has_color && has_bgcolor) { debugmsg("Found both color and bgcolor for %s, use only one of these.", new_furniture.name.c_str()); new_furniture.color = c_white; } else if(has_color) { new_furniture.color = color_from_string(jsobj.get_string("color")); } else if(has_bgcolor) { new_furniture.color = bgcolor_from_string(jsobj.get_string("bgcolor")); } else { debugmsg("Furniture %s needs at least one of: color, bgcolor.", new_furniture.name.c_str()); } new_furniture.movecost = jsobj.get_int("move_cost_mod"); new_furniture.move_str_req = jsobj.get_int("required_str"); new_furniture.transparent = false; new_furniture.bitflags = 0; JsonArray flags = jsobj.get_array("flags"); while(flags.has_more()) { new_furniture.set_flag(flags.next_string()); } if(jsobj.has_member("examine_action")) { std::string function_name = jsobj.get_string("examine_action"); new_furniture.examine = iexamine_function_from_string(function_name); } else { //If not specified, default to no action new_furniture.examine = iexamine_function_from_string("none"); } new_furniture.open = ""; if ( jsobj.has_member("open") ) { new_furniture.open = jsobj.get_string("open"); } new_furniture.close = ""; if ( jsobj.has_member("close") ) { new_furniture.close = jsobj.get_string("close"); } new_furniture.bash.load(jsobj, "bash", true); new_furniture.loadid = furnlist.size(); furnmap[new_furniture.id] = new_furniture; furnlist.push_back(new_furniture); }
void load_furniture( JsonObject &jo, const std::string &src ) { if( furniture_data.empty() ) { furniture_data.insert( null_furniture_t() ); } furniture_data.load( jo, src ); }
void load_furniture(JsonObject &jsobj) { if ( furnlist.empty() ) { furn_t new_null = null_furniture_t(); furnmap[new_null.id] = new_null; furnlist.push_back(new_null); } furn_t new_furniture; new_furniture.id = jsobj.get_string("id"); if ( new_furniture.id == "f_null" ) { return; } new_furniture.name = _(jsobj.get_string("name").c_str()); new_furniture.load_symbol( jsobj ); new_furniture.movecost = jsobj.get_int("move_cost_mod"); new_furniture.move_str_req = jsobj.get_int("required_str"); new_furniture.max_volume = jsobj.get_int("max_volume", MAX_VOLUME_IN_SQUARE); new_furniture.crafting_pseudo_item = jsobj.get_string("crafting_pseudo_item", ""); new_furniture.transparent = false; for( auto & flag : jsobj.get_string_array( "flags" ) ) { new_furniture.set_flag( flag ); } if(jsobj.has_member("examine_action")) { std::string function_name = jsobj.get_string("examine_action"); new_furniture.examine = iexamine_function_from_string(function_name); } else { //If not specified, default to no action new_furniture.examine = iexamine_function_from_string("none"); } new_furniture.open = ""; if ( jsobj.has_member("open") ) { new_furniture.open = jsobj.get_string("open"); } new_furniture.close = ""; if ( jsobj.has_member("close") ) { new_furniture.close = jsobj.get_string("close"); } new_furniture.bash.load(jsobj, "bash", true); new_furniture.deconstruct.load(jsobj, "deconstruct", true); new_furniture.loadid = furn_id( furnlist.size() ); furnmap[new_furniture.id] = new_furniture; furnlist.push_back(new_furniture); }