Merge lp:~widelands-dev/widelands/bug-1784122-singleplayer-viewport into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 8792
Proposed branch: lp:~widelands-dev/widelands/bug-1784122-singleplayer-viewport
Merge into: lp:widelands
Diff against target: 16 lines (+5/-1)
1 file modified
src/game_io/game_interactive_player_packet.cc (+5/-1)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1784122-singleplayer-viewport
Reviewer Review Type Date Requested Status
Notabilis Approve
Review via email: mp+353391@code.launchpad.net

Commit message

Fix saveloading of interactive player's viewport

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

Continuous integration builds have changed state:

Travis build 3819. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/418129123.
Appveyor build 3618. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1784122_singleplayer_viewport-3618.

Revision history for this message
Notabilis (notabilis27) wrote :

Code is looking good and working as intended.

That definitely is one nasty bug...

review: Approve
Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Now I am confused. That code should be semantically identical?

As peformance optimizer I see the the extra null-assignement is a waste :-)

Can you add a comment what compiler/enviroment causes this problem?

I tested this in bzr8791[trunk] and it was ok for me.

Revision history for this message
GunChleoc (gunchleoc) wrote :

> That code should be semantically identical?

That's what I thought too when I broke it. I really don't want to dig into the streamreader right now though - there is some subtle unexpected side-effect going on there.

@bunnybot merge

Revision history for this message
Notabilis (notabilis27) wrote :

That bug is really fun but the streamreader isn't to blame. ;-)
The problem is that the float_32() call not only returns the value but also modifies the internal state of the stream. As a consequence, the order of assignment to x and y matters (or more precisely, the order in which the respective float_32() calls are made).
It seems as if calling it twice as constructor parameters results in the *second* call being done first, resulting in x and y being swapped after the assignment. Doing only one call as parameter and assigning the other one later on is fine. Or just assign both later on as in this branch.
Took me quite some time of trial&error until I realized that...

I am using gcc version 8.2.0 with a release build. The order of the evaluation is undefined in the standard, so it might indeed be compiler dependent.

The null-assignment is required since the default constructor is deleted.

Revision history for this message
Notabilis (notabilis27) wrote :

*with a debug build, sorry.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/game_io/game_interactive_player_packet.cc'
2--- src/game_io/game_interactive_player_packet.cc 2018-07-08 15:16:16 +0000
3+++ src/game_io/game_interactive_player_packet.cc 2018-08-20 07:44:00 +0000
4@@ -59,7 +59,11 @@
5 if (player_number > max)
6 throw GameDataError("The game has no players!");
7 }
8- Vector2f center_map_pixel(fr.float_32(), fr.float_32());
9+
10+ Vector2f center_map_pixel = Vector2f::zero();
11+ center_map_pixel.x = fr.float_32();
12+ center_map_pixel.y = fr.float_32();
13+
14 uint32_t const display_flags = fr.unsigned_32();
15
16 if (InteractiveBase* const ibase = game.get_ibase()) {

Subscribers

People subscribed via source and target branches

to status/vote changes: