[Freeciv-Dev] (PR#7350) Map radius change with city size
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=7350 >
I think the generation of the indices is more complicated than it needs
to be.
I think this implementation should work:
int dist, count = 0;
for (dist = 0; dist <= CITY_MAP_RADIUS * CITY_MAP_RADIUS + 2; dist++) {
for (x = 0; x < CITY_MAP_SIZE; x++) {
for (y = 0; y < CITY_MAP_SIZE; y++) {
int dx = (x - CITY_MAP_RADIUS);
int dy = (y - CITY_MAP_RADIUS);
if (dx * dx + dy * dy == dist) {
indices[count].x = x;
indices[count].y = y;
count++;
}
}
}
}
This is O(R^4), where R = CITY_MAP_RADIUS (or max city radius). This is
quite acceptable as a one-time cost.
jason
|
|