Skip to content

Commit

Permalink
Merge pull request #36261 from ZhilkinSerg/astyle-2019-12-19
Browse files Browse the repository at this point in the history
Fix astyle regression (2019-12-19)
  • Loading branch information
ZhilkinSerg committed Dec 19, 2019
2 parents fc8d267 + abb329b commit 1cfb09b
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 16 deletions.
3 changes: 2 additions & 1 deletion src/construction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1398,7 +1398,8 @@ void load_construction( const JsonObject &jo )
con.post_flags = jo.get_tags( "post_flags" );

if( jo.has_member( "byproducts" ) ) {
con.byproduct_item_group = item_group::load_item_group( jo.get_member( "byproducts" ), "collection" );
con.byproduct_item_group = item_group::load_item_group( jo.get_member( "byproducts" ),
"collection" );
}

static const std::map<std::string, std::function<bool( const tripoint & )>> pre_special_map = {{
Expand Down
3 changes: 2 additions & 1 deletion src/field_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ void field_type::load( const JsonObject &jo, const std::string & )
optional( jo, was_loaded, "legacy_enum_id", legacy_enum_id, -1 );
for( const JsonObject &jao : jo.get_array( "intensity_levels" ) ) {
field_intensity_level intensity_level;
field_intensity_level fallback_intensity_level = !intensity_levels.empty() ? intensity_levels.back() : intensity_level;
field_intensity_level fallback_intensity_level = !intensity_levels.empty() ? intensity_levels.back()
: intensity_level;
optional( jao, was_loaded, "name", intensity_level.name, fallback_intensity_level.name );
optional( jao, was_loaded, "sym", intensity_level.symbol, unicode_codepoint_from_symbol_reader,
fallback_intensity_level.symbol );
Expand Down
9 changes: 6 additions & 3 deletions src/item_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1534,14 +1534,16 @@ void Item_factory::load( islot_tool &slot, const JsonObject &jo, const std::stri

if( jo.has_array( "rand_charges" ) ) {
if( jo.has_member( "initial_charges" ) ) {
jo.throw_error( "You can have a fixed initial amount of charges, or randomized. Not both.", "rand_charges" );
jo.throw_error( "You can have a fixed initial amount of charges, or randomized. Not both.",
"rand_charges" );
}
for( const int charge : jo.get_array( "rand_charges" ) ) {
slot.rand_charges.push_back( charge );
}
if( slot.rand_charges.size() == 1 ) {
// see item::item(...) for the use of this array
jo.throw_error( "a rand_charges array with only one entry will be ignored, it needs at least 2 entries!", "rand_charges" );
jo.throw_error( "a rand_charges array with only one entry will be ignored, it needs at least 2 entries!",
"rand_charges" );
}
}
}
Expand Down Expand Up @@ -2513,7 +2515,8 @@ void Item_factory::load_item_group( const JsonObject &jsobj )
load_item_group( jsobj, group_id, subtype );
}

void Item_factory::load_item_group( const JsonArray &entries, const Group_tag &group_id, const bool is_collection, const int ammo_chance, const int magazine_chance )
void Item_factory::load_item_group( const JsonArray &entries, const Group_tag &group_id,
const bool is_collection, const int ammo_chance, const int magazine_chance )
{
const auto type = is_collection ? Item_group::G_COLLECTION : Item_group::G_DISTRIBUTION;
std::unique_ptr<Item_spawn_data> &isd = m_template_groups[group_id];
Expand Down
3 changes: 2 additions & 1 deletion src/item_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ class Item_factory
* Note that each entry in the array has to be a JSON object. The other function above
* can also load data from arrays of strings, where the strings are item or group ids.
*/
void load_item_group( const JsonArray &entries, const Group_tag &group_id, bool is_collection, int ammo_chance, int magazine_chance );
void load_item_group( const JsonArray &entries, const Group_tag &group_id, bool is_collection,
int ammo_chance, int magazine_chance );
/**
* Get the item group object. Returns null if the item group does not exists.
*/
Expand Down
9 changes: 5 additions & 4 deletions src/json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1886,10 +1886,11 @@ JsonIn &JsonValue::seek() const
return jsin_;
}

JsonValue JsonObject::get_member( const std::string &name ) const {
const auto iter = positions.find(name);
if(!jsin || iter == positions.end()) {
throw_error("requested non-existing member \"" + name + "\"");
JsonValue JsonObject::get_member( const std::string &name ) const
{
const auto iter = positions.find( name );
if( !jsin || iter == positions.end() ) {
throw_error( "requested non-existing member \"" + name + "\"" );
}
visited_members.insert( name );
return JsonValue( *jsin, iter->second );
Expand Down
3 changes: 2 additions & 1 deletion src/mission.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ tripoint target_om_ter_random( const std::string &omter, int reveal_rad, mission
bool must_see, int range, tripoint loc = overmap::invalid_tripoint );
void set_reveal( const std::string &terrain,
std::vector<std::function<void( mission *miss )>> &funcs );
void set_reveal_any( const JsonArray &ja, std::vector<std::function<void( mission *miss )>> &funcs );
void set_reveal_any( const JsonArray &ja,
std::vector<std::function<void( mission *miss )>> &funcs );
mission_target_params parse_mission_om_target( const JsonObject &jo );
cata::optional<tripoint> assign_mission_target( const mission_target_params &params );
tripoint get_om_terrain_pos( const mission_target_params &params );
Expand Down
3 changes: 2 additions & 1 deletion src/mission_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,8 @@ void mission_util::set_reveal( const std::string &terrain,
funcs.emplace_back( mission_func );
}

void mission_util::set_reveal_any( const JsonArray &ja, std::vector<std::function<void( mission *miss )>> &funcs )
void mission_util::set_reveal_any( const JsonArray &ja,
std::vector<std::function<void( mission *miss )>> &funcs )
{
std::vector<std::string> terrains;
for( const std::string &terrain : ja ) {
Expand Down
3 changes: 2 additions & 1 deletion src/mutation.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ struct mutation_branch {
* Note that each entry in the array has to be a JSON object. The other function above
* can also load data from arrays of strings, where the strings are item or group ids.
*/
static void load_trait_group( const JsonArray &entries, const trait_group::Trait_group_tag &gid, bool is_collection );
static void load_trait_group( const JsonArray &entries, const trait_group::Trait_group_tag &gid,
bool is_collection );

/**
* Create a new trait group as specified by the given JSON object and register
Expand Down
6 changes: 4 additions & 2 deletions src/mutation_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,8 @@ static Trait_group &make_group_or_throw( const trait_group::Trait_group_tag &gid
return *found->second;
}

void mutation_branch::load_trait_group( const JsonArray &entries, const trait_group::Trait_group_tag &gid, const bool is_collection )
void mutation_branch::load_trait_group( const JsonArray &entries,
const trait_group::Trait_group_tag &gid, const bool is_collection )
{
Trait_group &tg = make_group_or_throw( gid, is_collection );

Expand Down Expand Up @@ -699,7 +700,8 @@ void mutation_branch::load_trait_group( const JsonObject &jsobj,
tg.add_group_entry( trait_group::Trait_group_tag( entry.get_string() ), 100 );
} else if( entry.test_array() ) {
JsonArray subtrait = entry.get_array();
tg.add_group_entry( trait_group::Trait_group_tag( subtrait.get_string( 0 ) ), subtrait.get_int( 1 ) );
tg.add_group_entry( trait_group::Trait_group_tag( subtrait.get_string( 0 ) ),
subtrait.get_int( 1 ) );
} else {
JsonObject subobj = entry.get_object();
add_entry( tg, subobj );
Expand Down
3 changes: 2 additions & 1 deletion src/trait_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ static Trait_group_tag get_unique_trait_group_id()
}
}

Trait_group_tag trait_group::load_trait_group( const JsonValue &value, const std::string &default_subtype )
Trait_group_tag trait_group::load_trait_group( const JsonValue &value,
const std::string &default_subtype )
{
if( value.test_string() ) {
return Trait_group_tag( value.get_string() );
Expand Down

0 comments on commit 1cfb09b

Please sign in to comment.