Merge lp:~widelands-dev/widelands/bug-1520820 into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 7652
Proposed branch: lp:~widelands-dev/widelands/bug-1520820
Merge into: lp:widelands
Diff against target: 45 lines (+6/-6)
1 file modified
src/logic/production_program.cc (+6/-6)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1520820
Reviewer Review Type Date Requested Status
GunChleoc Needs Resubmitting
TiborB Needs Fixing
Tino Pending
Review via email: mp+278898@code.launchpad.net

Description of the change

Initialized some variables to fix error in gcc 5.2.0.

Tino, could you please check if this does fix it?

To post a comment you must log in.
Revision history for this message
TiborB (tiborb95) wrote :

But I dont think it is correct, providing that m_items is bigger then 1 and it contains various wares - count should be either sum of all item_pair.second (see comment of diff) or rather the result string should be in format warename+count and should be generated differently... In fact I dont remember detaily the format of this string in the game...

review: Needs Fixing
Revision history for this message
GunChleoc (gunchleoc) wrote :

You are right, we need to sum these up.

Revision history for this message
GunChleoc (gunchleoc) wrote :

This should do it - thanks for having my back :)

review: Needs Resubmitting

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/logic/production_program.cc'
2--- src/logic/production_program.cc 2015-11-28 13:56:45 +0000
3+++ src/logic/production_program.cc 2015-11-29 09:27:06 +0000
4@@ -1049,9 +1049,9 @@
5 assert(m_items.size());
6
7 std::vector<std::string> ware_descnames;
8- uint8_t count;
9+ uint8_t count = 0;
10 for (const auto& item_pair : m_items) {
11- count = item_pair.second;
12+ count += item_pair.second;
13 std::string ware_descname = tribe.get_ware_descr(item_pair.first)->descname();
14 // TODO(GunChleoc): would be nice with pngettext whenever it gets added to xgettext for Lua.
15 if (1 < count) {
16@@ -1059,7 +1059,7 @@
17 /** TRANSLATORS: %%1$i = "2" */
18 /** TRANSLATORS: %2$s = "Coal" */
19 ware_descname = (boost::format(_("%1$ix %2$s"))
20- % static_cast<unsigned int>(count)
21+ % static_cast<unsigned int>(item_pair.second)
22 % ware_descname).str();
23 }
24 ware_descnames.push_back(ware_descname);
25@@ -1145,9 +1145,9 @@
26 const TribeDescr & tribe = ps.owner().tribe();
27 assert(m_items.size());
28 std::vector<std::string> worker_descnames;
29- uint8_t count;
30+ uint8_t count = 0;
31 for (const auto& item_pair : m_items) {
32- count = item_pair.second;
33+ count += item_pair.second;
34 std::string worker_descname = tribe.get_worker_descr(item_pair.first)->descname();
35 // TODO(GunChleoc): would be nice with pngettext whenever it gets added to xgettext for Lua.
36 if (1 < count) {
37@@ -1155,7 +1155,7 @@
38 /** TRANSLATORS: %1$i = "2" */
39 /** TRANSLATORS: %2$s = "Ox" */
40 worker_descname = (boost::format(_("%1$ix %2$s"))
41- % static_cast<unsigned int>(count)
42+ % static_cast<unsigned int>(item_pair.second)
43 % worker_descname).str();
44 }
45 worker_descnames.push_back(worker_descname);

Subscribers

People subscribed via source and target branches

to status/vote changes: