widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #02222
[Merge] lp:~hjd/widelands/fix-size-greater-than-zero-style-warnings into lp:widelands
Hans Joachim Desserud has proposed merging lp:~hjd/widelands/fix-size-greater-than-zero-style-warnings into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~hjd/widelands/fix-size-greater-than-zero-style-warnings/+merge/226034
As correctly pointed out by SirVer, I pushed the new codecheck without ensuring I had solved the issues it complained about. This is the patch to rectify this :p
(Also a couple of minor style changes adding {}, and a simplification where it was possible)
--
https://code.launchpad.net/~hjd/widelands/fix-size-greater-than-zero-style-warnings/+merge/226034
Your team Widelands Developers is requested to review the proposed merge of lp:~hjd/widelands/fix-size-greater-than-zero-style-warnings into lp:widelands.
=== modified file 'src/ai/defaultai.cc'
--- src/ai/defaultai.cc 2014-07-03 19:26:30 +0000
+++ src/ai/defaultai.cc 2014-07-08 20:01:43 +0000
@@ -670,8 +670,9 @@
field.military_capacity_ += militarysite->maxSoldierCapacity();
field.military_presence_ += militarysite->stationedSoldiers().size();
- if (militarysite->stationedSoldiers().size() > 0)
+ if (!militarysite->stationedSoldiers().empty()) {
field.military_stationed_ += 1;
+ }
field.military_loneliness_ *= static_cast<double_t>(dist) / radius;
}
@@ -1009,7 +1010,7 @@
max_needed_preciousness = 0;
// Check if the produced wares are needed (if it is producing anything)
- if (bo.outputs_.size() > 0) {
+ if (!bo.outputs_.empty()) {
container_iterate(std::list<EconomyObserver*>, economies, l) {
// Don't check if the economy has no warehouse.
if ((*l.current)->economy.warehouses().empty())
@@ -1263,7 +1264,7 @@
bf->coords.x,
bf->coords.y);
}
- } else if (bo.inputs_.size() > 0) {
+ } else if (!bo.inputs_.empty()) {
// to have two buildings from everything (intended for upgradeable buildings)
// but I do not know how to identify such buildings
if (bo.cnt_built_ == 1
@@ -2133,8 +2134,9 @@
}
// buildings with inputs_, checking if we can a dismantle some due to low performance
- if (productionsite_observer.bo->inputs_.size() > 0 and productionsite_observer.bo->cnt_built_ >=
- 3 and productionsite_observer.bo->current_stats_ < 30) {
+ if (!productionsite_observer.bo->inputs_.empty()
+ and productionsite_observer.bo->cnt_built_ >= 3
+ and productionsite_observer.bo->current_stats_ < 30) {
if (kIdleDismantle)
log(" kIdleDismantle: dismantling due to too many buildings: %15s at %3d x %3d, total "
"counts: %2d, stat: %2d\n",
@@ -2451,7 +2453,7 @@
uint32_t DefaultAI::get_stocklevel(BuildingObserver& bo) {
uint32_t count = 0;
- if (bo.outputs_.size() > 0) {
+ if (!bo.outputs_.empty()) {
container_iterate(std::list<EconomyObserver*>, economies, l) {
// Don't check if the economy has no warehouse.
if ((*l.current)->economy.warehouses().empty())
=== modified file 'src/io/filesystem/test/test_filesystem.cc'
--- src/io/filesystem/test/test_filesystem.cc 2013-07-26 19:16:51 +0000
+++ src/io/filesystem/test/test_filesystem.cc 2014-07-08 20:01:43 +0000
@@ -31,7 +31,7 @@
{
for (size_t i = 0; i < s.size(); i++)
if (s[i] == '/') s[i] = '\\';
- if (s.size() > 0 && s[0] == '\\')
+ if (!s.empty() && s[0] == '\\')
{
// Insert drive letter part from current working directory
std::string cwd = RealFSImpl("").getWorkingDirectory();
=== modified file 'src/logic/game.cc'
--- src/logic/game.cc 2014-07-08 04:34:17 +0000
+++ src/logic/game.cc 2014-07-08 20:01:43 +0000
@@ -228,8 +228,13 @@
loaderUI.step (_("Preloading a map"));
maploader->preload_map(true);
std::string const background = map().get_background();
+<<<<<<< TREE
if (!background.empty())
+=======
+ if (!background.empty()) {
+>>>>>>> MERGE-SOURCE
loaderUI.set_background(background);
+ }
// We have to create the players here.
Player_Number const nr_players = map().get_nrplayers();
@@ -288,8 +293,13 @@
maploader->preload_map(settings.scenario);
std::string const background = map().get_background();
if (loaderUI) {
+<<<<<<< TREE
if (!background.empty())
+=======
+ if (!background.empty()) {
+>>>>>>> MERGE-SOURCE
loaderUI->set_background(background);
+ }
loaderUI->step(_("Configuring players"));
}
std::vector<PlayerSettings> shared;
=== modified file 'src/network/internet_gaming.cc'
--- src/network/internet_gaming.cc 2014-07-05 11:47:11 +0000
+++ src/network/internet_gaming.cc 2014-07-08 20:01:43 +0000
@@ -325,7 +325,7 @@
}
}
- if (waitcmd.size() > 0) {
+ if (!waitcmd.empty()) {
// Check if timeout is reached
time_t now = time(nullptr);
if (now > waittimeout) {
=== modified file 'src/network/netclient.cc'
--- src/network/netclient.cc 2014-07-03 18:20:45 +0000
+++ src/network/netclient.cc 2014-07-08 20:01:43 +0000
@@ -1076,8 +1076,9 @@
s.Unsigned8(NETCMD_DISCONNECT);
s.Unsigned8(arg.size() < 1 ? 1 : 2);
s.String(reason);
- if (arg.size() > 0)
+ if (!arg.empty()) {
s.String(arg);
+ }
s.send(d->sock);
}
=== modified file 'src/network/nethost.cc'
--- src/network/nethost.cc 2014-07-05 14:22:44 +0000
+++ src/network/nethost.cc 2014-07-08 20:01:43 +0000
@@ -668,7 +668,7 @@
{
clearComputerPlayers();
- while (d->clients.size() > 0) {
+ while (!d->clients.empty()) {
disconnectClient(0, "SERVER_LEFT");
reaper();
}
@@ -1258,8 +1258,9 @@
} else {
//try to save the game
std::string savename = "save/" + arg1;
- if (arg2.size() > 0) // only add space and arg2, if arg2 has anything to print.
+ if (!arg2.empty()) { // only add space and arg2, if arg2 has anything to print.
savename += " " + arg2;
+ }
savename += ".wgf";
std::string * error = new std::string();
SaveHandler & sh = d->game->save_handler();
=== modified file 'src/network/network_gaming_messages.cc'
--- src/network/network_gaming_messages.cc 2014-06-08 21:47:45 +0000
+++ src/network/network_gaming_messages.cc 2014-07-08 20:01:43 +0000
@@ -50,11 +50,11 @@
// push code and all arguments - if existing - in a vector for easier handling
std::vector<std::string> strings;
strings.push_back(get_message(code));
- if (arg1.size() > 0) {
+ if (!arg1.empty()) {
strings.push_back(get_message(arg1));
- if (arg2.size() > 0) {
+ if (!arg2.empty()) {
strings.push_back(get_message(arg2));
- if (arg3.size() > 0)
+ if (!arg3.empty())
strings.push_back(get_message(arg3));
}
}
=== modified file 'src/ui_basic/editbox.cc'
--- src/ui_basic/editbox.cc 2014-07-05 14:22:44 +0000
+++ src/ui_basic/editbox.cc 2014-07-08 20:01:43 +0000
@@ -237,7 +237,7 @@
case SDLK_RETURN:
// Save history if active and text is not empty
if (m_history_active) {
- if (m->text.size() > 0) {
+ if (!m->text.empty()) {
for (uint8_t i = CHAT_HISTORY_SIZE - 1; i > 0; --i)
m_history[i] = m_history[i - 1];
m_history[0] = m->text;
=== modified file 'src/ui_basic/progresswindow.cc'
--- src/ui_basic/progresswindow.cc 2014-07-05 14:22:44 +0000
+++ src/ui_basic/progresswindow.cc 2014-07-08 20:01:43 +0000
@@ -93,14 +93,11 @@
/// Set a picture to render in the background
void ProgressWindow::set_background(const std::string & file_name) {
RenderTarget & rt = *g_gr->get_render_target();
- if (file_name.size() > 0) {
- if (g_fs->FileExists(file_name))
- m_background = file_name;
- else {
- m_background = "pics/progress.png";
- }
- } else
+ if (!file_name.empty() && g_fs->FileExists(file_name)) {
+ m_background = file_name;
+ } else {
m_background = "pics/progress.png";
+ }
m_background_pic = nullptr;
draw_background(rt, g_gr->get_xres(), g_gr->get_yres());
update(true);
=== modified file 'src/ui_fsmenu/launch_mpg.cc'
--- src/ui_fsmenu/launch_mpg.cc 2014-07-05 14:22:44 +0000
+++ src/ui_fsmenu/launch_mpg.cc 2014-07-08 20:01:43 +0000
@@ -227,12 +227,12 @@
settings, m_butw, m_buth, m_fn, m_fs);
// If we are the host, open the map or save selection menu at startup
- if (m_settings->settings().usernum == 0 && m_settings->settings().mapname.empty())
- {
+ if (m_settings->settings().usernum == 0 && m_settings->settings().mapname.empty()) {
change_map_or_save();
// Try to associate the host with the first player
- if (m_settings->settings().players.size() > 0)
+ if (!m_settings->settings().players.empty()) {
m_settings->setPlayerNumber(0);
+ }
}
}
@@ -527,7 +527,7 @@
m_settings->setPlayerTribe (i, map.get_scenario_player_tribe (i + 1));
m_settings->setPlayerCloseable(i, map.get_scenario_player_closeable(i + 1));
std::string ai(map.get_scenario_player_ai(i + 1));
- if (ai.size() > 0) {
+ if (!ai.empty()) {
m_settings->setPlayerState(i, PlayerSettings::stateComputer);
m_settings->setPlayerAI (i, ai);
} else if
=== modified file 'src/wui/game_summary.cc'
--- src/wui/game_summary.cc 2014-07-05 13:14:42 +0000
+++ src/wui/game_summary.cc 2014-07-08 20:01:43 +0000
@@ -192,7 +192,7 @@
}
}
m_players_table->update();
- if (players_status.size() > 0) {
+ if (!players_status.empty()) {
m_players_table->select(players_status.at(0).player);
}
m_gametime_value->set_text(gametimestring(m_game.get_gametime()));