Merge lp:~widelands-dev/widelands/bug-1782377-compiler-error into lp:widelands

Proposed by Klaus Halfmann
Status: Merged
Merged at revision: 8758
Proposed branch: lp:~widelands-dev/widelands/bug-1782377-compiler-error
Merge into: lp:widelands
Diff against target: 19 lines (+4/-3)
1 file modified
src/logic/player.cc (+4/-3)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1782377-compiler-error
Reviewer Review Type Date Requested Status
GunChleoc Pending
Review via email: mp+349831@code.launchpad.net

Commit message

Fix for Bug#1782377

Description of the change

Fix compiler error in src/logic/player.cc.

As of to many auto variables the compiler (an I) got confused
how to use a iterator for a two dimensional array.

I simmplified the code to make the compiler and the codecheck happy.

I had not time to check this, yet.

Gun: in this case the codecheck did not point to a real improvement, do we really need that one?

To post a comment you must log in.
Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

I did a quick test, saving is still OK.

That stats[ware_index] is actually an invariant and could be removed, too. Next time :-)

Revision history for this message
GunChleoc (gunchleoc) wrote :

Thanks for cleaning up after me. I'm on a virtual machine right now that's too slow for compiling.

Let's get this in ASAP so that we can continue working, then find a more elegant solution later - the problem with the current code might just have been some pointer/reference thing.

@bunnybot merge

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 3684. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/405534068.
Appveyor build 3483. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1782377_compiler_error-3483.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/logic/player.cc'
2--- src/logic/player.cc 2018-07-18 15:01:33 +0000
3+++ src/logic/player.cc 2018-07-18 19:49:00 +0000
4@@ -1482,11 +1482,12 @@
5 const auto write_stats = [&fw](
6 const std::vector<std::vector<uint32_t>>& stats, const DescriptionIndex ware_index) {
7 std::ostringstream oss("");
8- if (!stats[ware_index].empty()) {
9- for (uint32_t i = 0; i < stats[ware_index].size() - 1; ++i) {
10+ const int sizem = stats[ware_index].size() - 1;
11+ if (sizem >= 0) {
12+ for (int i = 0; i < sizem; ++i) {
13 oss << stats[ware_index][i] << "|";
14 }
15- oss << stats[ware_index][stats[ware_index].rbegin()];
16+ oss << stats[ware_index][sizem];
17 }
18 fw.c_string(oss.str());
19 };

Subscribers

People subscribed via source and target branches

to status/vote changes: