widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #01664
[Merge] lp:~hjd/widelands/cppcheck-issues into lp:widelands
Hans Joachim Desserud has proposed merging lp:~hjd/widelands/cppcheck-issues into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #986611 in widelands: "Issues reported by cppcheck"
https://bugs.launchpad.net/widelands/+bug/986611
For more details, see:
https://code.launchpad.net/~hjd/widelands/cppcheck-issues/+merge/198154
(Can't seem to link branches/reviews to milestones, but this is targetted for build19)
Fixed a couple of the issues reported by cppcheck.
--
https://code.launchpad.net/~hjd/widelands/cppcheck-issues/+merge/198154
Your team Widelands Developers is requested to review the proposed merge of lp:~hjd/widelands/cppcheck-issues into lp:widelands.
=== modified file 'src/economy/request.cc'
--- src/economy/request.cc 2013-10-08 07:50:59 +0000
+++ src/economy/request.cc 2013-12-07 13:47:13 +0000
@@ -108,9 +108,9 @@
(FileRead & fr, Game & game, Map_Map_Object_Loader & mol)
{
try {
- bool fudged_type = false;
uint16_t const version = fr.Unsigned16();
if (2 <= version and version <= REQUEST_VERSION) {
+ bool fudged_type = false;
const Tribe_Descr & tribe = m_target.owner().tribe();
if (version <= 3) {
// Unfortunately, old versions wrote the index. The best thing
=== modified file 'src/logic/world.cc'
--- src/logic/world.cc 2013-07-26 20:19:36 +0000
+++ src/logic/world.cc 2013-12-07 13:47:13 +0000
@@ -255,7 +255,6 @@
void MapGenAreaInfo::parseSection
(World * const world, Section & s, MapGenAreaType const areaType)
{
- std::string res_str = s.get_string("resources", "");
m_weight = s.get_positive("weight", 1);
m_world = world;
switch (areaType) {
=== modified file 'src/map_generator.cc'
--- src/map_generator.cc 2013-07-25 21:05:20 +0000
+++ src/map_generator.cc 2013-12-07 13:47:13 +0000
@@ -458,7 +458,6 @@
bool isDesert = false;
bool isDesertOuter = false;
uint32_t landAreaIndex = 0;
- MapGenAreaInfo::MapGenAreaType landType = MapGenAreaInfo::atLand;
uint32_t rand2 =
random2[c0.x + m_mapInfo.w * c0.y] / 3 +
@@ -559,7 +558,7 @@
uint32_t const coast_h = mapGenInfo.getLandCoastHeight();
if (h1 <= coast_h && h2 <= coast_h && h3 <= coast_h) { // water or coast...
- atp = landType;
+ atp = MapGenAreaInfo::atLand;
ttp = MapGenAreaInfo::ttLandCoast;
uint32_t const ocean_h = mapGenInfo.getWaterOceanHeight();
=== modified file 'src/map_io/widelands_map_player_names_and_tribes_data_packet.cc'
--- src/map_io/widelands_map_player_names_and_tribes_data_packet.cc 2013-09-23 18:47:02 +0000
+++ src/map_io/widelands_map_player_names_and_tribes_data_packet.cc 2013-12-07 13:47:13 +0000
@@ -91,7 +91,6 @@
("packet_version", CURRENT_PACKET_VERSION);
const Map & map = egbase.map();
- std::string name, tribe;
Player_Number const nr_players = map.get_nrplayers();
iterate_player_numbers(p, nr_players) {
char buffer[10];
=== modified file 'src/map_io/widelands_map_resources_data_packet.cc'
--- src/map_io/widelands_map_resources_data_packet.cc 2013-09-23 18:47:02 +0000
+++ src/map_io/widelands_map_resources_data_packet.cc 2013-12-07 13:47:13 +0000
@@ -118,10 +118,8 @@
fw.Unsigned16(nr_res);
// write all resources names and their id's
- std::map<std::string, uint8_t> smap;
for (int32_t i = 0; i < nr_res; ++i) {
const Resource_Descr & res = *world.get_resource(i);
- smap[res.name().c_str()] = i;
fw.Unsigned16(i);
fw.CString(res.name().c_str());
}
=== modified file 'src/network/nethost.cc'
--- src/network/nethost.cc 2013-10-08 20:13:35 +0000
+++ src/network/nethost.cc 2013-12-07 13:47:13 +0000
@@ -446,7 +446,6 @@
// Acknowledge kick
else if (cmd == "ack_kick") {
- std::string name;
if (arg1.empty())
c.msg = _("kick acknowledgement cancelled: No name given!");
else if (arg2.size())
@@ -2609,7 +2608,6 @@
if (!client.dedicated_access)
throw DisconnectException("NO_ACCESS_TO_SERVER");
- std::string name = r.String();
std::string path = g_fs->FileSystem::fixCrossFile(r.String());
bool savegame = r.Unsigned8() == 1;
bool scenario = r.Unsigned8() == 1;
=== modified file 'src/text_parser.cc'
--- src/text_parser.cc 2013-07-26 19:16:51 +0000
+++ src/text_parser.cc 2013-12-07 13:47:13 +0000
@@ -101,7 +101,6 @@
bool more_text_blocks = true;
while (more_text_blocks) {
std::string block_format;
- std::string block_text;
Text_Block new_block;
std::vector<std::string> words;
=== modified file 'src/ui_fsmenu/options.cc'
--- src/ui_fsmenu/options.cc 2013-07-26 20:19:36 +0000
+++ src/ui_fsmenu/options.cc 2013-12-07 13:47:13 +0000
@@ -524,9 +524,8 @@
// Fill the font list.
{ // For use of string ui_font take a look at fullscreen_menu_base.cc
- bool did_select_a_font = false;
bool cmpbool = !strcmp("serif", opt.ui_font.c_str());
- did_select_a_font = cmpbool;
+ bool did_select_a_font = cmpbool;
m_ui_font_list.add
(_("DejaVuSerif (Default)"), "serif", nullptr, cmpbool);
cmpbool = !strcmp("sans", opt.ui_font.c_str());
=== modified file 'src/wui/game_main_menu_save_game.cc'
--- src/wui/game_main_menu_save_game.cc 2013-08-20 16:17:50 +0000
+++ src/wui/game_main_menu_save_game.cc 2013-12-07 13:47:13 +0000
@@ -171,8 +171,8 @@
uint32_t gametime = gpdp.get_gametime();
m_gametime.set_text(gametimestring(gametime));
- char buf[200];
if (gpdp.get_number_of_players() > 0) {
+ char buf[200];
sprintf
(buf, "%i %s", gpdp.get_number_of_players(),
ngettext(_("player"), _("players"), gpdp.get_number_of_players()));
=== modified file 'src/wui/military_box.cc'
--- src/wui/military_box.cc 2013-07-26 20:19:36 +0000
+++ src/wui/military_box.cc 2013-12-07 13:47:13 +0000
@@ -105,9 +105,8 @@
void MilitaryBox::update() {
Game & game = ref_cast<Game, Editor_Game_Base>(m_pl->egbase());
- char buf[20];
-
if (m_pl->is_retreat_change_allowed()) {
+ char buf[20];
assert(m_slider_retreat);
assert(m_text_retreat);
/// Send change to player
Follow ups