111 template <
typename DATA,
int BLKSIZE>
128 inline void set(
int x,
int y, DATA val);
129 inline DATA
get(
int x,
int y)
const;
130 inline bool onMap(
int x,
int y)
const;
138 inline size_t getTotalByteSize()
const {
139 return sizeof(DATA) *
140 ((
WORLD_W + BLKSIZE - 1) / BLKSIZE) *
141 ((
WORLD_H + BLKSIZE - 1) / BLKSIZE);
147 ((
WORLD_H + BLKSIZE - 1) / BLKSIZE)];
158 template <
typename DATA,
int BLKSIZE>
160 MAP_BLOCKSIZE(BLKSIZE),
161 MAP_W((
WORLD_W + BLKSIZE - 1) / BLKSIZE),
162 MAP_H((
WORLD_H + BLKSIZE - 1) / BLKSIZE),
163 _MAP_DEFAULT_VALUE(defaultValue)
169 template <
typename DATA,
int BLKSIZE>
171 MAP_BLOCKSIZE(BLKSIZE),
172 MAP_W((
WORLD_W + BLKSIZE - 1) / BLKSIZE),
173 MAP_H((
WORLD_H + BLKSIZE - 1) / BLKSIZE),
174 _MAP_DEFAULT_VALUE(map._MAP_DEFAULT_VALUE)
176 for (
int i = 0; i < this->MAP_W * this->
MAP_H; i++) {
183 template <
typename DATA,
int BLKSIZE>
187 for (
int i = 0; i < this->MAP_W * this->MAP_H; i++) {
188 this->_mapData[i] = map.
_mapData[i];
196 template <
typename DATA,
int BLKSIZE>
207 template <
typename DATA,
int BLKSIZE>
210 for (
int i = 0; i < this->MAP_W * this->MAP_H; i++) {
211 this->_mapData[i] = value;
221 template <
typename DATA,
int BLKSIZE>
224 fill(this->_MAP_DEFAULT_VALUE);
232 template <
typename DATA,
int BLKSIZE>
235 return this->_mapData;
247 template <
typename DATA,
int BLKSIZE>
250 if(this->onMap(x, y)) {
251 this->_mapData[x * MAP_H + y] = value;
264 template <
typename DATA,
int BLKSIZE>
267 if(!this->onMap(x, y)) {
268 return this->_MAP_DEFAULT_VALUE;
271 return this->_mapData[x * MAP_H + y];
281 template <
typename DATA,
int BLKSIZE>
284 return (x >= 0 && x < this->MAP_W) && (y >= 0 && y < this->MAP_H);
296 template <
typename DATA,
int BLKSIZE>
299 if(this->worldOnMap(x, y)) {
302 this->_mapData[x * MAP_H + y] = value;
315 template <
typename DATA,
int BLKSIZE>
318 if(!this->worldOnMap(x, y)) {
319 return this->_MAP_DEFAULT_VALUE;
324 return this->_mapData[x * MAP_H + y];
334 template <
typename DATA,
int BLKSIZE>
DATA worldGet(int x, int y) const
void set(int x, int y, DATA val)
const int MAP_W
Number of clusters in horizontal direction.
Map(const Map< DATA, BLKSIZE > &map)
Map & operator=(const Map< DATA, BLKSIZE > &map)
bool worldOnMap(int x, int y) const
DATA _mapData[((WORLD_W+BLKSIZE - 1)/BLKSIZE) *((WORLD_H+BLKSIZE - 1)/BLKSIZE)]
const DATA _MAP_DEFAULT_VALUE
Default value of a cluster.
bool onMap(int x, int y) const
const int MAP_H
Number of clusters in vertical direction.
DATA get(int x, int y) const
void worldSet(int x, int y, DATA val)
Map< short, 8 > MapShort8
Map of ::short, with cluster size 8.
Map< Byte, 2 > MapByte2
Map of ::Byte, with cluster size 2.
Map< Byte, 4 > MapByte4
Map of ::Byte, with cluster size 4.
Map< Byte, 1 > MapByte1
Map of ::Byte, with cluster size 1.