Feature #334 ยป 0035-Replace-direct-wld.map.interate_outwards_indices-acc.patch
common/map.h | ||
---|---|---|
int _tile##_index = 0; \
|
||
index_to_map_pos(&_start##_x, &_start##_y, tile_index(_tile##_start)); \
|
||
for (; \
|
||
_tile##_index < wld.map.num_iterate_outwards_indices; \
|
||
_tile##_index < MAP_NUM_ITERATE_OUTWARDS_INDICES; \
|
||
_tile##_index++) { \
|
||
if (wld.map.iterate_outwards_indices[_tile##_index].dist > _tile##_max) { \
|
||
if (MAP_ITERATE_OUTWARDS_INDICES[_tile##_index].dist > _tile##_max) { \
|
||
break; \
|
||
} \
|
||
_x = wld.map.iterate_outwards_indices[_tile##_index].dx; \
|
||
_y = wld.map.iterate_outwards_indices[_tile##_index].dy; \
|
||
_x = MAP_ITERATE_OUTWARDS_INDICES[_tile##_index].dx; \
|
||
_y = MAP_ITERATE_OUTWARDS_INDICES[_tile##_index].dy; \
|
||
_tile##_x = _x + _start##_x; \
|
||
_tile##_y = _y + _start##_y; \
|
||
_tile = map_pos_to_tile(nmap, _tile##_x, _tile##_y); \
|
common/scriptcore/api_game_methods.c | ||
---|---|---|
index_to_map_pos(&startx, &starty, tile_index(pstart));
|
||
tindex++;
|
||
while (tindex < wld.map.num_iterate_outwards_indices) {
|
||
if (wld.map.iterate_outwards_indices[tindex].dist > max_dist) {
|
||
while (tindex < MAP_NUM_ITERATE_OUTWARDS_INDICES) {
|
||
if (MAP_ITERATE_OUTWARDS_INDICES[tindex].dist > max_dist) {
|
||
return -1;
|
||
}
|
||
dx = wld.map.iterate_outwards_indices[tindex].dx;
|
||
dy = wld.map.iterate_outwards_indices[tindex].dy;
|
||
dx = MAP_ITERATE_OUTWARDS_INDICES[tindex].dx;
|
||
dy = MAP_ITERATE_OUTWARDS_INDICES[tindex].dy;
|
||
newx = dx + startx;
|
||
newy = dy + starty;
|
||
if (!normalize_map_pos(&(wld.map), &newx, &newy)) {
|
||
tindex++;
|
||
continue;
|
||
... | ... | |
LUASCRIPT_CHECK_STATE(L, NULL);
|
||
LUASCRIPT_CHECK_SELF(L, pstart, NULL);
|
||
LUASCRIPT_CHECK_ARG(L,
|
||
tindex >= 0 && tindex < wld.map.num_iterate_outwards_indices,
|
||
tindex >= 0 && tindex < MAP_NUM_ITERATE_OUTWARDS_INDICES,
|
||
3, "index out of bounds", NULL);
|
||
index_to_map_pos(&newx, &newy, tile_index(pstart));
|
||
newx += wld.map.iterate_outwards_indices[tindex].dx;
|
||
newy += wld.map.iterate_outwards_indices[tindex].dy;
|
||
newx += MAP_ITERATE_OUTWARDS_INDICES[tindex].dx;
|
||
newy += MAP_ITERATE_OUTWARDS_INDICES[tindex].dy;
|
||
if (!normalize_map_pos(&(wld.map), &newx, &newy)) {
|
||
return NULL;
|
common/world_object.h | ||
---|---|---|
#define MAP_NUM_CARDINAL_DIRS wld.map.num_cardinal_dirs
|
||
#define MAP_VALID_DIRS wld.map.valid_dirs
|
||
#define MAP_NUM_VALID_DIRS wld.map.num_valid_dirs
|
||
#define MAP_ITERATE_OUTWARDS_INDICES wld.map.iterate_outwards_indices
|
||
#define MAP_NUM_ITERATE_OUTWARDS_INDICES wld.map.num_iterate_outwards_indices
|
||
#ifdef __cplusplus
|
||
}
|
server/generator/mapgen.c | ||
---|---|---|
/* Iterate positions, beginning by a random index of the outwards
|
||
* indices. */
|
||
for (i = fc_rand(wld.map.num_iterate_outwards_indices / 200);
|
||
i < wld.map.num_iterate_outwards_indices; i++) {
|
||
for (i = fc_rand(MAP_NUM_ITERATE_OUTWARDS_INDICES / 200);
|
||
i < MAP_NUM_ITERATE_OUTWARDS_INDICES; i++) {
|
||
x = tx + outwards_indices[i].dx;
|
||
y = ty + outwards_indices[i].dy;
|
||
if (normalize_map_pos(&(wld.map), &x, &y)
|
||
... | ... | |
if (wld.map.server.team_placement != TEAM_PLACEMENT_DISABLED
|
||
&& team_players_num > 0) {
|
||
/* Do team placement. */
|
||
struct iter_index outwards_indices[wld.map.num_iterate_outwards_indices];
|
||
struct iter_index outwards_indices[MAP_NUM_ITERATE_OUTWARDS_INDICES];
|
||
int start_x[teams_num], start_y[teams_num];
|
||
int dx = 0, dy = 0;
|
||
int j, k;
|
||
/* Build outwards_indices. */
|
||
memcpy(outwards_indices, wld.map.iterate_outwards_indices,
|
||
memcpy(outwards_indices, MAP_ITERATE_OUTWARDS_INDICES,
|
||
sizeof(outwards_indices));
|
||
switch (wld.map.server.team_placement) {
|
||
case TEAM_PLACEMENT_DISABLED:
|
||
... | ... | |
break;
|
||
case TEAM_PLACEMENT_CLOSEST:
|
||
case TEAM_PLACEMENT_CONTINENT:
|
||
for (j = 0; j < wld.map.num_iterate_outwards_indices; j++) {
|
||
for (j = 0; j < MAP_NUM_ITERATE_OUTWARDS_INDICES; j++) {
|
||
/* We want square distances for comparing. */
|
||
outwards_indices[j].dist =
|
||
map_vector_to_sq_distance(outwards_indices[j].dx,
|
||
outwards_indices[j].dy);
|
||
}
|
||
qsort(outwards_indices, wld.map.num_iterate_outwards_indices,
|
||
qsort(outwards_indices, MAP_NUM_ITERATE_OUTWARDS_INDICES,
|
||
sizeof(outwards_indices[0]), fair_team_placement_closest);
|
||
break;
|
||
case TEAM_PLACEMENT_HORIZONTAL:
|
||
qsort(outwards_indices, wld.map.num_iterate_outwards_indices,
|
||
qsort(outwards_indices, MAP_NUM_ITERATE_OUTWARDS_INDICES,
|
||
sizeof(outwards_indices[0]), fair_team_placement_horizontal);
|
||
break;
|
||
case TEAM_PLACEMENT_VERTICAL:
|
||
qsort(outwards_indices, wld.map.num_iterate_outwards_indices,
|
||
qsort(outwards_indices, MAP_NUM_ITERATE_OUTWARDS_INDICES,
|
||
sizeof(outwards_indices[0]), fair_team_placement_vertical);
|
||
break;
|
||
}
|