From 10efe23ad5f81c50e2b27b762826201b5b7555ab Mon Sep 17 00:00:00 2001 From: KarateSnoopy Date: Tue, 26 Mar 2019 22:19:28 -0700 Subject: [PATCH 1/2] Fix C4267 and C4244 warnings in Visual Studio 2017 compile --- src/consumption.cpp | 2 +- src/item_factory.cpp | 4 ++-- src/lightmap.cpp | 6 +++--- src/mutation.h | 2 +- src/mutation_data.cpp | 2 +- src/trait_group.cpp | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/consumption.cpp b/src/consumption.cpp index 5fa212188b4ff..afdf2fd500905 100644 --- a/src/consumption.cpp +++ b/src/consumption.cpp @@ -274,7 +274,7 @@ std::map player::vitamins_from( const item &it ) const for( const auto &mat : mut.vitamin_absorb_multi ) { // this is where we are able to check if the food actually is changed by the trait if( mat.first == material_id( "all" ) || material_exists( mat.first, it ) ) { - std::map mat_vit_map = mat.second; + std::map mat_vit_map = mat.second; // finally iterate over every vitamin in each material for( const auto &vit : res ) { // to avoid errors with undefined keys, and to initialize numbers to 1 if undefined diff --git a/src/item_factory.cpp b/src/item_factory.cpp index 5236753ed4f12..6643c30bd6edf 100644 --- a/src/item_factory.cpp +++ b/src/item_factory.cpp @@ -2648,7 +2648,7 @@ void item_group::debug_spawn() uilist menu; menu.text = _( "Test which group?" ); for( size_t i = 0; i < groups.size(); i++ ) { - menu.entries.emplace_back( i, true, -2, groups[i] ); + menu.entries.emplace_back( static_cast(i), true, -2, groups[i] ); } while( true ) { menu.query(); @@ -2674,7 +2674,7 @@ void item_group::debug_spawn() for( const auto &e : itemnames2 ) { std::ostringstream buffer; buffer << e.first << " x " << e.second << "\n"; - menu2.entries.emplace_back( menu2.entries.size(), true, -2, buffer.str() ); + menu2.entries.emplace_back( static_cast(menu2.entries.size()), true, -2, buffer.str() ); } menu2.query(); } diff --git a/src/lightmap.cpp b/src/lightmap.cpp index 8bcd3589f7138..2aa35c6624712 100644 --- a/src/lightmap.cpp +++ b/src/lightmap.cpp @@ -408,7 +408,7 @@ void map::generate_lightmap( const int zlev ) continue; } if( vp.has_feature( VPFLAG_CARGO ) && !vp.has_feature( "COVERED" ) ) { - add_light_from_items( pp, v->get_items( p ).begin(), v->get_items( p ).end() ); + add_light_from_items( pp, v->get_items( static_cast(p) ).begin(), v->get_items( static_cast(p) ).end() ); } } } @@ -1139,10 +1139,10 @@ void map::build_seen_cache( const tripoint &origin, const int target_z ) seen_cache[mirror_pos.x][mirror_pos.y] < LIGHT_TRANSPARENCY_SOLID + 0.1 ) { continue; } else if( !vp.info().has_flag( "CAMERA_CONTROL" ) ) { - mirrors.emplace_back( vp.part_index() ); + mirrors.emplace_back( static_cast(vp.part_index()) ); } else { if( square_dist( origin, mirror_pos ) <= 1 && veh->camera_on ) { - cam_control = vp.part_index(); + cam_control = static_cast(vp.part_index()); } } } diff --git a/src/mutation.h b/src/mutation.h index 94ec5320de601..9183467624f3f 100644 --- a/src/mutation.h +++ b/src/mutation.h @@ -184,7 +184,7 @@ struct mutation_branch { std::map vitamin_rates; // Mutations may affect absorption rates of vitamins based on material (or "all") - std::map> vitamin_absorb_multi; + std::map> vitamin_absorb_multi; std::vector prereqs; // Prerequisites; Only one is required std::vector prereqs2; // Prerequisites; need one from here too diff --git a/src/mutation_data.cpp b/src/mutation_data.cpp index 80f7625c57b6a..db49c97372c70 100644 --- a/src/mutation_data.cpp +++ b/src/mutation_data.cpp @@ -302,7 +302,7 @@ void mutation_branch::load( JsonObject &jo, const std::string & ) auto vam = jo.get_array( "vitamins_absorb_multi" ); while( vam.has_more() ) { auto pair = vam.next_array(); - std::map vit; + std::map vit; auto vit_array = pair.get_array( 1 ); // fill the inner map with vitamins while( vit_array.has_more() ) { diff --git a/src/trait_group.cpp b/src/trait_group.cpp index 1297233957b10..e7968fe0640cd 100644 --- a/src/trait_group.cpp +++ b/src/trait_group.cpp @@ -82,7 +82,7 @@ void trait_group::debug_spawn() uilist menu; menu.text = _( "Test which group?" ); for( size_t i = 0; i < groups.size(); i++ ) { - menu.entries.emplace_back( i, true, -2, groups[i].str() ); + menu.entries.emplace_back( static_cast(i), true, -2, groups[i].str() ); } while( true ) { menu.query(); @@ -108,7 +108,7 @@ void trait_group::debug_spawn() for( const auto &e : traitnames2 ) { std::ostringstream buffer; buffer << e.first << " x " << e.second << "\n"; - menu2.entries.emplace_back( menu2.entries.size(), true, -2, buffer.str() ); + menu2.entries.emplace_back( static_cast(menu2.entries.size()), true, -2, buffer.str() ); } menu2.query(); } From 0d08becd47a199d8a64596f46ae2c48d7dcd23ac Mon Sep 17 00:00:00 2001 From: KarateSnoopy Date: Tue, 26 Mar 2019 23:39:38 -0700 Subject: [PATCH 2/2] Fixing formatting using AStyle --- src/item_factory.cpp | 4 ++-- src/lightmap.cpp | 7 ++++--- src/trait_group.cpp | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/item_factory.cpp b/src/item_factory.cpp index 6643c30bd6edf..78f500a2537b9 100644 --- a/src/item_factory.cpp +++ b/src/item_factory.cpp @@ -2648,7 +2648,7 @@ void item_group::debug_spawn() uilist menu; menu.text = _( "Test which group?" ); for( size_t i = 0; i < groups.size(); i++ ) { - menu.entries.emplace_back( static_cast(i), true, -2, groups[i] ); + menu.entries.emplace_back( static_cast( i ), true, -2, groups[i] ); } while( true ) { menu.query(); @@ -2674,7 +2674,7 @@ void item_group::debug_spawn() for( const auto &e : itemnames2 ) { std::ostringstream buffer; buffer << e.first << " x " << e.second << "\n"; - menu2.entries.emplace_back( static_cast(menu2.entries.size()), true, -2, buffer.str() ); + menu2.entries.emplace_back( static_cast( menu2.entries.size() ), true, -2, buffer.str() ); } menu2.query(); } diff --git a/src/lightmap.cpp b/src/lightmap.cpp index 2aa35c6624712..edd04c03ade11 100644 --- a/src/lightmap.cpp +++ b/src/lightmap.cpp @@ -408,7 +408,8 @@ void map::generate_lightmap( const int zlev ) continue; } if( vp.has_feature( VPFLAG_CARGO ) && !vp.has_feature( "COVERED" ) ) { - add_light_from_items( pp, v->get_items( static_cast(p) ).begin(), v->get_items( static_cast(p) ).end() ); + add_light_from_items( pp, v->get_items( static_cast( p ) ).begin(), + v->get_items( static_cast( p ) ).end() ); } } } @@ -1139,10 +1140,10 @@ void map::build_seen_cache( const tripoint &origin, const int target_z ) seen_cache[mirror_pos.x][mirror_pos.y] < LIGHT_TRANSPARENCY_SOLID + 0.1 ) { continue; } else if( !vp.info().has_flag( "CAMERA_CONTROL" ) ) { - mirrors.emplace_back( static_cast(vp.part_index()) ); + mirrors.emplace_back( static_cast( vp.part_index() ) ); } else { if( square_dist( origin, mirror_pos ) <= 1 && veh->camera_on ) { - cam_control = static_cast(vp.part_index()); + cam_control = static_cast( vp.part_index() ); } } } diff --git a/src/trait_group.cpp b/src/trait_group.cpp index e7968fe0640cd..26e0af29eaee8 100644 --- a/src/trait_group.cpp +++ b/src/trait_group.cpp @@ -82,7 +82,7 @@ void trait_group::debug_spawn() uilist menu; menu.text = _( "Test which group?" ); for( size_t i = 0; i < groups.size(); i++ ) { - menu.entries.emplace_back( static_cast(i), true, -2, groups[i].str() ); + menu.entries.emplace_back( static_cast( i ), true, -2, groups[i].str() ); } while( true ) { menu.query(); @@ -108,7 +108,7 @@ void trait_group::debug_spawn() for( const auto &e : traitnames2 ) { std::ostringstream buffer; buffer << e.first << " x " << e.second << "\n"; - menu2.entries.emplace_back( static_cast(menu2.entries.size()), true, -2, buffer.str() ); + menu2.entries.emplace_back( static_cast( menu2.entries.size() ), true, -2, buffer.str() ); } menu2.query(); }