widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #11054
[Merge] lp:~widelands-dev/widelands/move_out_triangle_index into lp:widelands
SirVer has proposed merging lp:~widelands-dev/widelands/move_out_triangle_index into lp:widelands.
Commit message:
Pull out TriangleIndex from TCoords.
It is independently useful and does not require the templating that TCoords has.
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/move_out_triangle_index/+merge/329919
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/move_out_triangle_index into lp:widelands.
=== modified file 'src/editor/editorinteractive.cc'
--- src/editor/editorinteractive.cc 2017-08-28 19:34:33 +0000
+++ src/editor/editorinteractive.cc 2017-08-30 13:39:17 +0000
@@ -675,7 +675,7 @@
map_view()->set_view(MapView::View{Vector2f::zero(), 1.f}, MapView::Transition::Jump);
set_sel_pos(Widelands::NodeAndTriangle<>(
Widelands::Coords(0, 0),
- Widelands::TCoords<>(Widelands::Coords(0, 0), Widelands::TCoords<>::D)));
+ Widelands::TCoords<>(Widelands::Coords(0, 0), Widelands::TriangleIndex::D)));
break;
case MapWas::kGloballyMutated:
=== modified file 'src/editor/tools/info_tool.cc'
--- src/editor/tools/info_tool.cc 2017-08-16 05:10:15 +0000
+++ src/editor/tools/info_tool.cc 2017-08-30 13:39:17 +0000
@@ -115,7 +115,7 @@
const Widelands::Field& tf = (*map)[center.triangle];
const Widelands::TerrainDescription& ter = world.terrain_descr(
- center.triangle.t == Widelands::TCoords<>::D ? tf.terrain_d() : tf.terrain_r());
+ center.triangle.t == Widelands::TriangleIndex::D ? tf.terrain_d() : tf.terrain_r());
buf +=
"• " + (boost::format(pgettext("terrain_name", "Name: %s")) % ter.descname()).str() + "\n";
=== modified file 'src/editor/tools/set_terrain_tool.cc'
--- src/editor/tools/set_terrain_tool.cc 2017-01-25 18:55:59 +0000
+++ src/editor/tools/set_terrain_tool.cc 2017-08-30 13:39:17 +0000
@@ -29,7 +29,7 @@
EditorInteractive& /* parent */,
EditorActionArgs* args,
Widelands::Map* map) {
- assert(center.triangle.t == TCoords<>::D || center.triangle.t == TCoords<>::R);
+ assert(center.triangle.t == TriangleIndex::D || center.triangle.t == TriangleIndex::R);
uint16_t const radius = args->sel_radius;
int32_t max = 0;
@@ -70,7 +70,7 @@
EditorInteractive& /* parent */,
EditorActionArgs* args,
Widelands::Map* map) {
- assert(center.triangle.t == TCoords<>::D || center.triangle.t == TCoords<>::R);
+ assert(center.triangle.t == TriangleIndex::D || center.triangle.t == TriangleIndex::R);
uint16_t const radius = args->sel_radius;
if (!args->terrain_type.empty()) {
int32_t max = 0;
=== modified file 'src/logic/editor_game_base.cc'
--- src/logic/editor_game_base.cc 2017-08-20 15:45:50 +0000
+++ src/logic/editor_game_base.cc 2017-08-30 13:39:17 +0000
@@ -180,7 +180,7 @@
iterate_players_existing_const(plnum, kMaxPlayers, *this, p) {
Player::Field& player_field = p->fields_[i];
if (1 < player_field.vision) {
- player_field.map_object_descr[TCoords<>::None] = descr;
+ player_field.map_object_descr[TriangleIndex::None] = descr;
}
}
}
=== modified file 'src/logic/field.h'
--- src/logic/field.h 2017-08-16 13:23:15 +0000
+++ src/logic/field.h 2017-08-30 13:39:17 +0000
@@ -110,10 +110,10 @@
void set_terrains(const Terrains& i) {
terrains = i;
}
- void set_terrain(const TCoords<FCoords>::TriangleIndex& t, DescriptionIndex const i)
+ void set_terrain(const TriangleIndex& t, DescriptionIndex const i)
{
- if (t == TCoords<FCoords>::D)
+ if (t == TriangleIndex::D)
set_terrain_d(i);
else
set_terrain_r(i);
=== modified file 'src/logic/map.cc'
--- src/logic/map.cc 2017-08-28 13:37:51 +0000
+++ src/logic/map.cc 2017-08-30 13:39:17 +0000
@@ -1755,7 +1755,7 @@
// check south-west vertex if d-Triangle is changed, check east vertex if r-Triangle is changed
Widelands::FCoords f_sw_e(c, c.field);
get_neighbour(
- f_sw_e, c.t == TCoords<FCoords>::D ? Widelands::WALK_SW : Widelands::WALK_E, &f_sw_e);
+ f_sw_e, c.t == TriangleIndex::D ? Widelands::WALK_SW : Widelands::WALK_E, &f_sw_e);
if (!is_resource_valid(world, f_sw_e, f_sw_e.field->get_resources())) {
clear_resources(f_sw_e);
}
=== modified file 'src/logic/maptriangleregion.cc'
--- src/logic/maptriangleregion.cc 2017-01-25 18:55:59 +0000
+++ src/logic/maptriangleregion.cc 2017-08-30 13:39:17 +0000
@@ -24,13 +24,13 @@
template <>
MapTriangleRegion<>::MapTriangleRegion(const Map& map, Area<TCoords<>> area)
: radius_is_odd_(area.radius & 1) {
- assert(area.t == TCoords<>::R || area.t == TCoords<>::D);
+ assert(area.t == TriangleIndex::R || area.t == TriangleIndex::D);
const uint16_t radius_plus_1 = area.radius + 1;
const uint16_t half_radius_rounded_down = area.radius / 2;
row_length_ = radius_plus_1;
for (uint32_t i = half_radius_rounded_down; i; --i)
map.get_tln(area, &area);
- if (area.t == TCoords<>::R) {
+ if (area.t == TriangleIndex::R) {
left_ = area;
if (area.radius) {
remaining_rows_in_upper_phase_ = half_radius_rounded_down + 1;
@@ -40,17 +40,17 @@
phase_ = Top;
row_length_ = area.radius + 2;
remaining_in_row_ = radius_plus_1 / 2;
- area.t = TCoords<>::D;
+ area.t = TriangleIndex::D;
} else {
phase_ = Upper;
remaining_in_row_ = row_length_ = radius_plus_1;
- area.t = TCoords<>::R;
+ area.t = TriangleIndex::R;
}
} else {
assert(area.radius == 0);
phase_ = Bottom;
remaining_in_row_ = 0;
- area.t = TCoords<>::R;
+ area.t = TriangleIndex::R;
}
} else {
remaining_rows_in_upper_phase_ = radius_plus_1 / 2;
@@ -60,13 +60,13 @@
left_ = area;
phase_ = Upper;
remaining_in_row_ = row_length_ = area.radius + 2;
- area.t = TCoords<>::R;
+ area.t = TriangleIndex::R;
} else {
map.get_bln(area, &left_);
phase_ = Top;
row_length_ = area.radius + 3;
remaining_in_row_ = half_radius_rounded_down + (0 < area.radius);
- area.t = TCoords<>::D;
+ area.t = TriangleIndex::D;
}
}
location_ = area;
@@ -90,10 +90,10 @@
break;
case Upper:
if (remaining_in_row_) {
- if (location_.t == TCoords<>::D)
- location_.t = TCoords<>::R;
+ if (location_.t == TriangleIndex::D)
+ location_.t = TriangleIndex::R;
else
- location_ = TCoords<>(map.r_n(location_), TCoords<>::D);
+ location_ = TCoords<>(map.r_n(location_), TriangleIndex::D);
} else {
if (--remaining_rows_in_upper_phase_) {
row_length_ += 2;
@@ -103,7 +103,7 @@
phase_ = Lower;
assert(row_length_ >= 2);
row_length_ -= 2;
- } else if (location_.t == TCoords<>::R) {
+ } else if (location_.t == TriangleIndex::R) {
phase_ = Bottom;
row_length_ /= 2;
} else
@@ -116,16 +116,16 @@
break;
case Lower:
if (remaining_in_row_) {
- if (location_.t == TCoords<>::D)
- location_.t = TCoords<>::R;
+ if (location_.t == TriangleIndex::D)
+ location_.t = TriangleIndex::R;
else
- location_ = TCoords<>(map.r_n(location_), TCoords<>::D);
+ location_ = TCoords<>(map.r_n(location_), TriangleIndex::D);
} else {
if (--remaining_rows_in_lower_phase_) {
assert(row_length_ >= 2);
remaining_in_row_ = row_length_ -= 2;
left_ = map.br_n(left_);
- } else if (location_.t == TCoords<>::R) {
+ } else if (location_.t == TriangleIndex::R) {
phase_ = Bottom;
remaining_in_row_ = row_length_ / 2;
left_ = map.br_n(left_);
@@ -145,13 +145,13 @@
template <>
MapTriangleRegion<TCoords<FCoords>>::MapTriangleRegion(const Map& map, Area<TCoords<FCoords>> area)
: radius_is_odd_(area.radius & 1) {
- assert(area.t == TCoords<FCoords>::R || area.t == TCoords<FCoords>::D);
+ assert(area.t == TriangleIndex::R || area.t == TriangleIndex::D);
const uint16_t radius_plus_1 = area.radius + 1;
const uint16_t half_radius_rounded_down = area.radius / 2;
row_length_ = radius_plus_1;
for (uint32_t i = half_radius_rounded_down; i; --i)
map.get_tln(area, &area);
- if (area.t == TCoords<FCoords>::R) {
+ if (area.t == TriangleIndex::R) {
left_ = area;
if (area.radius) {
remaining_rows_in_upper_phase_ = half_radius_rounded_down + 1;
@@ -161,16 +161,16 @@
phase_ = Top;
row_length_ = area.radius + 2;
remaining_in_row_ = radius_plus_1 / 2;
- area.t = TCoords<FCoords>::D;
+ area.t = TriangleIndex::D;
} else {
phase_ = Upper;
remaining_in_row_ = row_length_ = radius_plus_1;
- area.t = TCoords<FCoords>::R;
+ area.t = TriangleIndex::R;
}
} else {
phase_ = Bottom;
remaining_in_row_ = 0;
- area.t = TCoords<FCoords>::R;
+ area.t = TriangleIndex::R;
}
} else {
remaining_rows_in_upper_phase_ = radius_plus_1 / 2;
@@ -180,13 +180,13 @@
left_ = area;
phase_ = Upper;
remaining_in_row_ = row_length_ = area.radius + 2;
- area.t = TCoords<FCoords>::R;
+ area.t = TriangleIndex::R;
} else {
map.get_bln(area, &left_);
phase_ = Top;
row_length_ = area.radius + 3;
remaining_in_row_ = half_radius_rounded_down + (0 < area.radius);
- area.t = TCoords<FCoords>::D;
+ area.t = TriangleIndex::D;
}
}
location_ = area;
@@ -211,10 +211,10 @@
break;
case Upper:
if (remaining_in_row_) {
- if (location_.t == TCoords<FCoords>::D)
- location_.t = TCoords<FCoords>::R;
+ if (location_.t == TriangleIndex::D)
+ location_.t = TriangleIndex::R;
else
- location_ = TCoords<FCoords>(map.r_n(location_), TCoords<FCoords>::D);
+ location_ = TCoords<FCoords>(map.r_n(location_), TriangleIndex::D);
} else {
if (--remaining_rows_in_upper_phase_) {
row_length_ += 2;
@@ -224,7 +224,7 @@
phase_ = Lower;
assert(row_length_ >= 2);
row_length_ -= 2;
- } else if (location_.t == TCoords<FCoords>::R) {
+ } else if (location_.t == TriangleIndex::R) {
phase_ = Bottom;
row_length_ /= 2;
} else
@@ -237,16 +237,16 @@
break;
case Lower:
if (remaining_in_row_) {
- if (location_.t == TCoords<FCoords>::D)
- location_.t = TCoords<FCoords>::R;
+ if (location_.t == TriangleIndex::D)
+ location_.t = TriangleIndex::R;
else
- location_ = TCoords<FCoords>(map.r_n(location_), TCoords<FCoords>::D);
+ location_ = TCoords<FCoords>(map.r_n(location_), TriangleIndex::D);
} else {
if (--remaining_rows_in_lower_phase_) {
assert(row_length_ >= 2);
remaining_in_row_ = row_length_ -= 2;
left_ = map.br_n(left_);
- } else if (location_.t == TCoords<FCoords>::R) {
+ } else if (location_.t == TriangleIndex::R) {
phase_ = Bottom;
remaining_in_row_ = row_length_ / 2;
left_ = map.br_n(left_);
=== modified file 'src/logic/maptriangleregion.h'
--- src/logic/maptriangleregion.h 2017-08-16 05:09:40 +0000
+++ src/logic/maptriangleregion.h 2017-08-30 13:39:17 +0000
@@ -37,8 +37,8 @@
* left to right in each row and I see no reason why that would ever change.)
*
* The initial coordinates must refer to a triangle
- * (TCoords<>::D or TCoords<>::R). Use MapRegion instead for nodes
- * (TCoords<>::None).
+ * (TriangleIndex::D or TriangleIndex::R). Use MapRegion instead for nodes
+ * (TriangleIndex::None).
*/
template <typename CoordsType = TCoords<>, typename RadiusType = uint16_t>
struct MapTriangleRegion {
@@ -64,7 +64,7 @@
};
template <> struct MapTriangleRegion<FCoords> {
MapTriangleRegion(const Map& map, const Area<FCoords>& area)
- : area_(TCoords<FCoords>(area, TCoords<FCoords>::D), area.radius + 1),
+ : area_(TCoords<FCoords>(area, TriangleIndex::D), area.radius + 1),
rowwidth_(area_.radius * 2 + 1),
remaining_in_row_(rowwidth_),
remaining_rows_(area_.radius * 2) {
@@ -79,21 +79,21 @@
bool advance(const Map& map) {
if (--remaining_in_row_) {
- if (area_.t == TCoords<FCoords>::D)
- area_.t = TCoords<FCoords>::R;
+ if (area_.t == TriangleIndex::D)
+ area_.t = TriangleIndex::R;
else {
- area_.t = TCoords<FCoords>::D;
+ area_.t = TriangleIndex::D;
map.get_rn(area_, &area_);
}
} else if (area_.radius < --remaining_rows_) {
map.get_bln(left_, &area_);
left_ = area_;
- area_.t = TCoords<FCoords>::D;
+ area_.t = TriangleIndex::D;
remaining_in_row_ = rowwidth_ += 2;
} else if (remaining_rows_) {
map.get_brn(left_, &area_);
left_ = area_;
- area_.t = TCoords<FCoords>::D;
+ area_.t = TriangleIndex::D;
remaining_in_row_ = rowwidth_ -= 2;
} else
return false;
=== modified file 'src/logic/player.cc'
--- src/logic/player.cc 2017-08-19 22:22:20 +0000
+++ src/logic/player.cc 2017-08-30 13:39:17 +0000
@@ -963,7 +963,7 @@
}
} else
map_object_descr = nullptr;
- field.map_object_descr[TCoords<>::None] = map_object_descr;
+ field.map_object_descr[TriangleIndex::None] = map_object_descr;
}
}
{ // discover the D triangle and the SW edge of the top right neighbour
=== modified file 'src/logic/widelands_geometry.h'
--- src/logic/widelands_geometry.h 2017-08-27 20:25:47 +0000
+++ src/logic/widelands_geometry.h 2017-08-30 13:39:17 +0000
@@ -122,13 +122,13 @@
Field* field;
};
+enum class TriangleIndex { D, R, None };
+
// TODO(sirver): This should not derive from CoordsType. Replace with NodeAndTriangle.
template <typename CoordsType = Coords> struct TCoords : public CoordsType {
- enum TriangleIndex { D, R, None };
-
TCoords() : t() {
}
- TCoords(const CoordsType C, const TriangleIndex T = None) : CoordsType(C), t(T) {
+ TCoords(const CoordsType C, const TriangleIndex T = TriangleIndex::None) : CoordsType(C), t(T) {
}
bool operator==(const TCoords& other) const {
=== modified file 'src/map_io/map_players_view_packet.cc'
--- src/map_io/map_players_view_packet.cc 2017-06-24 08:47:46 +0000
+++ src/map_io/map_players_view_packet.cc 2017-08-30 13:39:17 +0000
@@ -351,7 +351,7 @@
map_object_descr = nullptr;
} else
map_object_descr = nullptr;
- f_player_field.map_object_descr[TCoords<>::None] = map_object_descr;
+ f_player_field.map_object_descr[TriangleIndex::None] = map_object_descr;
}
{ // triangles
@@ -554,7 +554,7 @@
}
MapObjectData mod = read_unseen_immovable(
egbase, imm_kind, node_immovables_file, node_immovables_file_version);
- f_player_field.map_object_descr[TCoords<>::None] = mod.map_object_descr;
+ f_player_field.map_object_descr[TriangleIndex::None] = mod.map_object_descr;
f_player_field.constructionsite = mod.csi;
// Read in whether this field had a border the last time it was seen
@@ -593,7 +593,7 @@
map_object_descr = nullptr;
} else
map_object_descr = nullptr;
- f_player_field.map_object_descr[TCoords<>::None] = map_object_descr;
+ f_player_field.map_object_descr[TriangleIndex::None] = map_object_descr;
break;
}
@@ -603,7 +603,7 @@
// information about the triangle has not been saved. Fill in
// the information from the game state.
f_player_field.terrains.d = f.field->terrain_d();
- f_player_field.map_object_descr[TCoords<>::D] = nullptr;
+ f_player_field.map_object_descr[TriangleIndex::D] = nullptr;
} else if (f_everseen | bl_everseen | br_everseen) {
// The player has seen the D triangle but does not see it now.
// Load his information about the triangle from file.
@@ -623,14 +623,14 @@
}
MapObjectData mod = read_unseen_immovable(
egbase, im_kind, triangle_immovables_file, triangle_immovables_file_version);
- f_player_field.map_object_descr[TCoords<>::D] = mod.map_object_descr;
+ f_player_field.map_object_descr[TriangleIndex::D] = mod.map_object_descr;
}
if (f_seen | br_seen | r_seen) {
// The player currently sees the R triangle. Therefore his
// information about the triangle has not been saved. Fill in
// the information from the game state.
f_player_field.terrains.r = f.field->terrain_r();
- f_player_field.map_object_descr[TCoords<>::R] = nullptr;
+ f_player_field.map_object_descr[TriangleIndex::R] = nullptr;
} else if (f_everseen | br_everseen | r_everseen) {
// The player has seen the R triangle but does not see it now.
// Load his information about the triangle from file.
@@ -650,7 +650,7 @@
}
MapObjectData mod = read_unseen_immovable(
egbase, im_kind, triangle_immovables_file, triangle_immovables_file_version);
- f_player_field.map_object_descr[TCoords<>::R] = mod.map_object_descr;
+ f_player_field.map_object_descr[TriangleIndex::R] = mod.map_object_descr;
}
{ // edges
@@ -716,7 +716,7 @@
kCurrentPacketVersionSurveyAmounts);
}
try {
- f_player_field.time_triangle_last_surveyed[TCoords<>::D] =
+ f_player_field.time_triangle_last_surveyed[TriangleIndex::D] =
survey_times_file.unsigned_32();
} catch (const FileRead::FileBoundaryExceeded&) {
throw GameDataError(
@@ -750,7 +750,7 @@
kCurrentPacketVersionSurveyAmounts);
}
try {
- f_player_field.time_triangle_last_surveyed[TCoords<>::R] =
+ f_player_field.time_triangle_last_surveyed[TriangleIndex::R] =
survey_times_file.unsigned_32();
} catch (const FileRead::FileBoundaryExceeded&) {
throw GameDataError(
@@ -895,7 +895,7 @@
assert(f_player_field.owner < 0x20);
owners_file.unsigned_8(f_player_field.owner);
MapObjectData mod;
- mod.map_object_descr = f_player_field.map_object_descr[TCoords<>::None];
+ mod.map_object_descr = f_player_field.map_object_descr[TriangleIndex::None];
mod.csi = f_player_field.constructionsite;
write_unseen_immovable(&mod, node_immovable_kinds_file, node_immovables_file);
@@ -915,7 +915,7 @@
(!bl_seen & !br_seen & (f_everseen | bl_everseen | br_everseen)) {
terrains_file.unsigned_8(f_player_field.terrains.d);
MapObjectData mod;
- mod.map_object_descr = f_player_field.map_object_descr[TCoords<>::D];
+ mod.map_object_descr = f_player_field.map_object_descr[TriangleIndex::D];
write_unseen_immovable(
&mod, triangle_immovable_kinds_file, triangle_immovables_file);
}
@@ -925,7 +925,7 @@
(!br_seen & !r_seen & (f_everseen | br_everseen | r_everseen)) {
terrains_file.unsigned_8(f_player_field.terrains.r);
MapObjectData mod;
- mod.map_object_descr = f_player_field.map_object_descr[TCoords<>::R];
+ mod.map_object_descr = f_player_field.map_object_descr[TriangleIndex::R];
write_unseen_immovable(
&mod, triangle_immovable_kinds_file, triangle_immovables_file);
}
@@ -942,7 +942,7 @@
// geologic survey
if (f_everseen & bl_everseen & br_everseen) {
const uint32_t time_last_surveyed =
- f_player_field.time_triangle_last_surveyed[TCoords<>::D];
+ f_player_field.time_triangle_last_surveyed[TriangleIndex::D];
const uint8_t has_info = time_last_surveyed != 0xffffffff;
surveys_file.unsigned_8(has_info);
if (has_info) {
@@ -952,7 +952,7 @@
}
if (f_everseen & br_everseen & r_everseen) {
const uint32_t time_last_surveyed =
- f_player_field.time_triangle_last_surveyed[TCoords<>::R];
+ f_player_field.time_triangle_last_surveyed[TriangleIndex::R];
const uint8_t has_info = time_last_surveyed != 0xffffffff;
surveys_file.unsigned_8(has_info);
if (has_info) {
=== modified file 'src/scripting/lua_map.cc'
--- src/scripting/lua_map.cc 2017-08-20 17:45:42 +0000
+++ src/scripting/lua_map.cc 2017-08-30 13:39:17 +0000
@@ -5973,7 +5973,7 @@
report_error(L, "Unknown terrain '%s'", name);
egbase.mutable_map()->change_terrain(
- world, TCoords<FCoords>(fcoords(L), TCoords<FCoords>::R), td);
+ world, TCoords<FCoords>(fcoords(L), TriangleIndex::R), td);
lua_pushstring(L, name);
return 1;
@@ -5993,7 +5993,7 @@
report_error(L, "Unknown terrain '%s'", name);
egbase.mutable_map()->change_terrain(
- world, TCoords<FCoords>(fcoords(L), TCoords<FCoords>::D), td);
+ world, TCoords<FCoords>(fcoords(L), TriangleIndex::D), td);
lua_pushstring(L, name);
return 1;
=== modified file 'src/wui/game_debug_ui.cc'
--- src/wui/game_debug_ui.cc 2017-08-19 22:22:20 +0000
+++ src/wui/game_debug_ui.cc 2017-08-30 13:39:17 +0000
@@ -282,7 +282,7 @@
str += (boost::format(" vision: %u\n") % vision).str();
{
Widelands::Time const time_last_surveyed =
- player_field.time_triangle_last_surveyed[Widelands::TCoords<>::D];
+ player_field.time_triangle_last_surveyed[Widelands::TriangleIndex::D];
if (time_last_surveyed != Widelands::never()) {
str += (boost::format(" D triangle last surveyed at %u: amount %u\n") %
@@ -294,7 +294,7 @@
}
{
Widelands::Time const time_last_surveyed =
- player_field.time_triangle_last_surveyed[Widelands::TCoords<>::R];
+ player_field.time_triangle_last_surveyed[Widelands::TriangleIndex::R];
if (time_last_surveyed != Widelands::never()) {
str += (boost::format(" R triangle last surveyed at %u: amount %u\n") %
@@ -310,7 +310,7 @@
break;
case 1: {
std::string animation_name = "(no animation)";
- if (player_field.map_object_descr[Widelands::TCoords<>::None]) {
+ if (player_field.map_object_descr[Widelands::TriangleIndex::None]) {
animation_name = "(seen an animation)";
}
=== modified file 'src/wui/interactive_base.cc'
--- src/wui/interactive_base.cc 2017-08-20 19:58:19 +0000
+++ src/wui/interactive_base.cc 2017-08-30 13:39:17 +0000
@@ -161,7 +161,7 @@
// register sel overlay position
if (sel_.triangles) {
- assert(center.triangle.t == TCoords<>::D || center.triangle.t == TCoords<>::R);
+ assert(center.triangle.t == TriangleIndex::D || center.triangle.t == TriangleIndex::R);
Widelands::MapTriangleRegion<> mr(map, Area<TCoords<>>(center.triangle, sel_.radius));
do
field_overlay_manager_->register_overlay(
=== modified file 'src/wui/interactive_base.h'
--- src/wui/interactive_base.h 2017-08-20 16:12:28 +0000
+++ src/wui/interactive_base.h 2017-08-30 13:39:17 +0000
@@ -233,7 +233,7 @@
const bool Triangles = false,
const Widelands::NodeAndTriangle<>& Pos = Widelands::NodeAndTriangle<>(
Widelands::Coords(0, 0),
- Widelands::TCoords<>(Widelands::Coords(0, 0), Widelands::TCoords<>::D)),
+ Widelands::TCoords<>(Widelands::Coords(0, 0), Widelands::TriangleIndex::D)),
const uint32_t Radius = 0,
const Image* Pic = nullptr,
const FieldOverlayManager::OverlayId Jobid = 0)
=== modified file 'src/wui/interactive_player.cc'
--- src/wui/interactive_player.cc 2017-08-29 10:48:24 +0000
+++ src/wui/interactive_player.cc 2017-08-30 13:39:17 +0000
@@ -126,7 +126,7 @@
const float scale,
RenderTarget* dst) {
if (const Widelands::MapObjectDescr* const map_object_descr =
- player_field.map_object_descr[Widelands::TCoords<>::None]) {
+ player_field.map_object_descr[Widelands::TriangleIndex::None]) {
if (player_field.constructionsite.becomes) {
assert(field.owner != nullptr);
const Widelands::ConstructionsiteInformation& csinf = player_field.constructionsite;
@@ -286,7 +286,7 @@
map_view()->mouse_to_field(flag_to_connect_, MapView::Transition::Jump);
set_sel_pos(Widelands::NodeAndTriangle<>(
flag_to_connect_,
- Widelands::TCoords<>(flag_to_connect_, Widelands::TCoords<>::D)));
+ Widelands::TCoords<>(flag_to_connect_, Widelands::TriangleIndex::D)));
start_build_road(flag_to_connect_, field.get_owned_by());
}
flag_to_connect_ = Widelands::Coords::null();
=== modified file 'src/wui/mapviewpixelfunctions.cc'
--- src/wui/mapviewpixelfunctions.cc 2017-01-25 18:55:59 +0000
+++ src/wui/mapviewpixelfunctions.cc 2017-08-30 13:39:17 +0000
@@ -191,14 +191,14 @@
if (pdy * kTriangleWidth > ldy * pdx) {
// (x, y) is in the upper triangle.
result.triangle = TCoords<>(
- Coords(left_col, (row_number == 0 ? mapheight : row_number) - 1), TCoords<>::D);
+ Coords(left_col, (row_number == 0 ? mapheight : row_number) - 1), TriangleIndex::D);
} else {
Y_a = screen_y_base - map[Coords(left_col, next_row_number)].get_height() * kHeightFactor;
ldy = Y_b - Y_a;
if (pdy * (kTriangleWidth / 2) > ldy * pdx) {
// (x, y) is in the second triangle.
result.triangle = TCoords<>(
- Coords((right_col == 0 ? mapwidth : right_col) - 1, row_number), TCoords<>::R);
+ Coords((right_col == 0 ? mapwidth : right_col) - 1, row_number), TriangleIndex::R);
} else {
Y_b = screen_y_base -
map[Coords(left_col + 1 == mapwidth ? 0 : left_col + 1, next_row_number)]
@@ -209,10 +209,10 @@
pdx = (col_number + 2) * (kTriangleWidth / 2) - x;
if (pdy * kTriangleWidth > ldy * pdx) {
// (x, y) is in the third triangle.
- result.triangle = TCoords<>(Coords(right_col, row_number), TCoords<>::D);
+ result.triangle = TCoords<>(Coords(right_col, row_number), TriangleIndex::D);
} else {
// (x, y) is in the lower triangle.
- result.triangle = TCoords<>(Coords(left_col, next_row_number), TCoords<>::R);
+ result.triangle = TCoords<>(Coords(left_col, next_row_number), TriangleIndex::R);
}
}
}
@@ -229,7 +229,7 @@
if (pdy * kTriangleWidth > ldy * pdx) {
// (x, y) is in the upper triangle.
result.triangle = TCoords<>(
- Coords(right_col, (row_number == 0 ? mapheight : row_number) - 1), TCoords<>::D);
+ Coords(right_col, (row_number == 0 ? mapheight : row_number) - 1), TriangleIndex::D);
} else {
Y_b = screen_y_base - map[Coords(right_col, next_row_number)].get_height() * kHeightFactor;
ldy = Y_b - Y_a;
@@ -237,7 +237,7 @@
pdx = (col_number + 1) * (kTriangleWidth / 2) - x;
if (pdy * (kTriangleWidth / 2) > ldy * pdx) {
// (x, y) is in the second triangle.
- result.triangle = TCoords<>(Coords(left_col, row_number), TCoords<>::R);
+ result.triangle = TCoords<>(Coords(left_col, row_number), TriangleIndex::R);
} else {
Y_a = screen_y_base -
map[Coords((right_col == 0 ? mapwidth : right_col) - 1, next_row_number)]
@@ -246,12 +246,12 @@
ldy = Y_b - Y_a;
if (pdy * kTriangleWidth > ldy * pdx) {
// (x, y) is in the third triangle.
- result.triangle = TCoords<>(Coords(left_col, row_number), TCoords<>::D);
+ result.triangle = TCoords<>(Coords(left_col, row_number), TriangleIndex::D);
} else {
// (x, y) is in the lower triangle.
result.triangle =
TCoords<>(Coords((right_col == 0 ? mapwidth : right_col) - 1, next_row_number),
- TCoords<>::R);
+ TriangleIndex::R);
}
}
}
Follow ups