Merge lp:~widelands-dev/widelands/kill_edge_overlay into lp:widelands

Proposed by SirVer
Status: Merged
Merged at revision: 8419
Proposed branch: lp:~widelands-dev/widelands/kill_edge_overlay
Merge into: lp:widelands
Diff against target: 639 lines (+61/-200)
16 files modified
src/ai/ai_help_structs.h (+4/-4)
src/graphic/CMakeLists.txt (+0/-1)
src/graphic/game_renderer.cc (+16/-14)
src/graphic/game_renderer.h (+9/-3)
src/logic/map.cc (+2/-2)
src/logic/map.h (+1/-1)
src/logic/map_objects/checkstep.h (+3/-4)
src/logic/widelands_geometry.h (+4/-7)
src/wui/CMakeLists.txt (+0/-10)
src/wui/edge_overlay_manager.cc (+0/-62)
src/wui/edge_overlay_manager.h (+0/-62)
src/wui/field_overlay_manager.h (+1/-3)
src/wui/interactive_base.cc (+3/-15)
src/wui/interactive_base.h (+10/-7)
src/wui/interactive_gamebase.h (+1/-0)
src/wui/mapview.cc (+7/-5)
To merge this branch: bzr merge lp:~widelands-dev/widelands/kill_edge_overlay
Reviewer Review Type Date Requested Status
GunChleoc Approve
Review via email: mp+328947@code.launchpad.net

Commit message

Remove the ill named EdgeOverlayManager.

It only dealt with road previews while in road building mode. This data is now
passed into the GameRenderer directly instead of being side loaded through
egbase.iabase.

- Replace Coords::ordering_functor through operator<.
- Fixed some warnings in ai headers that were disturbing while working.

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

Code LGTM, compiling now to do some testing.

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

Now tested and working.

@bunnybot merge

Revision history for this message
GunChleoc (gunchleoc) wrote :

@bunnybot merge

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 2530. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/263780860.
Appveyor build 2354. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_kill_edge_overlay-2354.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/ai/ai_help_structs.h'
2--- src/ai/ai_help_structs.h 2017-07-30 15:35:36 +0000
3+++ src/ai/ai_help_structs.h 2017-08-12 08:20:40 +0000
4@@ -609,7 +609,7 @@
5 uint32_t get_int();
6 uint16_t get_id() {
7 return id;
8- };
9+ }
10
11 private:
12 std::bitset<kFNeuronBitSize> core;
13@@ -622,7 +622,7 @@
14 void set_expantion_type(ExpansionMode);
15 ExpansionMode get_expansion_type() {
16 return type;
17- };
18+ }
19
20 private:
21 ExpansionMode type;
22@@ -654,14 +654,14 @@
23 uint16_t new_neuron_id() {
24 ++next_neuron_id;
25 return next_neuron_id - 1;
26- };
27+ }
28 void reset_neuron_id() {
29 next_neuron_id = 0;
30 }
31 uint16_t new_bi_neuron_id() {
32 ++next_bi_neuron_id;
33 return next_bi_neuron_id - 1;
34- };
35+ }
36 void reset_bi_neuron_id() {
37 next_bi_neuron_id = 0;
38 }
39
40=== modified file 'src/graphic/CMakeLists.txt'
41--- src/graphic/CMakeLists.txt 2017-05-21 18:17:14 +0000
42+++ src/graphic/CMakeLists.txt 2017-08-12 08:20:40 +0000
43@@ -183,7 +183,6 @@
44 graphic_terrain_programs
45 logic
46 wui
47- wui_edge_overlay_manager
48 wui_field_overlay_manager
49 wui_mapview_pixelfunctions
50 )
51
52=== modified file 'src/graphic/game_renderer.cc'
53--- src/graphic/game_renderer.cc 2017-06-08 16:11:05 +0000
54+++ src/graphic/game_renderer.cc 2017-08-12 08:20:40 +0000
55@@ -29,7 +29,6 @@
56 #include "logic/editor_game_base.h"
57 #include "logic/map_objects/world/world.h"
58 #include "logic/player.h"
59-#include "wui/edge_overlay_manager.h"
60 #include "wui/field_overlay_manager.h"
61 #include "wui/interactive_base.h"
62 #include "wui/mapviewpixelconstants.h"
63@@ -100,12 +99,12 @@
64 void draw_objects_for_visible_field(const EditorGameBase& egbase,
65 const FieldsToDraw::Field& field,
66 const float zoom,
67- const TextToDraw draw_text,
68+ const TextToDraw text_to_draw,
69 const Player* player,
70 RenderTarget* dst) {
71 BaseImmovable* const imm = field.fcoords.field->get_immovable();
72 if (imm != nullptr && imm->get_positions(egbase).front() == field.fcoords) {
73- TextToDraw draw_text_for_this_immovable = draw_text;
74+ TextToDraw draw_text_for_this_immovable = text_to_draw;
75 const Player* owner = imm->get_owner();
76 if (player != nullptr && owner != nullptr && !player->see_all() &&
77 player->is_hostile(*owner)) {
78@@ -117,7 +116,7 @@
79 egbase.get_gametime(), draw_text_for_this_immovable, field.rendertarget_pixel, zoom, dst);
80 }
81 for (Bob* bob = field.fcoords.field->get_first_bob(); bob; bob = bob->get_next_bob()) {
82- TextToDraw draw_text_for_this_bob = draw_text;
83+ TextToDraw draw_text_for_this_bob = text_to_draw;
84 const Player* owner = bob->get_owner();
85 if (player != nullptr && owner != nullptr && !player->see_all() &&
86 player->is_hostile(*owner)) {
87@@ -209,7 +208,7 @@
88 const float zoom,
89 const FieldsToDraw& fields_to_draw,
90 const Player* player,
91- const TextToDraw draw_text,
92+ const TextToDraw text_to_draw,
93 RenderTarget* dst) {
94 std::vector<FieldOverlayManager::OverlayInfo> overlay_info;
95 for (size_t current_index = 0; current_index < fields_to_draw.size(); ++current_index) {
96@@ -239,7 +238,7 @@
97 }
98
99 if (1 < field.vision) { // Render stuff that belongs to the node.
100- draw_objects_for_visible_field(egbase, field, zoom, draw_text, player, dst);
101+ draw_objects_for_visible_field(egbase, field, zoom, text_to_draw, player, dst);
102 } else if (field.vision == 1) {
103 // We never show census or statistics for objects in the fog.
104 assert(player != nullptr);
105@@ -313,23 +312,23 @@
106 const Vector2f& viewpoint,
107 const float zoom,
108 const Widelands::Player& player,
109- const TextToDraw draw_text,
110+ const Overlays& overlays,
111 RenderTarget* dst) {
112- draw(egbase, viewpoint, zoom, draw_text, &player, dst);
113+ draw(egbase, viewpoint, zoom, overlays, &player, dst);
114 }
115
116 void GameRenderer::rendermap(const Widelands::EditorGameBase& egbase,
117 const Vector2f& viewpoint,
118 const float zoom,
119- const TextToDraw draw_text,
120+ const Overlays& overlays,
121 RenderTarget* dst) {
122- draw(egbase, viewpoint, zoom, draw_text, nullptr, dst);
123+ draw(egbase, viewpoint, zoom, overlays, nullptr, dst);
124 }
125
126 void GameRenderer::draw(const EditorGameBase& egbase,
127 const Vector2f& viewpoint,
128 const float zoom,
129- const TextToDraw draw_text,
130+ const Overlays& overlays,
131 const Player* player,
132 RenderTarget* dst) {
133 assert(viewpoint.x >= 0); // divisions involving negative numbers are bad
134@@ -367,7 +366,6 @@
135 const int surface_height = surface->height();
136
137 Map& map = egbase.map();
138- const EdgeOverlayManager& edge_overlay_manager = egbase.get_ibase()->edge_overlay_manager();
139 const uint32_t gametime = egbase.get_gametime();
140
141 const float scale = 1.f / zoom;
142@@ -423,7 +421,11 @@
143 f.is_border = pf.border;
144 }
145 }
146- f.roads |= edge_overlay_manager.get_overlay(f.fcoords);
147+
148+ const auto it = overlays.road_building_preview.find(f.fcoords);
149+ if (it != overlays.road_building_preview.end()) {
150+ f.roads |= it->second;
151+ }
152 }
153 }
154
155@@ -451,5 +453,5 @@
156 i.program_id = RenderQueue::Program::kTerrainRoad;
157 RenderQueue::instance().enqueue(i);
158
159- draw_objects(egbase, scale, fields_to_draw_, player, draw_text, dst);
160+ draw_objects(egbase, scale, fields_to_draw_, player, overlays.text_to_draw, dst);
161 }
162
163=== modified file 'src/graphic/game_renderer.h'
164--- src/graphic/game_renderer.h 2017-01-25 18:55:59 +0000
165+++ src/graphic/game_renderer.h 2017-08-12 08:20:40 +0000
166@@ -21,6 +21,7 @@
167 #define WL_GRAPHIC_GAME_RENDERER_H
168
169 #include <memory>
170+#include <map>
171
172 #include "base/macros.h"
173 #include "base/vector.h"
174@@ -37,6 +38,11 @@
175 // Renders the MapView on screen.
176 class GameRenderer {
177 public:
178+ struct Overlays {
179+ TextToDraw text_to_draw;
180+ std::map<Widelands::Coords, uint8_t> road_building_preview;
181+ };
182+
183 GameRenderer();
184 ~GameRenderer();
185
186@@ -47,7 +53,7 @@
187 const Vector2f& viewpoint,
188 float scale,
189 const Widelands::Player& player,
190- TextToDraw draw_text,
191+ const Overlays& overlays,
192 RenderTarget* dst);
193
194 // Renders the map from an omniscient perspective. This is used
195@@ -55,7 +61,7 @@
196 void rendermap(const Widelands::EditorGameBase& egbase,
197 const Vector2f& viewpoint,
198 float scale,
199- TextToDraw draw_text,
200+ const Overlays& overlays,
201 RenderTarget* dst);
202
203 private:
204@@ -64,7 +70,7 @@
205 void draw(const Widelands::EditorGameBase& egbase,
206 const Vector2f& viewpoint,
207 float scale,
208- TextToDraw draw_text,
209+ const Overlays& overlays,
210 const Widelands::Player* player,
211 RenderTarget* dst);
212
213
214=== modified file 'src/logic/map.cc'
215--- src/logic/map.cc 2017-01-30 14:40:12 +0000
216+++ src/logic/map.cc 2017-08-12 08:20:40 +0000
217@@ -1967,11 +1967,11 @@
218 bool Map::allows_seafaring() {
219 Map::PortSpacesSet port_spaces = get_port_spaces();
220 std::vector<Coords> portdocks;
221- std::set<Coords, Coords::OrderingFunctor> swim_coords;
222+ std::set<Coords> swim_coords;
223
224 for (const Coords& c : port_spaces) {
225 std::queue<Coords> q_positions;
226- std::set<Coords, Coords::OrderingFunctor> visited_positions;
227+ std::set<Coords> visited_positions;
228 FCoords fc = get_fcoords(c);
229 portdocks = find_portdock(fc);
230
231
232=== modified file 'src/logic/map.h'
233--- src/logic/map.h 2017-01-25 18:55:59 +0000
234+++ src/logic/map.h 2017-08-12 08:20:40 +0000
235@@ -146,7 +146,7 @@
236 friend struct MapElementalPacket;
237 friend struct WidelandsMapLoader;
238
239- using PortSpacesSet = std::set<Coords, Coords::OrderingFunctor>;
240+ using PortSpacesSet = std::set<Coords>;
241 using Objectives = std::map<std::string, std::unique_ptr<Objective>>;
242 using SuggestedTeam = std::vector<PlayerNumber>; // Players in a team
243 using SuggestedTeamLineup =
244
245=== modified file 'src/logic/map_objects/checkstep.h'
246--- src/logic/map_objects/checkstep.h 2017-01-25 18:55:59 +0000
247+++ src/logic/map_objects/checkstep.h 2017-08-12 08:20:40 +0000
248@@ -183,11 +183,10 @@
249 bool reachable_dest(Map&, FCoords dest) const;
250
251 private:
252- // It is OK to use Coords::OrderingFunctor because the ordering of the set
253- // does not matter, as long as it is system independent (for parallel
254- // simulation).
255+ // The ordering of the set does not matter, as long as it is system
256+ // independent (for parallel simulation).
257 // The only thing that matters is whether a location is in the set.
258- std::set<Coords, Coords::OrderingFunctor> allowed_locations_;
259+ std::set<Coords> allowed_locations_;
260 };
261 }
262
263
264=== modified file 'src/logic/widelands_geometry.h'
265--- src/logic/widelands_geometry.h 2017-01-25 18:55:59 +0000
266+++ src/logic/widelands_geometry.h 2017-08-12 08:20:40 +0000
267@@ -54,15 +54,12 @@
268
269 bool operator==(const Coords& other) const;
270 bool operator!=(const Coords& other) const;
271+ bool operator<(const Coords& other) const {
272+ return std::forward_as_tuple(y, x) < std::forward_as_tuple(other.y, other.x);
273+ }
274+
275 operator bool() const;
276
277- // Ordering functor for use with std:: containers.
278- struct OrderingFunctor {
279- bool operator()(const Coords& a, const Coords& b) const {
280- return std::forward_as_tuple(a.y, a.x) < std::forward_as_tuple(b.y, b.x);
281- }
282- };
283-
284 // Move the coords to the 'new_origin'.
285 void reorigin(Coords new_origin, const Extent& extent);
286
287
288=== modified file 'src/wui/CMakeLists.txt'
289--- src/wui/CMakeLists.txt 2017-05-14 14:40:24 +0000
290+++ src/wui/CMakeLists.txt 2017-08-12 08:20:40 +0000
291@@ -49,15 +49,6 @@
292 )
293
294
295-wl_library(wui_edge_overlay_manager
296- SRCS
297- edge_overlay_manager.cc
298- edge_overlay_manager.h
299- DEPENDS
300- base_macros
301- logic_widelands_geometry
302-)
303-
304 wl_library(wui_mapview_pixelfunctions
305 SRCS
306 mapviewpixelconstants.h
307@@ -273,7 +264,6 @@
308 ui_basic
309 wui_chat_ui
310 wui_economy_options
311- wui_edge_overlay_manager
312 wui_field_overlay_manager
313 wui_mapview
314 wui_mapview_pixelfunctions
315
316=== removed file 'src/wui/edge_overlay_manager.cc'
317--- src/wui/edge_overlay_manager.cc 2017-01-25 18:55:59 +0000
318+++ src/wui/edge_overlay_manager.cc 1970-01-01 00:00:00 +0000
319@@ -1,62 +0,0 @@
320-/*
321- * Copyright (C) 2006-2017 by the Widelands Development Team
322- *
323- * This program is free software; you can redistribute it and/or
324- * modify it under the terms of the GNU General Public License
325- * as published by the Free Software Foundation; either version 2
326- * of the License, or (at your option) any later version.
327- *
328- * This program is distributed in the hope that it will be useful,
329- * but WITHOUT ANY WARRANTY; without even the implied warranty of
330- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
331- * GNU General Public License for more details.
332- *
333- * You should have received a copy of the GNU General Public License
334- * along with this program; if not, write to the Free Software
335- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
336- *
337- */
338-
339-#include "wui/edge_overlay_manager.h"
340-
341-EdgeOverlayManager::EdgeOverlayManager() : current_overlay_id_(0) {
342-}
343-
344-EdgeOverlayManager::OverlayId EdgeOverlayManager::next_overlay_id() {
345- ++current_overlay_id_;
346- return current_overlay_id_;
347-}
348-
349-void EdgeOverlayManager::register_overlay(Widelands::Coords const c,
350- uint8_t const where,
351- OverlayId const overlay_id) {
352- const RegisteredRoadOverlays overlay = {overlay_id, where};
353- RegisteredRoadOverlaysMap::iterator it = overlays_.find(c);
354- if (it == overlays_.end())
355- overlays_.insert(std::pair<const Widelands::Coords, RegisteredRoadOverlays>(c, overlay));
356- else
357- it->second = overlay;
358-}
359-
360-void EdgeOverlayManager::remove_overlay(const Widelands::Coords c) {
361- const RegisteredRoadOverlaysMap::iterator it = overlays_.find(c);
362- if (it != overlays_.end())
363- overlays_.erase(it);
364-}
365-
366-void EdgeOverlayManager::remove_overlay(OverlayId const overlay_id) {
367- RegisteredRoadOverlaysMap::iterator it = overlays_.begin();
368- const RegisteredRoadOverlaysMap::const_iterator end = overlays_.end();
369- while (it != end)
370- if (it->second.overlay_id == overlay_id)
371- overlays_.erase(it++); // Necessary!
372- else
373- ++it;
374-}
375-
376-uint8_t EdgeOverlayManager::get_overlay(const Widelands::Coords c) const {
377- RegisteredRoadOverlaysMap::const_iterator const it = overlays_.find(c);
378- if (it != overlays_.end())
379- return it->second.where;
380- return 0;
381-}
382
383=== removed file 'src/wui/edge_overlay_manager.h'
384--- src/wui/edge_overlay_manager.h 2017-01-25 18:55:59 +0000
385+++ src/wui/edge_overlay_manager.h 1970-01-01 00:00:00 +0000
386@@ -1,62 +0,0 @@
387-/*
388- * Copyright (C) 2006-2017 by the Widelands Development Team
389- *
390- * This program is free software; you can redistribute it and/or
391- * modify it under the terms of the GNU General Public License
392- * as published by the Free Software Foundation; either version 2
393- * of the License, or (at your option) any later version.
394- *
395- * This program is distributed in the hope that it will be useful,
396- * but WITHOUT ANY WARRANTY; without even the implied warranty of
397- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
398- * GNU General Public License for more details.
399- *
400- * You should have received a copy of the GNU General Public License
401- * along with this program; if not, write to the Free Software
402- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
403- *
404- */
405-
406-#ifndef WL_WUI_EDGE_OVERLAY_MANAGER_H
407-#define WL_WUI_EDGE_OVERLAY_MANAGER_H
408-
409-#include <map>
410-
411-#include "base/macros.h"
412-#include "logic/widelands_geometry.h"
413-
414-// Similar to FieldOverlayManager, this class cares for overlays that are drawn
415-// onto the edges of triangles.
416-class EdgeOverlayManager {
417-public:
418- // A unique id identifying a registered overlay.
419- using OverlayId = uint32_t;
420-
421- EdgeOverlayManager();
422-
423- /// Get a unique, unused job id.
424- OverlayId next_overlay_id();
425-
426- // When a road overlay information is requested the same data as for a
427- // field is returned (a uint8_t which needs to be ANDed).
428- void register_overlay(Widelands::Coords, uint8_t where, OverlayId overlay_id = 0);
429- void remove_overlay(Widelands::Coords);
430- void remove_overlay(OverlayId overlay_id);
431- uint8_t get_overlay(Widelands::Coords c) const;
432-
433-private:
434- struct RegisteredRoadOverlays {
435- OverlayId overlay_id;
436- uint8_t where;
437- };
438-
439- using RegisteredRoadOverlaysMap =
440- std::map<const Widelands::Coords, RegisteredRoadOverlays, Widelands::Coords::OrderingFunctor>;
441-
442- OverlayId current_overlay_id_;
443- RegisteredRoadOverlaysMap overlays_;
444-
445- DISALLOW_COPY_AND_ASSIGN(EdgeOverlayManager);
446-};
447-
448-#endif // end of include guard: WL_WUI_EDGE_OVERLAY_MANAGER_H
449
450=== modified file 'src/wui/field_overlay_manager.h'
451--- src/wui/field_overlay_manager.h 2017-05-13 11:25:24 +0000
452+++ src/wui/field_overlay_manager.h 2017-08-12 08:20:40 +0000
453@@ -122,9 +122,7 @@
454 int level;
455 };
456
457- using RegisteredOverlaysMap = std::multimap<const Widelands::Coords,
458- RegisteredOverlays,
459- Widelands::Coords::OrderingFunctor>;
460+ using RegisteredOverlaysMap = std::multimap<const Widelands::Coords, RegisteredOverlays>;
461
462 // Returns the index into buildhelp_infos_ for the correct fieldcaps for
463 // 'fc' according to the current 'callback_'.
464
465=== modified file 'src/wui/interactive_base.cc'
466--- src/wui/interactive_base.cc 2017-07-24 20:35:46 +0000
467+++ src/wui/interactive_base.cc 2017-08-12 08:20:40 +0000
468@@ -45,7 +45,6 @@
469 #include "logic/player.h"
470 #include "profile/profile.h"
471 #include "scripting/lua_interface.h"
472-#include "wui/edge_overlay_manager.h"
473 #include "wui/field_overlay_manager.h"
474 #include "wui/game_chat_menu.h"
475 #include "wui/game_debug_ui.h"
476@@ -85,7 +84,6 @@
477 toolbar_(this, 0, 0, UI::Box::Horizontal),
478 m(new InteractiveBaseInternals(new QuickNavigation(this))),
479 field_overlay_manager_(new FieldOverlayManager()),
480- edge_overlay_manager_(new EdgeOverlayManager()),
481 egbase_(the_egbase),
482 #ifndef NDEBUG // not in releases
483 display_flags_(dfDebug),
484@@ -95,7 +93,6 @@
485 lastframe_(SDL_GetTicks()),
486 frametime_(0),
487 avg_usframetime_(0),
488- jobid_(0),
489 road_buildhelp_overlay_jobid_(0),
490 buildroad_(nullptr),
491 road_build_player_(0),
492@@ -680,12 +677,11 @@
493 */
494 void InteractiveBase::roadb_add_overlay() {
495 assert(buildroad_);
496+ assert(road_building_preview_.empty());
497
498 Map& map = egbase().map();
499
500 // preview of the road
501- assert(!jobid_);
502- jobid_ = field_overlay_manager_->next_overlay_id();
503 const CoordPath::StepVector::size_type nr_steps = buildroad_->get_nsteps();
504 for (CoordPath::StepVector::size_type idx = 0; idx < nr_steps; ++idx) {
505 Widelands::Direction dir = (*buildroad_)[idx];
506@@ -695,12 +691,8 @@
507 map.get_neighbour(c, dir, &c);
508 dir = Widelands::get_reverse_dir(dir);
509 }
510-
511 int32_t const shift = 2 * (dir - Widelands::WALK_E);
512-
513- uint8_t set_to = edge_overlay_manager_->get_overlay(c);
514- set_to |= Widelands::RoadType::kNormal << shift;
515- edge_overlay_manager_->register_overlay(c, set_to, jobid_);
516+ road_building_preview_[c] |= (Widelands::RoadType::kNormal << shift);
517 }
518
519 // build hints
520@@ -762,11 +754,7 @@
521 void InteractiveBase::roadb_remove_overlay() {
522 assert(buildroad_);
523
524- // preview of the road
525- if (jobid_) {
526- edge_overlay_manager_->remove_overlay(jobid_);
527- }
528- jobid_ = 0;
529+ road_building_preview_.clear();
530
531 // build hints
532 if (road_buildhelp_overlay_jobid_) {
533
534=== modified file 'src/wui/interactive_base.h'
535--- src/wui/interactive_base.h 2017-06-27 18:10:20 +0000
536+++ src/wui/interactive_base.h 2017-08-12 08:20:40 +0000
537@@ -20,6 +20,7 @@
538 #ifndef WL_WUI_INTERACTIVE_BASE_H
539 #define WL_WUI_INTERACTIVE_BASE_H
540
541+#include <map>
542 #include <memory>
543
544 #include <SDL_keycode.h>
545@@ -36,7 +37,6 @@
546 #include "ui_basic/unique_window.h"
547 #include "wui/chatoverlay.h"
548 #include "wui/debugconsole.h"
549-#include "wui/edge_overlay_manager.h"
550 #include "wui/field_overlay_manager.h"
551 #include "wui/mapview.h"
552 #include "wui/minimap.h"
553@@ -158,10 +158,6 @@
554 return field_overlay_manager_.get();
555 }
556
557- const EdgeOverlayManager& edge_overlay_manager() const {
558- return *edge_overlay_manager_;
559- }
560-
561 void toggle_minimap();
562 void toggle_buildhelp();
563
564@@ -171,6 +167,10 @@
565 // Sets the landmark for the keyboard 'key' to 'point'
566 void set_landmark(size_t key, const MapView::View& view);
567
568+ const std::map<Widelands::Coords, uint8_t>& road_building_preview() const {
569+ return road_building_preview_;
570+ }
571+
572 protected:
573 /// Adds a toolbar button to the toolbar
574 /// \param image_basename: File path for button image starting from 'images' and without
575@@ -242,7 +242,11 @@
576 std::unique_ptr<InteractiveBaseInternals> m;
577
578 std::unique_ptr<FieldOverlayManager> field_overlay_manager_;
579- std::unique_ptr<EdgeOverlayManager> edge_overlay_manager_;
580+
581+ // The roads that are displayed while a road is being build. They are not
582+ // yet logically in the game, but need to be displayed for the user as
583+ // visual guide. The data type is the same as for Field::road.
584+ std::map<Widelands::Coords, uint8_t> road_building_preview_;
585
586 std::unique_ptr<Notifications::Subscriber<GraphicResolutionChanged>>
587 graphic_resolution_changed_subscriber_;
588@@ -253,7 +257,6 @@
589 uint32_t frametime_; // in millseconds
590 uint32_t avg_usframetime_; // in microseconds!
591
592- EdgeOverlayManager::OverlayId jobid_;
593 FieldOverlayManager::OverlayId road_buildhelp_overlay_jobid_;
594 Widelands::CoordPath* buildroad_; // path for the new road
595 Widelands::PlayerNumber road_build_player_;
596
597=== modified file 'src/wui/interactive_gamebase.h'
598--- src/wui/interactive_gamebase.h 2017-02-28 16:00:20 +0000
599+++ src/wui/interactive_gamebase.h 2017-08-12 08:20:40 +0000
600@@ -54,6 +54,7 @@
601 Section& global_s,
602 PlayerType pt = NONE,
603 bool multiplayer = false);
604+ ~InteractiveGameBase() override {}
605 Widelands::Game* get_game() const;
606 Widelands::Game& game() const;
607
608
609=== modified file 'src/wui/mapview.cc'
610--- src/wui/mapview.cc 2017-05-13 18:48:26 +0000
611+++ src/wui/mapview.cc 2017-08-12 08:20:40 +0000
612@@ -392,21 +392,23 @@
613 return;
614 }
615
616- TextToDraw draw_text = TextToDraw::kNone;
617+ TextToDraw text_to_draw = TextToDraw::kNone;
618 auto display_flags = intbase().get_display_flags();
619 if (display_flags & InteractiveBase::dfShowCensus) {
620- draw_text = draw_text | TextToDraw::kCensus;
621+ text_to_draw = text_to_draw | TextToDraw::kCensus;
622 }
623 if (display_flags & InteractiveBase::dfShowStatistics) {
624- draw_text = draw_text | TextToDraw::kStatistics;
625+ text_to_draw = text_to_draw | TextToDraw::kStatistics;
626 }
627
628 if (upcast(InteractivePlayer const, interactive_player, &intbase())) {
629+ const GameRenderer::Overlays overlays{text_to_draw, interactive_player->road_building_preview()};
630 renderer_->rendermap(
631- egbase, view_.viewpoint, view_.zoom, interactive_player->player(), draw_text, &dst);
632+ egbase, view_.viewpoint, view_.zoom, interactive_player->player(), overlays, &dst);
633 } else {
634+ const GameRenderer::Overlays overlays{static_cast<TextToDraw>(text_to_draw), {}};
635 renderer_->rendermap(
636- egbase, view_.viewpoint, view_.zoom, static_cast<TextToDraw>(draw_text), &dst);
637+ egbase, view_.viewpoint, view_.zoom, overlays, &dst);
638 }
639 }
640

Subscribers

People subscribed via source and target branches

to status/vote changes: