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

Proposed by GunChleoc
Status: Merged
Merged at revision: 7073
Proposed branch: lp:~widelands-dev/widelands/bug-1293158
Merge into: lp:widelands
Diff against target: 101 lines (+28/-25)
1 file modified
src/editor/tools/editor_info_tool.cc (+28/-25)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1293158
Reviewer Review Type Date Requested Status
Tino Needs Fixing
SirVer Approve
Review via email: mp+221434@code.launchpad.net

Description of the change

Got rid of a garbage string

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

A bunch of small nits.

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

Some comments to the nits.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Added some fixes + more comments.

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

the inline comment is rather cumbersome with saving....

review: Approve
Revision history for this message
Tino (tino79) wrote :

Still shows a box character under Map:->Players:
Tested with "Crossing the horizon"

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

> Still shows a box character under Map:->Players:
> Tested with "Crossing the horizon"

I know, but I haven't the foggiest why. Somebody else will have to fix this.

If nobody wants to take on this branch, can we merge and open a new bug?

Revision history for this message
SirVer (sirver) wrote :

the problem was that number of players is a uchar (i.e. 0 <= uchar <= 255). Boost::format() likes to interpret this though as a 'single char'. I merged this and static_cast<int>() the value in question and all is good.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Thanks :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/editor/tools/editor_info_tool.cc'
2--- src/editor/tools/editor_info_tool.cc 2014-06-18 13:20:33 +0000
3+++ src/editor/tools/editor_info_tool.cc 2014-07-11 17:42:02 +0000
4@@ -48,16 +48,11 @@
5 Widelands::Field & f = map[center.node];
6
7 // *** Node info
8- char buf1[1024];
9 std::string buf = _("Node:");
10 buf += "\n";
11- buf += std::string("• ") + (boost::format(_("Coordinates: (%1$i, %2$i)"))
12+ buf += "• " + (boost::format(_("Coordinates: (%1$i, %2$i)"))
13 % center.node.x % center.node.y).str() + "\n";
14
15- buf += std::string("• ");
16- buf += buf1;
17- buf += std::string("\n");
18-
19 std::string temp = "";
20 Widelands::NodeCaps const caps = f.nodecaps();
21 switch (caps & Widelands::BUILDCAPS_SIZEMASK) {
22@@ -82,15 +77,21 @@
23
24 buf += std::string("• ") + (boost::format(_("Caps:%s")) % temp).str() + "\n";
25
26- buf += std::string("• ");
27- snprintf(buf1, sizeof(buf1), _("Owned by %i"), f.get_owned_by());
28- buf += std::string(buf1) + "\n";
29+ if(f.get_owned_by() > 0) {
30+ buf += std::string("• ");
31+ char buf1[1024];
32+ snprintf(buf1, sizeof(buf1), _("Owned by: %u"), f.get_owned_by());
33+ buf += std::string(buf1) + "\n";
34+ }
35+ else {
36+ buf += std::string("• ") + _("Owned by: —") + "\n";
37+ }
38
39 temp = f.get_immovable() ? _("Has base immovable") : _("No base immovable");
40- buf += std::string("• ") + temp + "\n";
41+ buf += "• " + temp + "\n";
42
43 temp = f.get_first_bob() ? _("Has bobs") : _("No bobs");
44- buf += std::string("• ") + temp + "\n";
45+ buf += "• " + temp + "\n";
46
47 // *** Terrain info
48 buf += std::string("\n") + _("Terrain:") + "\n";
49@@ -99,8 +100,8 @@
50 const Widelands::TerrainDescription& ter = world.terrain_descr(
51 center.triangle.t == Widelands::TCoords<>::D ? tf.terrain_d() : tf.terrain_r());
52
53- buf += std::string("• ") + (boost::format(_("Name: %s")) % ter.descname()).str() + "\n";
54- buf += std::string("• ") + (boost::format(_("Texture Number: %i")) % ter.get_texture()).str() + "\n";
55+ buf += "• " + (boost::format(_("Name: %s")) % ter.descname()).str() + "\n";
56+ buf += "• " + (boost::format(_("Texture Number: %i")) % ter.get_texture()).str() + "\n";
57
58 // *** Resources info
59 buf += std::string("\n") + _("Resources:") + "\n";
60@@ -109,28 +110,30 @@
61 int ramount = f.get_resources_amount();
62
63 if (ramount > 0) {
64- buf += std::string("• ") + (boost::format(
65+ buf += "• " + (boost::format(
66 _("Resource name: %s")) % world.get_resource(ridx)->name().c_str()
67 ).str() + "\n";
68- buf += std::string("• ") + (boost::format(_("Resource amount: %i")) % ramount).str() + "\n";
69+ buf += "• " + (boost::format(_("Resource amount: %i")) % ramount).str() + "\n";
70 }
71- else
72- {
73- buf += std::string("• ") + std::string(_("No resources")) + "\n";
74+ else {
75+ buf += "• " + std::string(_("No resources")) + "\n";
76 }
77
78 // *** Map info
79 buf += std::string("\n") + _("Map:") + "\n";
80- buf += std::string("• ") + (boost::format(_("Name: %s")) % map.get_name()).str() + "\n";
81- buf += std::string("• ") + (boost::format(_("Size: %1$ix%2$i"))
82+ buf += "• " + (boost::format(_("Name: %s")) % map.get_name()).str() + "\n";
83+ buf += "• " + (boost::format(_("Size: %1$ix%2$i"))
84 % map.get_width() % map.get_height()).str() + "\n";
85
86- buf += std::string("• ");
87- snprintf(buf1, sizeof(buf1), _("Players: %i"), map.get_nrplayers());
88+ if (map.get_nrplayers() > 0) {
89+ buf += "• " + (boost::format(_("Players: %u")) % map.get_nrplayers()).str() + "\n";
90+ }
91+ else {
92+ buf += "• " + (boost::format(_("Players: %s")) % "—").str() + "\n";
93+ }
94
95- buf += std::string(buf1) + "\n";
96- buf += std::string("• ") + (boost::format(_("Author: %s")) % map.get_author()).str() + "\n";
97- buf += std::string("• ") + (boost::format(_("Descr: %s")) % map.get_description()).str() + "\n";
98+ buf += "• " + (boost::format(_("Author: %s")) % map.get_author()).str() + "\n";
99+ buf += "• " + (boost::format(_("Descr: %s")) % map.get_description()).str() + "\n";
100
101 multiline_textarea->set_text(buf.c_str());
102

Subscribers

People subscribed via source and target branches

to status/vote changes: