Merge lp:~hjd/widelands/fix-size-greater-than-zero-style-warnings into lp:widelands

Proposed by Hans Joachim Desserud
Status: Merged
Merged at revision: 7064
Proposed branch: lp:~hjd/widelands/fix-size-greater-than-zero-style-warnings
Merge into: lp:widelands
Diff against target: 241 lines (+32/-29)
11 files modified
src/ai/defaultai.cc (+8/-6)
src/io/filesystem/test/test_filesystem.cc (+1/-1)
src/logic/game.cc (+4/-2)
src/network/internet_gaming.cc (+1/-1)
src/network/netclient.cc (+2/-1)
src/network/nethost.cc (+3/-2)
src/network/network_gaming_messages.cc (+3/-3)
src/ui_basic/editbox.cc (+1/-1)
src/ui_basic/progresswindow.cc (+4/-7)
src/ui_fsmenu/launch_mpg.cc (+4/-4)
src/wui/game_summary.cc (+1/-1)
To merge this branch: bzr merge lp:~hjd/widelands/fix-size-greater-than-zero-style-warnings
Reviewer Review Type Date Requested Status
SirVer Approve
Hans Joachim Desserud Needs Fixing
Review via email: mp+226034@code.launchpad.net

Description of the change

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)

To post a comment you must log in.
Revision history for this message
Hans Joachim Desserud (hjd) wrote :

Hm, where on earth did I get conflicts from? No matter, I'll fix.

review: Needs Fixing
Revision history for this message
SirVer (sirver) wrote :

Probably from the merge I just did :P.

One question in the diff, rest LGTM.

review: Approve
Revision history for this message
Hans Joachim Desserud (hjd) wrote :

Oh, it's comparing against trunk. Well that certainly explains why I didn't find it in my local files.

Revision history for this message
SirVer (sirver) wrote :
Download full text (11.0 KiB)

Fair enough. Ship it!

> Am 08.07.2014 um 22:19 schrieb Hans Joachim Desserud <email address hidden>:
>
> Oh, it's comparing against trunk. Well that certainly explains why I didn't find it in my local files.
>
> Diff comments:
>
>> === 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
>> @@...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/ai/defaultai.cc'
2--- src/ai/defaultai.cc 2014-07-03 19:26:30 +0000
3+++ src/ai/defaultai.cc 2014-07-09 11:36:05 +0000
4@@ -670,8 +670,9 @@
5 field.military_capacity_ += militarysite->maxSoldierCapacity();
6 field.military_presence_ += militarysite->stationedSoldiers().size();
7
8- if (militarysite->stationedSoldiers().size() > 0)
9+ if (!militarysite->stationedSoldiers().empty()) {
10 field.military_stationed_ += 1;
11+ }
12
13 field.military_loneliness_ *= static_cast<double_t>(dist) / radius;
14 }
15@@ -1009,7 +1010,7 @@
16 max_needed_preciousness = 0;
17
18 // Check if the produced wares are needed (if it is producing anything)
19- if (bo.outputs_.size() > 0) {
20+ if (!bo.outputs_.empty()) {
21 container_iterate(std::list<EconomyObserver*>, economies, l) {
22 // Don't check if the economy has no warehouse.
23 if ((*l.current)->economy.warehouses().empty())
24@@ -1263,7 +1264,7 @@
25 bf->coords.x,
26 bf->coords.y);
27 }
28- } else if (bo.inputs_.size() > 0) {
29+ } else if (!bo.inputs_.empty()) {
30 // to have two buildings from everything (intended for upgradeable buildings)
31 // but I do not know how to identify such buildings
32 if (bo.cnt_built_ == 1
33@@ -2133,8 +2134,9 @@
34 }
35
36 // buildings with inputs_, checking if we can a dismantle some due to low performance
37- if (productionsite_observer.bo->inputs_.size() > 0 and productionsite_observer.bo->cnt_built_ >=
38- 3 and productionsite_observer.bo->current_stats_ < 30) {
39+ if (!productionsite_observer.bo->inputs_.empty()
40+ and productionsite_observer.bo->cnt_built_ >= 3
41+ and productionsite_observer.bo->current_stats_ < 30) {
42 if (kIdleDismantle)
43 log(" kIdleDismantle: dismantling due to too many buildings: %15s at %3d x %3d, total "
44 "counts: %2d, stat: %2d\n",
45@@ -2451,7 +2453,7 @@
46 uint32_t DefaultAI::get_stocklevel(BuildingObserver& bo) {
47 uint32_t count = 0;
48
49- if (bo.outputs_.size() > 0) {
50+ if (!bo.outputs_.empty()) {
51 container_iterate(std::list<EconomyObserver*>, economies, l) {
52 // Don't check if the economy has no warehouse.
53 if ((*l.current)->economy.warehouses().empty())
54
55=== modified file 'src/io/filesystem/test/test_filesystem.cc'
56--- src/io/filesystem/test/test_filesystem.cc 2013-07-26 19:16:51 +0000
57+++ src/io/filesystem/test/test_filesystem.cc 2014-07-09 11:36:05 +0000
58@@ -31,7 +31,7 @@
59 {
60 for (size_t i = 0; i < s.size(); i++)
61 if (s[i] == '/') s[i] = '\\';
62- if (s.size() > 0 && s[0] == '\\')
63+ if (!s.empty() && s[0] == '\\')
64 {
65 // Insert drive letter part from current working directory
66 std::string cwd = RealFSImpl("").getWorkingDirectory();
67
68=== modified file 'src/logic/game.cc'
69--- src/logic/game.cc 2014-07-08 04:34:17 +0000
70+++ src/logic/game.cc 2014-07-09 11:36:05 +0000
71@@ -228,8 +228,9 @@
72 loaderUI.step (_("Preloading a map"));
73 maploader->preload_map(true);
74 std::string const background = map().get_background();
75- if (!background.empty())
76+ if (!background.empty()) {
77 loaderUI.set_background(background);
78+ }
79
80 // We have to create the players here.
81 Player_Number const nr_players = map().get_nrplayers();
82@@ -288,8 +289,9 @@
83 maploader->preload_map(settings.scenario);
84 std::string const background = map().get_background();
85 if (loaderUI) {
86- if (!background.empty())
87+ if (!background.empty()) {
88 loaderUI->set_background(background);
89+ }
90 loaderUI->step(_("Configuring players"));
91 }
92 std::vector<PlayerSettings> shared;
93
94=== modified file 'src/network/internet_gaming.cc'
95--- src/network/internet_gaming.cc 2014-07-05 11:47:11 +0000
96+++ src/network/internet_gaming.cc 2014-07-09 11:36:05 +0000
97@@ -325,7 +325,7 @@
98 }
99 }
100
101- if (waitcmd.size() > 0) {
102+ if (!waitcmd.empty()) {
103 // Check if timeout is reached
104 time_t now = time(nullptr);
105 if (now > waittimeout) {
106
107=== modified file 'src/network/netclient.cc'
108--- src/network/netclient.cc 2014-07-03 18:20:45 +0000
109+++ src/network/netclient.cc 2014-07-09 11:36:05 +0000
110@@ -1076,8 +1076,9 @@
111 s.Unsigned8(NETCMD_DISCONNECT);
112 s.Unsigned8(arg.size() < 1 ? 1 : 2);
113 s.String(reason);
114- if (arg.size() > 0)
115+ if (!arg.empty()) {
116 s.String(arg);
117+ }
118 s.send(d->sock);
119 }
120
121
122=== modified file 'src/network/nethost.cc'
123--- src/network/nethost.cc 2014-07-05 14:22:44 +0000
124+++ src/network/nethost.cc 2014-07-09 11:36:05 +0000
125@@ -668,7 +668,7 @@
126 {
127 clearComputerPlayers();
128
129- while (d->clients.size() > 0) {
130+ while (!d->clients.empty()) {
131 disconnectClient(0, "SERVER_LEFT");
132 reaper();
133 }
134@@ -1258,8 +1258,9 @@
135 } else {
136 //try to save the game
137 std::string savename = "save/" + arg1;
138- if (arg2.size() > 0) // only add space and arg2, if arg2 has anything to print.
139+ if (!arg2.empty()) { // only add space and arg2, if arg2 has anything to print.
140 savename += " " + arg2;
141+ }
142 savename += ".wgf";
143 std::string * error = new std::string();
144 SaveHandler & sh = d->game->save_handler();
145
146=== modified file 'src/network/network_gaming_messages.cc'
147--- src/network/network_gaming_messages.cc 2014-06-08 21:47:45 +0000
148+++ src/network/network_gaming_messages.cc 2014-07-09 11:36:05 +0000
149@@ -50,11 +50,11 @@
150 // push code and all arguments - if existing - in a vector for easier handling
151 std::vector<std::string> strings;
152 strings.push_back(get_message(code));
153- if (arg1.size() > 0) {
154+ if (!arg1.empty()) {
155 strings.push_back(get_message(arg1));
156- if (arg2.size() > 0) {
157+ if (!arg2.empty()) {
158 strings.push_back(get_message(arg2));
159- if (arg3.size() > 0)
160+ if (!arg3.empty())
161 strings.push_back(get_message(arg3));
162 }
163 }
164
165=== modified file 'src/ui_basic/editbox.cc'
166--- src/ui_basic/editbox.cc 2014-07-05 14:22:44 +0000
167+++ src/ui_basic/editbox.cc 2014-07-09 11:36:05 +0000
168@@ -237,7 +237,7 @@
169 case SDLK_RETURN:
170 // Save history if active and text is not empty
171 if (m_history_active) {
172- if (m->text.size() > 0) {
173+ if (!m->text.empty()) {
174 for (uint8_t i = CHAT_HISTORY_SIZE - 1; i > 0; --i)
175 m_history[i] = m_history[i - 1];
176 m_history[0] = m->text;
177
178=== modified file 'src/ui_basic/progresswindow.cc'
179--- src/ui_basic/progresswindow.cc 2014-07-05 14:22:44 +0000
180+++ src/ui_basic/progresswindow.cc 2014-07-09 11:36:05 +0000
181@@ -93,14 +93,11 @@
182 /// Set a picture to render in the background
183 void ProgressWindow::set_background(const std::string & file_name) {
184 RenderTarget & rt = *g_gr->get_render_target();
185- if (file_name.size() > 0) {
186- if (g_fs->FileExists(file_name))
187- m_background = file_name;
188- else {
189- m_background = "pics/progress.png";
190- }
191- } else
192+ if (!file_name.empty() && g_fs->FileExists(file_name)) {
193+ m_background = file_name;
194+ } else {
195 m_background = "pics/progress.png";
196+ }
197 m_background_pic = nullptr;
198 draw_background(rt, g_gr->get_xres(), g_gr->get_yres());
199 update(true);
200
201=== modified file 'src/ui_fsmenu/launch_mpg.cc'
202--- src/ui_fsmenu/launch_mpg.cc 2014-07-05 14:22:44 +0000
203+++ src/ui_fsmenu/launch_mpg.cc 2014-07-09 11:36:05 +0000
204@@ -227,12 +227,12 @@
205 settings, m_butw, m_buth, m_fn, m_fs);
206
207 // If we are the host, open the map or save selection menu at startup
208- if (m_settings->settings().usernum == 0 && m_settings->settings().mapname.empty())
209- {
210+ if (m_settings->settings().usernum == 0 && m_settings->settings().mapname.empty()) {
211 change_map_or_save();
212 // Try to associate the host with the first player
213- if (m_settings->settings().players.size() > 0)
214+ if (!m_settings->settings().players.empty()) {
215 m_settings->setPlayerNumber(0);
216+ }
217 }
218 }
219
220@@ -527,7 +527,7 @@
221 m_settings->setPlayerTribe (i, map.get_scenario_player_tribe (i + 1));
222 m_settings->setPlayerCloseable(i, map.get_scenario_player_closeable(i + 1));
223 std::string ai(map.get_scenario_player_ai(i + 1));
224- if (ai.size() > 0) {
225+ if (!ai.empty()) {
226 m_settings->setPlayerState(i, PlayerSettings::stateComputer);
227 m_settings->setPlayerAI (i, ai);
228 } else if
229
230=== modified file 'src/wui/game_summary.cc'
231--- src/wui/game_summary.cc 2014-07-05 13:14:42 +0000
232+++ src/wui/game_summary.cc 2014-07-09 11:36:05 +0000
233@@ -192,7 +192,7 @@
234 }
235 }
236 m_players_table->update();
237- if (players_status.size() > 0) {
238+ if (!players_status.empty()) {
239 m_players_table->select(players_status.at(0).player);
240 }
241 m_gametime_value->set_text(gametimestring(m_game.get_gametime()));

Subscribers

People subscribed via source and target branches

to status/vote changes: