Merge lp:~widelands-dev/widelands/bug-1638394-render-road into lp:widelands

Proposed by xxx-deleted
Status: Merged
Merged at revision: 8174
Proposed branch: lp:~widelands-dev/widelands/bug-1638394-render-road
Merge into: lp:widelands
Diff against target: 26 lines (+10/-5)
1 file modified
src/graphic/gl/road_program.cc (+10/-5)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1638394-render-road
Reviewer Review Type Date Requested Status
GunChleoc Approve
Review via email: mp+310715@code.launchpad.net

Commit message

Fix a crash with rendering roads in previously visible areas:
If the owner of the starting field of the road is not visible, the owner of the end field of the road is used to determine the road texture in RoadProgram::add_road.

Description of the change

If the owner of the starting field of the road is not visible, the owner of the end field of the road is used to determine the road texture in RoadProgram::add_road.

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

LGTM :)

@bunnybot merge

review: Approve
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 1598. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/175444991.
Appveyor build 1436. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1638394_render_road-1436.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/graphic/gl/road_program.cc'
2--- src/graphic/gl/road_program.cc 2016-10-24 20:07:22 +0000
3+++ src/graphic/gl/road_program.cc 2016-11-13 08:26:42 +0000
4@@ -72,12 +72,17 @@
5 const float road_thickness_x = (-delta_y / vector_length) * kRoadThicknessInPixels * scale;
6 const float road_thickness_y = (delta_x / vector_length) * kRoadThicknessInPixels * scale;
7
8- assert(start.owner != nullptr);
9+ assert(start.owner != nullptr || end.owner != nullptr);
10+
11+ Widelands::Player* visible_owner = start.owner;
12+ if (start.owner == nullptr) {
13+ visible_owner = end.owner;
14+ }
15+
16 const Image& texture =
17- road_type == Widelands::RoadType::kNormal ?
18- start.owner->tribe().road_textures().get_normal_texture(
19- start.geometric_coords, direction) :
20- start.owner->tribe().road_textures().get_busy_texture(start.geometric_coords, direction);
21+ road_type == Widelands::RoadType::kNormal ?
22+ visible_owner->tribe().road_textures().get_normal_texture(start.geometric_coords, direction) :
23+ visible_owner->tribe().road_textures().get_busy_texture(start.geometric_coords, direction);
24 if (*gl_texture == 0) {
25 *gl_texture = texture.blit_data().texture_id;
26 }

Subscribers

People subscribed via source and target branches

to status/vote changes: