widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #08735
[Merge] lp:~widelands-dev/widelands/bug-1638394-render-road into lp:widelands
Janosch Peters has proposed merging lp:~widelands-dev/widelands/bug-1638394-render-road into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1638394 in widelands: "Crash on rendering roads"
https://bugs.launchpad.net/widelands/+bug/1638394
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1638394-render-road/+merge/310715
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.
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1638394-render-road into lp:widelands.
=== modified file 'src/graphic/gl/road_program.cc'
--- src/graphic/gl/road_program.cc 2016-10-24 20:07:22 +0000
+++ src/graphic/gl/road_program.cc 2016-11-13 08:26:42 +0000
@@ -72,12 +72,17 @@
const float road_thickness_x = (-delta_y / vector_length) * kRoadThicknessInPixels * scale;
const float road_thickness_y = (delta_x / vector_length) * kRoadThicknessInPixels * scale;
- assert(start.owner != nullptr);
+ assert(start.owner != nullptr || end.owner != nullptr);
+
+ Widelands::Player* visible_owner = start.owner;
+ if (start.owner == nullptr) {
+ visible_owner = end.owner;
+ }
+
const Image& texture =
- road_type == Widelands::RoadType::kNormal ?
- start.owner->tribe().road_textures().get_normal_texture(
- start.geometric_coords, direction) :
- start.owner->tribe().road_textures().get_busy_texture(start.geometric_coords, direction);
+ road_type == Widelands::RoadType::kNormal ?
+ visible_owner->tribe().road_textures().get_normal_texture(start.geometric_coords, direction) :
+ visible_owner->tribe().road_textures().get_busy_texture(start.geometric_coords, direction);
if (*gl_texture == 0) {
*gl_texture = texture.blit_data().texture_id;
}
Follow ups