From e7bdfc90e6e9b52c2786990e7b0e07eaebb9b999 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 31 Jan 2017 13:25:45 +0200 Subject: [PATCH 1/4] map: add `const` to `Sight_map::{is_initialised,can_see}()` implementations. Squelches gcc errors. --- map.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/map.cpp b/map.cpp index 38e31fd..5573b71 100644 --- a/map.cpp +++ b/map.cpp @@ -250,12 +250,12 @@ void Sight_map::add_point(Tripoint p) seen.push_back( p ); } -bool Sight_map::is_initialized() +bool Sight_map::is_initialized() const { return initialized; } -bool Sight_map::can_see(Tripoint p) +bool Sight_map::can_see(Tripoint p) const { for (int i = 0; i < seen.size(); i++) { if (seen[i] == p) { From e59f1e9661a823a65da30318841e577c888435cc Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 31 Jan 2017 13:40:11 +0200 Subject: [PATCH 2/4] map: add `build_tile_sight_map()` to header, bandage up its syntax. It seems that 8635e2ec3f714a7b6549b70cfadd36e38ef8c6b1, which introduced the code, was patch-added, and is missing a hunk! Fix up for compilation, but know that things are seriously broken. Also, tried to just move `build_sight_map()` down after its `build_tile_sight_map()` helper, but for some reason, `gcc` was still complaining. So, declare in header. --- map.cpp | 8 ++++++++ map.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/map.cpp b/map.cpp index 5573b71..8d6ae38 100644 --- a/map.cpp +++ b/map.cpp @@ -2416,6 +2416,14 @@ void Map::build_tile_sight_map(int tile_x, int tile_y, int tile_z, int range) for (int x = min_x; x <= max_x; x++) { for (int y = min_y; y <= max_y; y++) { for (int z = min_z; z <= max_z; z++) { + // FIXME: something horrible happened in 8635e2ec3f714a7b6549b70cfadd36e38ef8c6b1 + } + // FIXME: something horrible happened in 8635e2ec3f714a7b6549b70cfadd36e38ef8c6b1 + } + // FIXME: something horrible happened in 8635e2ec3f714a7b6549b70cfadd36e38ef8c6b1 + } + // FIXME: something horrible happened in 8635e2ec3f714a7b6549b70cfadd36e38ef8c6b1 +} /* Still using Cataclysm/DDA style LOS. It sucks and is slow and I hate it. * Basically, iterate over all Bresenham lines between [x0,y0] and [x1,y1]. diff --git a/map.h b/map.h index 0dff643..6a6c135 100644 --- a/map.h +++ b/map.h @@ -245,6 +245,8 @@ class Map // If force_rebuild is false, we skip any tiles for which the Sight_map is // already initialized. void build_sight_map(int range = -1, bool force_rebuild = false); +// helper + void build_tile_sight_map(int tile_x, int tile_y, int tile_z, int range); bool senses(int x0, int y0, int x1, int y1, int range, Sense_type sense); bool senses(int x0, int y0, int z0, int x1, int y1, int z1, int range, From feab6a78fe209a81dcb0d47af3124d4d1bbbb122 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 31 Jan 2017 13:46:47 +0200 Subject: [PATCH 3/4] map: fix typo: `may_y` -> `max_y`. Compiles now, with ~10 warnings. --- map.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/map.cpp b/map.cpp index 8d6ae38..fd396db 100644 --- a/map.cpp +++ b/map.cpp @@ -2405,8 +2405,8 @@ void Map::build_tile_sight_map(int tile_x, int tile_y, int tile_z, int range) max_x = SUBMAP_SIZE * MAP_SIZE - 1; } int max_y = tile_y + range; - if (may_y > SUBMAP_SIZE * MAP_SIZE - 1) { - may_y = SUBMAP_SIZE * MAP_SIZE - 1; + if (max_y > SUBMAP_SIZE * MAP_SIZE - 1) { + max_y = SUBMAP_SIZE * MAP_SIZE - 1; } int max_z = tile_z + range; if (max_z > VERTICAL_MAP_SIZE * 2) { From 10b080117dd9563b2d92431dde5cf539e5aef33e Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 31 Jan 2017 13:51:45 +0200 Subject: [PATCH 4/4] map: minor, tag helper declaration in header as FIXME. --- map.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/map.h b/map.h index 6a6c135..5bab9cb 100644 --- a/map.h +++ b/map.h @@ -245,7 +245,7 @@ class Map // If force_rebuild is false, we skip any tiles for which the Sight_map is // already initialized. void build_sight_map(int range = -1, bool force_rebuild = false); -// helper +// FIXME: helper, shouldn't de declared here? void build_tile_sight_map(int tile_x, int tile_y, int tile_z, int range); bool senses(int x0, int y0, int x1, int y1, int range, Sense_type sense);