Skip to content

Commit 76eadb9

Browse files
committed
rename N to SECTOR_SIDE_LENGTH
1 parent c89f528 commit 76eadb9

File tree

14 files changed

+409
-409
lines changed

14 files changed

+409
-409
lines changed

libopenage/gamestate/map.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
namespace openage {
1717
namespace path {
1818

19-
template <size_t N>
19+
template <size_t SECTOR_SIDE_LENGTH>
2020
class Pathfinder;
2121
} // namespace path
2222

libopenage/pathfinding/cost_field.h

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace path {
2929
* Cost field in the flow-field pathfinding algorithm.
3030
*/
3131

32-
template <size_t N>
32+
template <size_t SECTOR_SIDE_LENGTH>
3333
class CostField {
3434
public:
3535
/**
@@ -106,15 +106,15 @@ class CostField {
106106
*
107107
* @return Cost field values.
108108
*/
109-
const std::array<cost_t, N * N> &get_costs() const;
109+
const std::array<cost_t, SECTOR_SIDE_LENGTH * SECTOR_SIDE_LENGTH> &get_costs() const;
110110

111111
/**
112112
* Set the cost field values.
113113
*
114114
* @param cells Cost field values.
115115
* @param valid_until Time at which the cost value expires.
116116
*/
117-
void set_costs(std::array<cost_t, N * N> &&cells, const time::time_t &changed);
117+
void set_costs(std::array<cost_t, SECTOR_SIDE_LENGTH * SECTOR_SIDE_LENGTH> &&cells, const time::time_t &changed);
118118

119119
/**
120120
* Stamp a cost field cell at a given time.
@@ -152,7 +152,7 @@ class CostField {
152152
void clear_dirty();
153153

154154

155-
const curve::Array<cost_t, N> &get_cost_history() const;
155+
const curve::Array<cost_t, SECTOR_SIDE_LENGTH> &get_cost_history() const;
156156

157157
private:
158158
/**
@@ -163,65 +163,65 @@ class CostField {
163163
/**
164164
* Cost field values.
165165
*/
166-
std::array<cost_t, N * N> cells;
166+
std::array<cost_t, SECTOR_SIDE_LENGTH * SECTOR_SIDE_LENGTH> cells;
167167

168168
/**
169169
* Cost stamp vector.
170170
*/
171-
std::array<std::optional<cost_stamp_t>, N * N> cost_stamps;
171+
std::array<std::optional<cost_stamp_t>, SECTOR_SIDE_LENGTH * SECTOR_SIDE_LENGTH> cost_stamps;
172172

173173

174174
/**
175175
* Array curve recording cell cost history,
176176
*/
177-
curve::Array<cost_t, N * N> cell_cost_history;
177+
curve::Array<cost_t, SECTOR_SIDE_LENGTH * SECTOR_SIDE_LENGTH> cell_cost_history;
178178
};
179179

180-
template <size_t N>
181-
CostField<N>::CostField(const std::shared_ptr<event::EventLoop> &loop, size_t id) :
180+
template <size_t SECTOR_SIDE_LENGTH>
181+
CostField<SECTOR_SIDE_LENGTH>::CostField(const std::shared_ptr<event::EventLoop> &loop, size_t id) :
182182
valid_until{time::TIME_MIN},
183183
cell_cost_history(loop, id) {
184184
cells.fill(COST_MIN);
185-
log::log(DBG << "Created cost field with size " << N << "x" << N);
185+
log::log(DBG << "Created cost field with size " << SECTOR_SIDE_LENGTH << "x" << SECTOR_SIDE_LENGTH);
186186
}
187187

188-
template <size_t N>
189-
constexpr size_t CostField<N>::get_size() const {
190-
return N;
188+
template <size_t SECTOR_SIDE_LENGTH>
189+
constexpr size_t CostField<SECTOR_SIDE_LENGTH>::get_size() const {
190+
return SECTOR_SIDE_LENGTH;
191191
}
192192

193-
template <size_t N>
194-
cost_t CostField<N>::get_cost(const coord::tile_delta &pos) const {
195-
return this->cells.at(pos.ne + pos.se * N);
193+
template <size_t SECTOR_SIDE_LENGTH>
194+
cost_t CostField<SECTOR_SIDE_LENGTH>::get_cost(const coord::tile_delta &pos) const {
195+
return this->cells.at(pos.ne + pos.se * SECTOR_SIDE_LENGTH);
196196
}
197197

198-
template <size_t N>
199-
cost_t CostField<N>::get_cost(size_t x, size_t y) const {
200-
return this->cells.at(x + y * N);
198+
template <size_t SECTOR_SIDE_LENGTH>
199+
cost_t CostField<SECTOR_SIDE_LENGTH>::get_cost(size_t x, size_t y) const {
200+
return this->cells.at(x + y * SECTOR_SIDE_LENGTH);
201201
}
202202

203-
template <size_t N>
204-
cost_t CostField<N>::get_cost(size_t idx) const {
203+
template <size_t SECTOR_SIDE_LENGTH>
204+
cost_t CostField<SECTOR_SIDE_LENGTH>::get_cost(size_t idx) const {
205205
return this->cells.at(idx);
206206
}
207207

208-
template <size_t N>
209-
void CostField<N>::set_cost(const coord::tile_delta &pos, cost_t cost, const time::time_t &valid_until) {
210-
this->set_cost(pos.ne + pos.se * N, cost, valid_until);
208+
template <size_t SECTOR_SIDE_LENGTH>
209+
void CostField<SECTOR_SIDE_LENGTH>::set_cost(const coord::tile_delta &pos, cost_t cost, const time::time_t &valid_until) {
210+
this->set_cost(pos.ne + pos.se * SECTOR_SIDE_LENGTH, cost, valid_until);
211211
}
212212

213-
template <size_t N>
214-
void CostField<N>::set_cost(size_t x, size_t y, cost_t cost, const time::time_t &valid_until) {
215-
this->set_cost(x + y * N, cost, valid_until);
213+
template <size_t SECTOR_SIDE_LENGTH>
214+
void CostField<SECTOR_SIDE_LENGTH>::set_cost(size_t x, size_t y, cost_t cost, const time::time_t &valid_until) {
215+
this->set_cost(x + y * SECTOR_SIDE_LENGTH, cost, valid_until);
216216
}
217217

218-
template <size_t N>
219-
const std::array<cost_t, N * N> &CostField<N>::get_costs() const {
218+
template <size_t SECTOR_SIDE_LENGTH>
219+
const std::array<cost_t, SECTOR_SIDE_LENGTH * SECTOR_SIDE_LENGTH> &CostField<SECTOR_SIDE_LENGTH>::get_costs() const {
220220
return this->cells;
221221
}
222222

223-
template <size_t N>
224-
void CostField<N>::set_costs(std::array<cost_t, N * N> &&cells, const time::time_t &valid_until) {
223+
template <size_t SECTOR_SIDE_LENGTH>
224+
void CostField<SECTOR_SIDE_LENGTH>::set_costs(std::array<cost_t, SECTOR_SIDE_LENGTH * SECTOR_SIDE_LENGTH> &&cells, const time::time_t &valid_until) {
225225
ENSURE(cells.size() == this->cells.size(),
226226
"cells vector has wrong size: " << cells.size()
227227
<< "; expected: "
@@ -232,8 +232,8 @@ void CostField<N>::set_costs(std::array<cost_t, N * N> &&cells, const time::time
232232
this->cell_cost_history.set_insert_range(valid_until, this->cells.begin(), this->cells.end());
233233
}
234234

235-
template <size_t N>
236-
bool CostField<N>::stamp(size_t idx, cost_t cost, const time::time_t &stamped_at) {
235+
template <size_t SECTOR_SIDE_LENGTH>
236+
bool CostField<SECTOR_SIDE_LENGTH>::stamp(size_t idx, cost_t cost, const time::time_t &stamped_at) {
237237
if (this->cost_stamps[idx].has_value()) {
238238
return false;
239239
}
@@ -247,8 +247,8 @@ bool CostField<N>::stamp(size_t idx, cost_t cost, const time::time_t &stamped_at
247247
return true;
248248
}
249249

250-
template <size_t N>
251-
bool CostField<N>::unstamp(size_t idx, const time::time_t &unstamped_at) {
250+
template <size_t SECTOR_SIDE_LENGTH>
251+
bool CostField<SECTOR_SIDE_LENGTH>::unstamp(size_t idx, const time::time_t &unstamped_at) {
252252
if (not this->cost_stamps[idx].has_value() or unstamped_at < this->cost_stamps[idx]->stamp_time) {
253253
return false;
254254
}
@@ -259,18 +259,18 @@ bool CostField<N>::unstamp(size_t idx, const time::time_t &unstamped_at) {
259259
return true;
260260
}
261261

262-
template <size_t N>
263-
bool CostField<N>::is_dirty(const time::time_t &time) const {
262+
template <size_t SECTOR_SIDE_LENGTH>
263+
bool CostField<SECTOR_SIDE_LENGTH>::is_dirty(const time::time_t &time) const {
264264
return time >= this->valid_until;
265265
}
266266

267-
template <size_t N>
268-
void CostField<N>::clear_dirty() {
267+
template <size_t SECTOR_SIDE_LENGTH>
268+
void CostField<SECTOR_SIDE_LENGTH>::clear_dirty() {
269269
this->valid_until = time::TIME_MAX;
270270
}
271271

272-
template <size_t N>
273-
const curve::Array<cost_t, N> &CostField<N>::get_cost_history() const {
272+
template <size_t SECTOR_SIDE_LENGTH>
273+
const curve::Array<cost_t, SECTOR_SIDE_LENGTH> &CostField<SECTOR_SIDE_LENGTH>::get_cost_history() const {
274274
return this->cell_cost_history;
275275
};
276276

libopenage/pathfinding/demo/demo_0.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ class MeshData;
3333

3434
namespace path {
3535

36-
template <size_t N>
36+
template <size_t SECTOR_SIDE_LENGTH>
3737
class CostField;
3838

39-
template <size_t N>
39+
template <size_t SECTOR_SIDE_LENGTH>
4040
class IntegrationField;
4141

42-
template <size_t N>
42+
template <size_t SECTOR_SIDE_LENGTH>
4343
class FlowField;
4444

4545

libopenage/pathfinding/demo/demo_1.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class GuiApplicationWithLogger;
2424

2525
namespace path {
2626

27-
template <size_t N>
27+
template <size_t SECTOR_SIDE_LENGTH>
2828
class Grid;
2929

3030
namespace tests {

libopenage/pathfinding/field_cache.h

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ struct tile_delta;
1616

1717
namespace path {
1818

19-
template <size_t N>
19+
template <size_t SECTOR_SIDE_LENGTH>
2020
class IntegrationField;
2121

22-
template <size_t N>
22+
template <size_t SECTOR_SIDE_LENGTH>
2323
class FlowField;
2424

2525
/**
2626
* Cache to store already calculated flow and integration fields for the pathfinding algorithm.
2727
*/
28-
template <size_t N>
28+
template <size_t SECTOR_SIDE_LENGTH>
2929
class FieldCache {
3030
public:
3131
FieldCache() = default;
@@ -38,7 +38,7 @@ class FieldCache {
3838
* @param cache_entry Field entry (integration field, flow field).
3939
*/
4040
void add(const cache_key_t cache_key,
41-
const field_cache_t<N> cache_entry);
41+
const field_cache_t<SECTOR_SIDE_LENGTH> cache_entry);
4242

4343
/**
4444
* Evict field entry from the cache.
@@ -65,7 +65,7 @@ class FieldCache {
6565
*
6666
* @return Integration field.
6767
*/
68-
std::shared_ptr<IntegrationField<N>> get_integration_field(const cache_key_t cache_key) const;
68+
std::shared_ptr<IntegrationField<SECTOR_SIDE_LENGTH>> get_integration_field(const cache_key_t cache_key) const;
6969

7070
/**
7171
* Get a cached flow field.
@@ -74,7 +74,7 @@ class FieldCache {
7474
*
7575
* @return Flow field.
7676
*/
77-
std::shared_ptr<FlowField<N>> get_flow_field(const cache_key_t cache_key) const;
77+
std::shared_ptr<FlowField<SECTOR_SIDE_LENGTH>> get_flow_field(const cache_key_t cache_key) const;
7878

7979
/**
8080
* Get a cached field entry.
@@ -85,7 +85,7 @@ class FieldCache {
8585
*
8686
* @return Field entry (integration field, flow field).
8787
*/
88-
field_cache_t<N> get(const cache_key_t cache_key) const;
88+
field_cache_t<SECTOR_SIDE_LENGTH> get(const cache_key_t cache_key) const;
8989

9090
private:
9191
/**
@@ -106,38 +106,38 @@ class FieldCache {
106106
* when the field is reused.
107107
*/
108108
std::unordered_map<cache_key_t,
109-
field_cache_t<N>,
109+
field_cache_t<SECTOR_SIDE_LENGTH>,
110110
pair_hash>
111111
cache;
112112
};
113113

114-
template <size_t N>
115-
void FieldCache<N>::add(const cache_key_t cache_key,
116-
const field_cache_t<N> cache_entry) {
114+
template <size_t SECTOR_SIDE_LENGTH>
115+
void FieldCache<SECTOR_SIDE_LENGTH>::add(const cache_key_t cache_key,
116+
const field_cache_t<SECTOR_SIDE_LENGTH> cache_entry) {
117117
this->cache[cache_key] = cache_entry;
118118
}
119119

120-
template <size_t N>
121-
bool FieldCache<N>::evict(const cache_key_t cache_key) {
120+
template <size_t SECTOR_SIDE_LENGTH>
121+
bool FieldCache<SECTOR_SIDE_LENGTH>::evict(const cache_key_t cache_key) {
122122
return this->cache.erase(cache_key) != 0;
123123
}
124-
template <size_t N>
125-
bool FieldCache<N>::is_cached(const cache_key_t cache_key) const {
124+
template <size_t SECTOR_SIDE_LENGTH>
125+
bool FieldCache<SECTOR_SIDE_LENGTH>::is_cached(const cache_key_t cache_key) const {
126126
return this->cache.contains(cache_key);
127127
}
128128

129-
template <size_t N>
130-
std::shared_ptr<IntegrationField<N>> FieldCache<N>::get_integration_field(const cache_key_t cache_key) const {
129+
template <size_t SECTOR_SIDE_LENGTH>
130+
std::shared_ptr<IntegrationField<SECTOR_SIDE_LENGTH>> FieldCache<SECTOR_SIDE_LENGTH>::get_integration_field(const cache_key_t cache_key) const {
131131
return this->cache.at(cache_key).first;
132132
}
133133

134-
template <size_t N>
135-
std::shared_ptr<FlowField<N>> FieldCache<N>::get_flow_field(const cache_key_t cache_key) const {
134+
template <size_t SECTOR_SIDE_LENGTH>
135+
std::shared_ptr<FlowField<SECTOR_SIDE_LENGTH>> FieldCache<SECTOR_SIDE_LENGTH>::get_flow_field(const cache_key_t cache_key) const {
136136
return this->cache.at(cache_key).second;
137137
}
138138

139-
template <size_t N>
140-
field_cache_t<N> FieldCache<N>::get(const cache_key_t cache_key) const {
139+
template <size_t SECTOR_SIDE_LENGTH>
140+
field_cache_t<SECTOR_SIDE_LENGTH> FieldCache<SECTOR_SIDE_LENGTH>::get(const cache_key_t cache_key) const {
141141
return this->cache.at(cache_key);
142142
}
143143

0 commit comments

Comments
 (0)