MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / SpiralTileIterator

Method SpiralTileIterator

src/tilearea.cpp:302–326  ·  view source on GitHub ↗

* See SpiralTileSequence constructor for description. */

Source from the content-addressed store, hash-verified

300 * See SpiralTileSequence constructor for description.
301 */
302SpiralTileIterator::SpiralTileIterator(TileIndex center, uint diameter) :
303 max_radius(diameter / 2),
304 cur_radius(0),
305 dir(DIAGDIR_BEGIN)
306{
307 assert(diameter > 0);
308
309 if (diameter % 2 == 1) {
310 this->extent.fill(1);
311 this->dir = INVALID_DIAGDIR; // special case for odd diameters, see Increment()
312 this->position = 0;
313
314 this->x = TileX(center);
315 this->y = TileY(center);
316 } else {
317 this->extent.fill(0);
318 this->dir = DIAGDIR_BEGIN;
319 this->InitPosition();
320
321 /* Start with the west corner of the center 2x2 rect */
322 this->x = TileX(center) + 1;
323 this->y = TileY(center);
324 }
325 this->SkipOutsideMap();
326}
327
328/**
329 * See SpiralTileSequence constructor for description.

Callers

nothing calls this directly

Calls 5

InitPositionMethod · 0.95
SkipOutsideMapMethod · 0.95
TileXFunction · 0.85
TileYFunction · 0.85
fillMethod · 0.80

Tested by

no test coverage detected