Feature #194 ยป 0037-Use-MAP_NATIVE_WIDTH-MAP_NATIVE_HEIGHT.patch
| ai/default/daidomestic.c | ||
|---|---|---|
|
if (CBS_LOGARITHMIC == game.info.caravan_bonus_style) {
|
||
|
int wd = ((100 - game.info.trade_world_rel_pct) * 10
|
||
|
+ game.info.trade_world_rel_pct
|
||
|
* (10 * 40 / MAX(wld.map.xsize, wld.map.ysize))) / 100;
|
||
|
* (10 * 40 / MAX(MAP_NATIVE_WIDTH, MAP_NATIVE_HEIGHT))) / 100;
|
||
|
income = pow(log(wd + 20 + 1.75 * max_trade_prod(pcity)) * 2, 2);
|
||
|
} else /* assume CBS_CLASSIC */ {
|
||
| client/climisc.c | ||
|---|---|---|
|
fc_assert_ret(punit != NULL);
|
||
|
center_tile_mapcanvas(unit_tile(punit));
|
||
|
} else {
|
||
|
struct tile *ctile = native_pos_to_tile(&(wld.map), wld.map.xsize / 2, wld.map.ysize / 2);
|
||
|
struct tile *ctile = native_pos_to_tile(&(wld.map), MAP_NATIVE_WIDTH / 2,
|
||
|
MAP_NATIVE_HEIGHT / 2);
|
||
|
/* Just any known tile will do; search near the middle first. */
|
||
|
/* Iterate outward from the center tile. We have to give a radius that
|
||
|
* is guaranteed to be larger than the map will be. Although this is
|
||
|
/* Iterate outward from the center tile. We have to give a radius that
|
||
|
* is guaranteed to be larger than the map will be. Although this is
|
||
|
* a misuse of map.xsize and map.ysize (which are native dimensions),
|
||
|
* it should give a sufficiently large radius. */
|
||
|
iterate_outward(&(wld.map), ctile, wld.map.xsize + wld.map.ysize, ptile) {
|
||
|
iterate_outward(&(wld.map), ctile, MAP_NATIVE_WIDTH + MAP_NATIVE_HEIGHT, ptile) {
|
||
|
if (client_tile_get_known(ptile) != TILE_UNKNOWN) {
|
||
|
ctile = ptile;
|
||
|
break;
|
||
| client/gui-qt/mapview.cpp | ||
|---|---|---|
|
}
|
||
|
if (MAP_IS_ISOMETRIC) {
|
||
|
ntl_y = map_x + map_y - wld.map.xsize;
|
||
|
ntl_y = map_x + map_y - MAP_NATIVE_WIDTH;
|
||
|
ntl_x = 2 * map_x - ntl_y;
|
||
|
} else {
|
||
|
ntl_x = map_x;
|
||
| client/gui-qt/menu.cpp | ||
|---|---|---|
|
bool map_saved;
|
||
|
QString img_name;
|
||
|
full_size_x = (wld.map.xsize + 2) * tileset_tile_width(tileset);
|
||
|
full_size_y = (wld.map.ysize + 2) * tileset_tile_height(tileset);
|
||
|
full_size_x = (MAP_NATIVE_WIDTH + 2) * tileset_tile_width(tileset);
|
||
|
full_size_y = (MAP_NATIVE_HEIGHT + 2) * tileset_tile_height(tileset);
|
||
|
current_width = gui()->mapview_wdg->width();
|
||
|
current_height = gui()->mapview_wdg->height();
|
||
|
if (tileset_hex_width(tileset) > 0) {
|
||
| client/gui-sdl2/mapview.c | ||
|---|---|---|
|
**************************************************************************/
|
||
|
void get_overview_area_dimensions(int *width, int *height)
|
||
|
{
|
||
|
/* calculate the dimensions in a way to always get a resulting
|
||
|
/* Calculate the dimensions in a way to always get a resulting
|
||
|
overview with a height bigger than or equal to DEFAULT_OVERVIEW_H.
|
||
|
First, the default dimensions are fed to the same formula that
|
||
|
is used in overview_common.c. If the resulting height is
|
||
| ... | ... | |
|
int xfact = MAP_IS_ISOMETRIC ? 2 : 1;
|
||
|
int shift = (MAP_IS_ISOMETRIC && !current_wrap_has_flag(WRAP_X)) ? -1 : 0;
|
||
|
OVERVIEW_TILE_SIZE = MIN((DEFAULT_OVERVIEW_W - 1) / (wld.map.xsize * xfact),
|
||
|
(DEFAULT_OVERVIEW_H - 1) / wld.map.ysize) + 1;
|
||
|
OVERVIEW_TILE_SIZE = MIN((DEFAULT_OVERVIEW_W - 1) / (MAP_NATIVE_WIDTH * xfact),
|
||
|
(DEFAULT_OVERVIEW_H - 1) / MAP_NATIVE_HEIGHT) + 1;
|
||
|
do {
|
||
|
*height = OVERVIEW_TILE_HEIGHT * wld.map.ysize;
|
||
|
*height = OVERVIEW_TILE_HEIGHT * MAP_NATIVE_HEIGHT;
|
||
|
if (*height < DEFAULT_OVERVIEW_H) {
|
||
|
OVERVIEW_TILE_SIZE++;
|
||
|
}
|
||
|
} while (*height < DEFAULT_OVERVIEW_H);
|
||
|
*width = OVERVIEW_TILE_WIDTH * wld.map.xsize + shift * OVERVIEW_TILE_SIZE;
|
||
|
*width = OVERVIEW_TILE_WIDTH * MAP_NATIVE_WIDTH + shift * OVERVIEW_TILE_SIZE;
|
||
|
OVERVIEW_TILE_SIZE = overview_tile_size_bak;
|
||
|
}
|
||
| client/gui-sdl3/mapview.c | ||
|---|---|---|
|
**************************************************************************/
|
||
|
void get_overview_area_dimensions(int *width, int *height)
|
||
|
{
|
||
|
/* calculate the dimensions in a way to always get a resulting
|
||
|
/* Calculate the dimensions in a way to always get a resulting
|
||
|
overview with a height bigger than or equal to DEFAULT_OVERVIEW_H.
|
||
|
First, the default dimensions are fed to the same formula that
|
||
|
is used in overview_common.c. If the resulting height is
|
||
| ... | ... | |
|
int xfact = MAP_IS_ISOMETRIC ? 2 : 1;
|
||
|
int shift = (MAP_IS_ISOMETRIC && !current_wrap_has_flag(WRAP_X)) ? -1 : 0;
|
||
|
OVERVIEW_TILE_SIZE = MIN((DEFAULT_OVERVIEW_W - 1) / (wld.map.xsize * xfact),
|
||
|
(DEFAULT_OVERVIEW_H - 1) / wld.map.ysize) + 1;
|
||
|
OVERVIEW_TILE_SIZE = MIN((DEFAULT_OVERVIEW_W - 1) / (MAP_NATIVE_WIDTH * xfact),
|
||
|
(DEFAULT_OVERVIEW_H - 1) / MAP_NATIVE_HEIGHT) + 1;
|
||
|
do {
|
||
|
*height = OVERVIEW_TILE_HEIGHT * wld.map.ysize;
|
||
|
*height = OVERVIEW_TILE_HEIGHT * MAP_NATIVE_HEIGHT;
|
||
|
if (*height < DEFAULT_OVERVIEW_H) {
|
||
|
OVERVIEW_TILE_SIZE++;
|
||
|
}
|
||
|
} while (*height < DEFAULT_OVERVIEW_H);
|
||
|
*width = OVERVIEW_TILE_WIDTH * wld.map.xsize + shift * OVERVIEW_TILE_SIZE;
|
||
|
*width = OVERVIEW_TILE_WIDTH * MAP_NATIVE_WIDTH + shift * OVERVIEW_TILE_SIZE;
|
||
|
OVERVIEW_TILE_SIZE = overview_tile_size_bak;
|
||
|
}
|
||
| client/mapctrl_common.c | ||
|---|---|---|
|
ptile = canvas_pos_to_nearest_tile(canvas_x, canvas_y, mouse_zoom);
|
||
|
/* Did mouse pointer move beyond the current tile's
|
||
|
* boundaries? Avoid macros; tile may be unreal!
|
||
|
/* Did mouse pointer move beyond the current tile's
|
||
|
* boundaries? Avoid macros; tile may be unreal!
|
||
|
*/
|
||
|
if (ptile == rec_tile) {
|
||
|
return;
|
||
| ... | ... | |
|
canvas_x += half_W;
|
||
|
canvas_y += half_H;
|
||
|
rec_w = rec_anchor_x - canvas_x; /* width */
|
||
|
rec_h = rec_anchor_y - canvas_y; /* height */
|
||
|
rec_w = rec_anchor_x - canvas_x; /* Width */
|
||
|
rec_h = rec_anchor_y - canvas_y; /* Height */
|
||
|
/* FIXME: This may be off-by-one. */
|
||
|
center_tile = get_center_tile_mapcanvas();
|
||
|
map_distance_vector(&diff_x, &diff_y, center_tile, rec_canvas_center_tile);
|
||
|
/* Adjust width, height if mapview has recentered.
|
||
|
*/
|
||
|
/* Adjust width, height if mapview has recentered. */
|
||
|
if (diff_x != 0 || diff_y != 0) {
|
||
|
if (tileset_is_isometric(tileset)) {
|
||
| ... | ... | |
|
rec_h += (diff_x + diff_y) * half_H;
|
||
|
/* Iso wrapping */
|
||
|
if (abs(rec_w) > wld.map.xsize * half_W / 2) {
|
||
|
int wx = wld.map.xsize * half_W, wy = wld.map.xsize * half_H;
|
||
|
if (abs(rec_w) > MAP_NATIVE_WIDTH * half_W / 2) {
|
||
|
int wx = MAP_NATIVE_WIDTH * half_W, wy = MAP_NATIVE_WIDTH * half_H;
|
||
|
rec_w > 0 ? (rec_w -= wx, rec_h -= wy) : (rec_w += wx, rec_h += wy);
|
||
|
}
|
||
| ... | ... | |
|
rec_h += diff_y * H;
|
||
|
/* X wrapping */
|
||
|
if (abs(rec_w) > wld.map.xsize * half_W) {
|
||
|
int wx = wld.map.xsize * W;
|
||
|
if (abs(rec_w) > MAP_NATIVE_WIDTH * half_W) {
|
||
|
int wx = MAP_NATIVE_WIDTH * W;
|
||
|
rec_w > 0 ? (rec_w -= wx) : (rec_w += wx);
|
||
|
}
|
||
| client/mapview_common.c | ||
|---|---|---|
|
* doesn't necessarily do. */
|
||
|
MAP_TO_NATIVE_POS(&nat_x, &nat_y, map_x, map_y);
|
||
|
if (current_wrap_has_flag(WRAP_X)) {
|
||
|
nat_x = FC_WRAP(nat_x, wld.map.xsize);
|
||
|
nat_x = FC_WRAP(nat_x, MAP_NATIVE_WIDTH);
|
||
|
}
|
||
|
if (current_wrap_has_flag(WRAP_Y)) {
|
||
|
nat_y = FC_WRAP(nat_y, wld.map.ysize);
|
||
|
nat_y = FC_WRAP(nat_y, MAP_NATIVE_HEIGHT);
|
||
|
}
|
||
|
NATIVE_TO_MAP_POS(&map_x, &map_y, nat_x, nat_y);
|
||
| ... | ... | |
|
NATIVE_TO_MAP_POS(xmin, ymin, 0, 0);
|
||
|
map_to_gui_pos(tileset, map_zoom, xmin, ymin, *xmin, *ymin);
|
||
|
NATIVE_TO_MAP_POS(xmax, ymax, wld.map.xsize - 1, wld.map.ysize - 1);
|
||
|
NATIVE_TO_MAP_POS(xmax, ymax, MAP_NATIVE_WIDTH - 1, MAP_NATIVE_HEIGHT - 1);
|
||
|
map_to_gui_pos(tileset, map_zoom, xmax, ymax, *xmax, *ymax);
|
||
|
*xmax += tileset_tile_width(tileset) * map_zoom;
|
||
|
*ymax += tileset_tile_height(tileset) * map_zoom;
|
||
| ... | ... | |
|
NATIVE_TO_MAP_POS(&map_x, &map_y, 0, 0);
|
||
|
map_to_gui_pos(tileset, map_zoom, &gui_x1, &gui_y1, map_x, map_y);
|
||
|
NATIVE_TO_MAP_POS(&map_x, &map_y, wld.map.xsize - 1, 0);
|
||
|
NATIVE_TO_MAP_POS(&map_x, &map_y, MAP_NATIVE_WIDTH - 1, 0);
|
||
|
map_to_gui_pos(tileset, map_zoom, &gui_x2, &gui_y2, map_x, map_y);
|
||
|
NATIVE_TO_MAP_POS(&map_x, &map_y, 0, wld.map.ysize - 1);
|
||
|
NATIVE_TO_MAP_POS(&map_x, &map_y, 0, MAP_NATIVE_HEIGHT - 1);
|
||
|
map_to_gui_pos(tileset, map_zoom, &gui_x3, &gui_y3, map_x, map_y);
|
||
|
NATIVE_TO_MAP_POS(&map_x, &map_y, wld.map.xsize - 1, wld.map.ysize - 1);
|
||
|
NATIVE_TO_MAP_POS(&map_x, &map_y, MAP_NATIVE_WIDTH - 1, MAP_NATIVE_HEIGHT - 1);
|
||
|
map_to_gui_pos(tileset, map_zoom, &gui_x4, &gui_y4, map_x, map_y);
|
||
|
*xmin = MIN(gui_x1, MIN(gui_x2, gui_x3)) - mapview.width / 2;
|
||
| client/overview_common.c | ||
|---|---|---|
|
/* Clip half tile left and right. See comment in map_to_overview_pos(). */
|
||
|
int shift = (MAP_IS_ISOMETRIC && !current_wrap_has_flag(WRAP_X)) ? -1 : 0;
|
||
|
if (recursion > 0 || wld.map.xsize <= 0 || wld.map.ysize <= 0) {
|
||
|
if (recursion > 0 || MAP_NATIVE_WIDTH <= 0 || MAP_NATIVE_HEIGHT <= 0) {
|
||
|
return;
|
||
|
}
|
||
|
recursion++;
|
||
| ... | ... | |
|
*
|
||
|
* It rounds up since this gives good results with the default settings.
|
||
|
* It may need tweaking if the panel resizes itself. */
|
||
|
OVERVIEW_TILE_SIZE = MIN((w - 1) / (wld.map.xsize * xfact) + 1,
|
||
|
(h - 1) / wld.map.ysize + 1);
|
||
|
OVERVIEW_TILE_SIZE = MIN((w - 1) / (MAP_NATIVE_WIDTH * xfact) + 1,
|
||
|
(h - 1) / MAP_NATIVE_HEIGHT + 1);
|
||
|
OVERVIEW_TILE_SIZE = MAX(OVERVIEW_TILE_SIZE, 1);
|
||
|
log_debug("Map size %d,%d - area size %d,%d - scale: %d", wld.map.xsize,
|
||
|
wld.map.ysize, w, h, OVERVIEW_TILE_SIZE);
|
||
|
log_debug("Map size %d,%d - area size %d,%d - scale: %d", MAP_NATIVE_WIDTH,
|
||
|
MAP_NATIVE_HEIGHT, w, h, OVERVIEW_TILE_SIZE);
|
||
|
gui_options.overview.width
|
||
|
= OVERVIEW_TILE_WIDTH * wld.map.xsize + shift * OVERVIEW_TILE_SIZE;
|
||
|
gui_options.overview.height = OVERVIEW_TILE_HEIGHT * wld.map.ysize;
|
||
|
= OVERVIEW_TILE_WIDTH * MAP_NATIVE_WIDTH + shift * OVERVIEW_TILE_SIZE;
|
||
|
gui_options.overview.height = OVERVIEW_TILE_HEIGHT * MAP_NATIVE_HEIGHT;
|
||
|
if (gui_options.overview.map) {
|
||
|
canvas_free(gui_options.overview.map);
|
||
| common/map.c | ||
|---|---|---|
|
*
|
||
|
* Thus the "center" position below is just an arbitrary point. We choose
|
||
|
* the center of the map to make the min/max values (below) simpler. */
|
||
|
nat_center_x = wld.map.xsize / 2;
|
||
|
nat_center_y = wld.map.ysize / 2;
|
||
|
nat_center_x = MAP_NATIVE_WIDTH / 2;
|
||
|
nat_center_y = MAP_NATIVE_HEIGHT / 2;
|
||
|
NATIVE_TO_MAP_POS(&map_center_x, &map_center_y,
|
||
|
nat_center_x, nat_center_y);
|
||
| ... | ... | |
|
* just have to make sure we go far enough if we're at one edge of the
|
||
|
* map. */
|
||
|
nat_min_x = (current_wrap_has_flag(WRAP_X) ? 0
|
||
|
: (nat_center_x - wld.map.xsize + 1));
|
||
|
: (nat_center_x - MAP_NATIVE_WIDTH + 1));
|
||
|
nat_min_y = (current_wrap_has_flag(WRAP_Y) ? 0
|
||
|
: (nat_center_y - wld.map.ysize + 1));
|
||
|
: (nat_center_y - MAP_NATIVE_HEIGHT + 1));
|
||
|
nat_max_x = (current_wrap_has_flag(WRAP_X)
|
||
|
? (wld.map.xsize - 1)
|
||
|
: (nat_center_x + wld.map.xsize - 1));
|
||
|
? (MAP_NATIVE_WIDTH - 1)
|
||
|
: (nat_center_x + MAP_NATIVE_WIDTH - 1));
|
||
|
nat_max_y = (current_wrap_has_flag(WRAP_Y)
|
||
|
? (wld.map.ysize - 1)
|
||
|
: (nat_center_y + wld.map.ysize - 1));
|
||
|
? (MAP_NATIVE_HEIGHT - 1)
|
||
|
: (nat_center_y + MAP_NATIVE_HEIGHT - 1));
|
||
|
tiles = (nat_max_x - nat_min_x + 1) * (nat_max_y - nat_min_y + 1);
|
||
|
fc_assert(wld.map.iterate_outwards_indices == nullptr);
|
||
| ... | ... | |
|
}
|
||
|
/*******************************************************************//**
|
||
|
map_init_topology needs to be called after map.topology_id is changed.
|
||
|
map_init_topology() needs to be called after map.topology_id is changed.
|
||
|
map.xsize and map.ysize must be set before calling map_init_topology().
|
||
|
This is done by the map generator code (server), when loading a savegame
|
||
| ... | ... | |
|
{
|
||
|
enum direction8 dir;
|
||
|
/* Sanity check for iso topologies*/
|
||
|
fc_assert(!MAP_IS_ISOMETRIC || (wld.map.ysize % 2) == 0);
|
||
|
/* Sanity check for iso topologies */
|
||
|
fc_assert(!MAP_IS_ISOMETRIC || (MAP_NATIVE_HEIGHT % 2) == 0);
|
||
|
/* The size and ratio must satisfy the minimum and maximum *linear*
|
||
|
* restrictions on width */
|
||
|
fc_assert(wld.map.xsize >= MAP_MIN_LINEAR_SIZE);
|
||
|
fc_assert(wld.map.ysize >= MAP_MIN_LINEAR_SIZE);
|
||
|
fc_assert(wld.map.xsize <= MAP_MAX_LINEAR_SIZE);
|
||
|
fc_assert(wld.map.ysize <= MAP_MAX_LINEAR_SIZE);
|
||
|
fc_assert(MAP_NATIVE_WIDTH >= MAP_MIN_LINEAR_SIZE);
|
||
|
fc_assert(MAP_NATIVE_HEIGHT >= MAP_MIN_LINEAR_SIZE);
|
||
|
fc_assert(MAP_NATIVE_WIDTH <= MAP_MAX_LINEAR_SIZE);
|
||
|
fc_assert(MAP_NATIVE_HEIGHT <= MAP_MAX_LINEAR_SIZE);
|
||
|
fc_assert(map_num_tiles() >= MAP_MIN_SIZE * 1000);
|
||
|
fc_assert(map_num_tiles() <= MAP_MAX_SIZE * 1000);
|
||
| ... | ... | |
|
/* If the position is out of range in a non-wrapping direction, it is
|
||
|
* unreal. */
|
||
|
if (current_wrap_has_flag(WRAP_X)) {
|
||
|
nat_x = FC_WRAP(nat_x, wld.map.xsize);
|
||
|
} else if (nat_x < 0 || nat_x >= wld.map.xsize) {
|
||
|
nat_x = FC_WRAP(nat_x, MAP_NATIVE_WIDTH);
|
||
|
} else if (nat_x < 0 || nat_x >= MAP_NATIVE_WIDTH) {
|
||
|
return nullptr;
|
||
|
}
|
||
|
if (current_wrap_has_flag(WRAP_Y)) {
|
||
|
nat_y = FC_WRAP(nat_y, wld.map.ysize);
|
||
|
} else if (nat_y < 0 || nat_y >= wld.map.ysize) {
|
||
|
nat_y = FC_WRAP(nat_y, MAP_NATIVE_HEIGHT);
|
||
|
} else if (nat_y < 0 || nat_y >= MAP_NATIVE_HEIGHT) {
|
||
|
return nullptr;
|
||
|
}
|
||
| ... | ... | |
|
int nat_x, nat_y;
|
||
|
MAP_TO_NATIVE_POS(&nat_x, &nat_y, x, y);
|
||
|
return nat_x >= 0 && nat_x < wld.map.xsize
|
||
|
&& nat_y >= 0 && nat_y < wld.map.ysize;
|
||
|
return nat_x >= 0 && nat_x < MAP_NATIVE_WIDTH
|
||
|
&& nat_y >= 0 && nat_y < MAP_NATIVE_HEIGHT;
|
||
|
}
|
||
|
/*******************************************************************//**
|
||
| ... | ... | |
|
MAP_TO_NATIVE_POS(&nat_x, &nat_y, x, y);
|
||
|
if (!current_wrap_has_flag(WRAP_X)) {
|
||
|
nat_x = CLIP(0, nat_x, wld.map.xsize - 1);
|
||
|
nat_x = CLIP(0, nat_x, MAP_NATIVE_WIDTH - 1);
|
||
|
}
|
||
|
if (!current_wrap_has_flag(WRAP_Y)) {
|
||
|
nat_y = CLIP(0, nat_y, wld.map.ysize - 1);
|
||
|
nat_y = CLIP(0, nat_y, MAP_NATIVE_HEIGHT - 1);
|
||
|
}
|
||
|
NATIVE_TO_MAP_POS(&x, &y, nat_x, nat_y);
|
||
| ... | ... | |
|
***********************************************************************/
|
||
|
int map_num_tiles(void)
|
||
|
{
|
||
|
return wld.map.xsize * wld.map.ysize;
|
||
|
return MAP_NATIVE_WIDTH * MAP_NATIVE_HEIGHT;
|
||
|
}
|
||
|
/*******************************************************************//**
|
||
| ... | ... | |
|
*dy = y1dv - y0dv;
|
||
|
if (current_wrap_has_flag(WRAP_X)) {
|
||
|
/* Wrap dx to be in [-map.xsize / 2, map.xsize / 2). */
|
||
|
*dx = FC_WRAP(*dx + wld.map.xsize / 2, wld.map.xsize) - wld.map.xsize / 2;
|
||
|
*dx = FC_WRAP(*dx + MAP_NATIVE_WIDTH / 2, MAP_NATIVE_WIDTH)
|
||
|
- MAP_NATIVE_WIDTH / 2;
|
||
|
}
|
||
|
if (current_wrap_has_flag(WRAP_Y)) {
|
||
|
/* Wrap dy to be in [-map.ysize / 2, map.ysize / 2). */
|
||
|
*dy = FC_WRAP(*dy + wld.map.ysize / 2, wld.map.ysize) - wld.map.ysize / 2;
|
||
|
*dy = FC_WRAP(*dy + MAP_NATIVE_HEIGHT / 2, MAP_NATIVE_HEIGHT)
|
||
|
- MAP_NATIVE_HEIGHT / 2;
|
||
|
}
|
||
|
/* Convert the native delta vector back to a pair of map positions. */
|
||
| ... | ... | |
|
***********************************************************************/
|
||
|
struct tile *rand_map_pos(const struct civ_map *nmap)
|
||
|
{
|
||
|
int nat_x = fc_rand(wld.map.xsize), nat_y = fc_rand(wld.map.ysize);
|
||
|
int nat_x = fc_rand(MAP_NATIVE_WIDTH);
|
||
|
int nat_y = fc_rand(MAP_NATIVE_HEIGHT);
|
||
|
return native_pos_to_tile(nmap, nat_x, nat_y);
|
||
|
}
|
||
| common/mapimg.c | ||
|---|---|---|
|
mapimg_generate_name(pmapdef));
|
||
|
pimg = img_new(pmapdef, CURRENT_TOPOLOGY, CURRENT_WRAP,
|
||
|
wld.map.xsize, wld.map.ysize);
|
||
|
MAP_NATIVE_WIDTH, MAP_NATIVE_HEIGHT);
|
||
|
img_createmap(pimg);
|
||
|
if (!img_save(pimg, mapimgfile, path)) {
|
||
|
ret = FALSE;
|
||
| ... | ... | |
|
mapimg_generate_name(pmapdef));
|
||
|
pimg = img_new(pmapdef, CURRENT_TOPOLOGY, CURRENT_WRAP,
|
||
|
wld.map.xsize, wld.map.ysize);
|
||
|
MAP_NATIVE_WIDTH, MAP_NATIVE_HEIGHT);
|
||
|
img_createmap(pimg);
|
||
|
if (!img_save(pimg, mapimgfile, path)) {
|
||
|
ret = FALSE;
|
||
| common/traderoutes.c | ||
|---|---|---|
|
int weighted_distance
|
||
|
= ((100 - game.info.trade_world_rel_pct) * real_dist
|
||
|
+ game.info.trade_world_rel_pct
|
||
|
* (real_dist * 40 / MAX(wld.map.xsize, wld.map.ysize))) / 100;
|
||
|
* (real_dist * 40 / MAX(MAP_NATIVE_WIDTH, MAP_NATIVE_HEIGHT))) / 100;
|
||
|
bonus = weighted_distance
|
||
|
+ city_size_get(pc1) + city_size_get(pc2);
|
||
| ... | ... | |
|
if (game.info.caravan_bonus_style == CBS_CLASSIC) {
|
||
|
/* Should this be real_map_distance? */
|
||
|
int distance = map_distance(pc1->tile, pc2->tile);
|
||
|
int weighted_distance = ((100 - game.info.trade_world_rel_pct) * distance
|
||
|
+ game.info.trade_world_rel_pct
|
||
|
* (distance * 40 / MAX(wld.map.xsize, wld.map.ysize))) / 100;
|
||
|
int weighted_distance
|
||
|
= ((100 - game.info.trade_world_rel_pct) * distance
|
||
|
+ game.info.trade_world_rel_pct
|
||
|
* (distance * 40 / MAX(MAP_NATIVE_WIDTH, MAP_NATIVE_HEIGHT))) / 100;
|
||
|
tb = weighted_distance + 10;
|
||
|
tb = (tb * (pc1->surplus[O_TRADE] + pc2->surplus[O_TRADE])) / 24;
|
||
|
} else if (game.info.caravan_bonus_style == CBS_LOGARITHMIC) {
|
||
|
/* Logarithmic bonus */
|
||
|
int distance = real_map_distance(pc1->tile, pc2->tile);
|
||
|
int weighted_distance = ((100 - game.info.trade_world_rel_pct) * distance
|
||
|
+ game.info.trade_world_rel_pct
|
||
|
* (distance * 40 / MAX(wld.map.xsize, wld.map.ysize))) / 100;
|
||
|
int weighted_distance
|
||
|
= ((100 - game.info.trade_world_rel_pct) * distance
|
||
|
+ game.info.trade_world_rel_pct
|
||
|
* (distance * 40 / MAX(MAP_NATIVE_WIDTH, MAP_NATIVE_HEIGHT))) / 100;
|
||
|
tb = pow(log(weighted_distance + 20
|
||
|
+ max_trade_prod(pc1) + max_trade_prod(pc2)) * 2, 2);
|
||
| server/animals.c | ||
|---|---|---|
|
send_research_info(presearch, NULL);
|
||
|
for (i = 0;
|
||
|
i < wld.map.xsize * wld.map.ysize * wld.map.server.animals / 1000;
|
||
|
i < MAP_NATIVE_WIDTH * MAP_NATIVE_HEIGHT * wld.map.server.animals / 1000;
|
||
|
i++) {
|
||
|
place_animal(plr, 2 * 2 + 1 * 1);
|
||
|
}
|
||
| server/gamehand.c | ||
|---|---|---|
|
if (utype != NULL) {
|
||
|
iterate_outward(&(wld.map), starttile,
|
||
|
wld.map.xsize + wld.map.ysize, itertile) {
|
||
|
MAP_NATIVE_WIDTH + MAP_NATIVE_HEIGHT, itertile) {
|
||
|
if (!is_non_allied_unit_tile(itertile, pplayer,
|
||
|
utype_has_flag(utype, UTYF_FLAGLESS))
|
||
|
&& is_native_tile(utype, itertile)) {
|
||
| server/generator/fracture_map.c | ||
|---|---|---|
|
int x,y;
|
||
|
struct tile *ptile1;
|
||
|
/* Calculate the mountain level. map.server.mountains specifies the
|
||
|
/* Calculate the mountain level. map.server.mountains specifies the
|
||
|
* percentage of land that is turned into hills and mountains. */
|
||
|
hmap_mountain_level = (((hmap_max_level - hmap_shore_level)
|
||
|
* (100 - wld.map.server.steepness))
|
||
| ... | ... | |
|
/* For larger maps, increase the number of landmasses - makes the map more interesting */
|
||
|
num_landmass = 20 + 15 * get_sqsize();
|
||
|
landmass = (map_landmass *)fc_malloc((wld.map.xsize / 2 + wld.map.ysize / 2 + num_landmass) * sizeof(map_landmass));
|
||
|
fracture_points = (map_point *)fc_malloc((wld.map.xsize / 2 + wld.map.ysize / 2 + num_landmass) * sizeof(map_point));
|
||
|
landmass
|
||
|
= (map_landmass *)fc_malloc((MAP_NATIVE_WIDTH / 2 + MAP_NATIVE_HEIGHT / 2 + num_landmass) * sizeof(map_landmass));
|
||
|
fracture_points
|
||
|
= (map_point *)fc_malloc((MAP_NATIVE_WIDTH / 2 + MAP_NATIVE_HEIGHT / 2 + num_landmass) * sizeof(map_point));
|
||
|
height_map = fc_malloc(sizeof(*height_map) * MAP_INDEX_SIZE);
|
||
|
/* Setup a whole bunch of landmasses along the view bordere. These will be sunken
|
||
|
to create ocean terrain.*/
|
||
|
nn = 0;
|
||
|
for (x = 3; x < wld.map.xsize; x += 5, nn++) {
|
||
|
for (x = 3; x < MAP_NATIVE_WIDTH; x += 5, nn++) {
|
||
|
fracture_points[nn].x = x;
|
||
|
fracture_points[nn].y = 3;
|
||
|
}
|
||
|
for (x = 3; x < wld.map.xsize; x += 5, nn++) {
|
||
|
for (x = 3; x < MAP_NATIVE_WIDTH; x += 5, nn++) {
|
||
|
fracture_points[nn].x = x;
|
||
|
fracture_points[nn].y = wld.map.ysize - 3;
|
||
|
fracture_points[nn].y = MAP_NATIVE_HEIGHT - 3;
|
||
|
}
|
||
|
for (y = 3; y < wld.map.ysize; y += 5, nn++) {
|
||
|
for (y = 3; y < MAP_NATIVE_HEIGHT; y += 5, nn++) {
|
||
|
fracture_points[nn].x = 3;
|
||
|
fracture_points[nn].y = y;
|
||
|
}
|
||
|
for (y = 3; y < wld.map.ysize; y += 5, nn++) {
|
||
|
fracture_points[nn].x = wld.map.xsize - 3;
|
||
|
for (y = 3; y < MAP_NATIVE_HEIGHT; y += 5, nn++) {
|
||
|
fracture_points[nn].x = MAP_NATIVE_WIDTH - 3;
|
||
|
fracture_points[nn].y = y;
|
||
|
}
|
||
|
/* pick remaining points randomly */
|
||
|
/* Pick remaining points randomly */
|
||
|
mm = nn;
|
||
|
for (; nn < mm + num_landmass; nn++) {
|
||
|
fracture_points[nn].x = fc_rand(wld.map.xsize - 6) + 3;
|
||
|
fracture_points[nn].y = fc_rand(wld.map.ysize - 6) + 3;
|
||
|
fracture_points[nn].x = fc_rand(MAP_NATIVE_WIDTH - 6) + 3;
|
||
|
fracture_points[nn].y = fc_rand(MAP_NATIVE_HEIGHT - 6) + 3;
|
||
|
}
|
||
|
for (nn = 0; nn < mm + num_landmass; nn++) {
|
||
|
landmass[nn].minX = wld.map.xsize - 1;
|
||
|
landmass[nn].minY = wld.map.ysize - 1;
|
||
|
landmass[nn].minX = MAP_NATIVE_WIDTH - 1;
|
||
|
landmass[nn].minY = MAP_NATIVE_HEIGHT - 1;
|
||
|
landmass[nn].maxX = 0;
|
||
|
landmass[nn].maxY = 0;
|
||
|
x = fracture_points[nn].x;
|
||
| ... | ... | |
|
/* Assign cells to landmass. Gradually expand the radius of the
|
||
|
fracture point. */
|
||
|
for (rad = 1; rad < (wld.map.xsize >> 1); rad++) {
|
||
|
for (rad = 1; rad < (MAP_NATIVE_WIDTH >> 1); rad++) {
|
||
|
for (nn = 0; nn < mm + num_landmass; nn++) {
|
||
|
circle_bresenham(fracture_points[nn].x, fracture_points[nn].y, rad, nn+1);
|
||
|
}
|
||
|
}
|
||
|
/* put in some random fuzz */
|
||
|
/* Put in some random fuzz */
|
||
|
whole_map_iterate(&(wld.map), ptile) {
|
||
|
if (hmap(ptile) > hmap_shore_level) {
|
||
|
hmap(ptile) = hmap(ptile) + fc_rand(4) - 2;
|
||
| ... | ... | |
|
}
|
||
|
/**********************************************************************//**
|
||
|
Assign landmass in 3x3 area increments to avoid "holes" created by the
|
||
|
circle algorithm.
|
||
|
Assign landmass in 3x3 area increments to avoid "holes" created by the
|
||
|
circle algorithm.
|
||
|
**************************************************************************/
|
||
|
static void fmfill(int x, int y, int c, int r)
|
||
|
{
|
||
| ... | ... | |
|
struct tile *ptileX1Y1;
|
||
|
if (x < 0) {
|
||
|
x = wld.map.xsize + x;
|
||
|
} else if (x > wld.map.xsize) {
|
||
|
x = x - wld.map.xsize;
|
||
|
x = MAP_NATIVE_WIDTH + x;
|
||
|
} else if (x > MAP_NATIVE_WIDTH) {
|
||
|
x = x - MAP_NATIVE_WIDTH;
|
||
|
}
|
||
|
x_less = x - 1;
|
||
|
if (x_less < 0) {
|
||
|
x_less = wld.map.xsize - 1;
|
||
|
x_less = MAP_NATIVE_WIDTH - 1;
|
||
|
}
|
||
|
x_more = x + 1;
|
||
|
if (x_more >= wld.map.xsize) {
|
||
|
if (x_more >= MAP_NATIVE_WIDTH) {
|
||
|
x_more = 0;
|
||
|
}
|
||
|
y_less = y - 1;
|
||
|
if (y_less < 0) {
|
||
|
y_less = wld.map.ysize - 1;
|
||
|
y_less = MAP_NATIVE_HEIGHT - 1;
|
||
|
}
|
||
|
y_more = y + 1;
|
||
|
if (y_more >= wld.map.ysize) {
|
||
|
if (y_more >= MAP_NATIVE_HEIGHT) {
|
||
|
y_more = 0;
|
||
|
}
|
||
|
if (y >= 0 && y < wld.map.ysize) {
|
||
|
if (y >= 0 && y < MAP_NATIVE_HEIGHT) {
|
||
|
ptileXY = native_pos_to_tile(&(wld.map), x, y);
|
||
|
ptileX2Y = native_pos_to_tile(&(wld.map), x_more, y);
|
||
|
ptileX1Y = native_pos_to_tile(&(wld.map), x_less, y);
|
||
| server/generator/height_map.c | ||
|---|---|---|
|
return;
|
||
|
}
|
||
|
if (xr == wld.map.xsize) {
|
||
|
if (xr == MAP_NATIVE_WIDTH) {
|
||
|
x1wrap = 0;
|
||
|
}
|
||
|
if (yb == wld.map.ysize) {
|
||
|
if (yb == MAP_NATIVE_HEIGHT) {
|
||
|
y1wrap = 0;
|
||
|
}
|
||
| ... | ... | |
|
int xdiv2 = xdiv + (xnowrap ? 1 : 0);
|
||
|
int ydiv2 = ydiv + (ynowrap ? 1 : 0);
|
||
|
int xmax = wld.map.xsize - (xnowrap ? 1 : 0);
|
||
|
int ymax = wld.map.ysize - (ynowrap ? 1 : 0);
|
||
|
int xmax = MAP_NATIVE_WIDTH - (xnowrap ? 1 : 0);
|
||
|
int ymax = MAP_NATIVE_HEIGHT - (ynowrap ? 1 : 0);
|
||
|
int x_current, y_current;
|
||
|
/* Just need something > log(max(xsize, ysize)) for the recursion */
|
||
|
int step = wld.map.xsize + wld.map.ysize;
|
||
|
int step = MAP_NATIVE_WIDTH + MAP_NATIVE_HEIGHT;
|
||
|
/* Edges are avoided more strongly as this increases */
|
||
|
int avoidedge = (100 - wld.map.server.landpercent) * step / 100 + step / 3;
|
||
| server/generator/mapgen.c | ||
|---|---|---|
|
**************************************************************************/
|
||
|
static void make_plain(struct tile *ptile, int *to_be_placed )
|
||
|
{
|
||
|
/* in cold place we get tundra instead */
|
||
|
/* In cold place we get tundra instead */
|
||
|
if (tmap_is(ptile, TT_FROZEN)) {
|
||
|
tile_set_terrain(ptile,
|
||
|
pick_terrain(MG_FROZEN, MG_UNUSED, MG_MOUNTAINOUS));
|
||
|
pick_terrain(MG_FROZEN, MG_UNUSED, MG_MOUNTAINOUS));
|
||
|
} else if (tmap_is(ptile, TT_COLD)) {
|
||
|
tile_set_terrain(ptile,
|
||
|
pick_terrain(MG_COLD, MG_UNUSED, MG_MOUNTAINOUS));
|
||
|
pick_terrain(MG_COLD, MG_UNUSED, MG_MOUNTAINOUS));
|
||
|
} else {
|
||
|
tile_set_terrain(ptile,
|
||
|
pick_terrain(MG_TEMPERATE, MG_GREEN, MG_MOUNTAINOUS));
|
||
|
pick_terrain(MG_TEMPERATE, MG_GREEN, MG_MOUNTAINOUS));
|
||
|
}
|
||
|
map_set_placed(ptile);
|
||
|
(*to_be_placed)--;
|
||
| ... | ... | |
|
/* Don't use any restriction here ! */
|
||
|
if ((ptile = rand_map_pos_characteristic(WC_ALL, TT_ALL, MC_NONE))) {
|
||
|
make_plain(ptile, &plains_count);
|
||
|
make_plain(ptile, &plains_count);
|
||
|
} else {
|
||
|
/* If rand_map_pos_temperature returns FALSE we may as well stop
|
||
|
* looking for plains. */
|
||
|
plains_count = 0;
|
||
|
/* If rand_map_pos_temperature returns FALSE we may as well stop
|
||
|
* looking for plains. */
|
||
|
plains_count = 0;
|
||
|
}
|
||
|
}
|
||
|
} while (forests_count > 0 || jungles_count > 0
|
||
| ... | ... | |
|
} cardinal_adjc_dir_iterate_end;
|
||
|
fc_assert_action(best_val != -1, continue);
|
||
|
/* should we abort? */
|
||
|
/* Should we abort? */
|
||
|
if (best_val > 0 && test_funcs[func_num].fatal) {
|
||
|
return FALSE;
|
||
|
return FALSE;
|
||
|
}
|
||
|
/* mark the less attractive directions as invalid */
|
||
|
/* Mark the less attractive directions as invalid */
|
||
|
cardinal_adjc_dir_base_iterate(&(wld.map), ptile, dir) {
|
||
|
if (rd_direction_is_valid[dir]) {
|
||
|
if (rd_comparison_val[dir] != best_val) {
|
||
|
rd_direction_is_valid[dir] = FALSE;
|
||
|
}
|
||
|
}
|
||
|
if (rd_direction_is_valid[dir]) {
|
||
|
if (rd_comparison_val[dir] != best_val) {
|
||
|
rd_direction_is_valid[dir] = FALSE;
|
||
|
}
|
||
|
}
|
||
|
} cardinal_adjc_dir_base_iterate_end;
|
||
|
}
|
||
| ... | ... | |
|
num_valid_directions = 0;
|
||
|
cardinal_adjc_dir_base_iterate(&(wld.map), ptile, dir) {
|
||
|
if (rd_direction_is_valid[dir]) {
|
||
|
num_valid_directions++;
|
||
|
num_valid_directions++;
|
||
|
}
|
||
|
} cardinal_adjc_dir_base_iterate_end;
|
||
| ... | ... | |
|
/* Rivers need to be on land only. */
|
||
|
wld.map.server.landpercent /
|
||
|
/* Adjustment value. Tested by me. Gives no rivers with 'set
|
||
|
rivers 0', gives a reasonable amount of rivers with default
|
||
|
settings and as many rivers as possible with 'set rivers 100'. */
|
||
|
rivers 0', gives a reasonable amount of rivers with default
|
||
|
settings and as many rivers as possible with 'set rivers 100'. */
|
||
|
5325;
|
||
|
/* The number of river tiles that have been set. */
|
||
| ... | ... | |
|
/* The main loop in this function. */
|
||
|
while (current_riverlength < desirable_riverlength
|
||
|
&& iteration_counter < RIVERS_MAXTRIES) {
|
||
|
&& iteration_counter < RIVERS_MAXTRIES) {
|
||
|
if (!(ptile = rand_map_pos_characteristic(WC_ALL, TT_NFROZEN,
|
||
|
MC_NLOW))) {
|
||
|
break; /* mo more spring places */
|
||
|
MC_NLOW))) {
|
||
|
break; /* mo more spring places */
|
||
|
}
|
||
|
pterrain = tile_terrain(ptile);
|
||
|
/* Check if it is suitable to start a river on the current tile.
|
||
|
*/
|
||
|
if (
|
||
|
/* Don't start a river on ocean. */
|
||
|
!is_ocean(pterrain)
|
||
|
/* Don't start a river on ocean. */
|
||
|
!is_ocean(pterrain)
|
||
|
/* Don't start a river on river. */
|
||
|
&& !tile_has_river(ptile)
|
||
|
/* Don't start a river on river. */
|
||
|
&& !tile_has_river(ptile)
|
||
|
/* Don't start a river on a tile is surrounded by > 1 river +
|
||
|
ocean tile. */
|
||
| ... | ... | |
|
MG_MOUNTAINOUS) < 90
|
||
|
|| iteration_counter >= RIVERS_MAXTRIES / 10 * 5)
|
||
|
/* Don't start a river on hills unless it is hard to find
|
||
|
somewhere else to start it. */
|
||
|
&& (pterrain->property[MG_MOUNTAINOUS] == 0
|
||
|
|| iteration_counter >= RIVERS_MAXTRIES / 10 * 6)
|
||
|
/* Don't start a river on hills unless it is hard to find
|
||
|
somewhere else to start it. */
|
||
|
&& (pterrain->property[MG_MOUNTAINOUS] == 0
|
||
|
|| iteration_counter >= RIVERS_MAXTRIES / 10 * 6)
|
||
|
/* Don't start a river on arctic unless it is hard to find
|
||
|
somewhere else to start it. */
|
||
|
&& (pterrain->property[MG_FROZEN] == 0
|
||
|
|| iteration_counter >= RIVERS_MAXTRIES / 10 * 8)
|
||
|
/* Don't start a river on arctic unless it is hard to find
|
||
|
somewhere else to start it. */
|
||
|
&& (pterrain->property[MG_FROZEN] == 0
|
||
|
|| iteration_counter >= RIVERS_MAXTRIES / 10 * 8)
|
||
|
/* Don't start a river on desert unless it is hard to find
|
||
|
somewhere else to start it. */
|
||
|
&& (pterrain->property[MG_DRY] == 0
|
||
|
|| iteration_counter >= RIVERS_MAXTRIES / 10 * 9)) {
|
||
|
/* Don't start a river on desert unless it is hard to find
|
||
|
somewhere else to start it. */
|
||
|
&& (pterrain->property[MG_DRY] == 0
|
||
|
|| iteration_counter >= RIVERS_MAXTRIES / 10 * 9)) {
|
||
|
/* Reset river map before making a new river. */
|
||
|
dbv_clr_all(&rivermap.blocked);
|
||
| ... | ... | |
|
{
|
||
|
int xrnd, yrnd;
|
||
|
fc_assert_ret_val((pstate->e - pstate->w) > 0, NULL);
|
||
|
fc_assert_ret_val((pstate->e - pstate->w) < wld.map.xsize, NULL);
|
||
|
fc_assert_ret_val((pstate->s - pstate->n) > 0, NULL);
|
||
|
fc_assert_ret_val((pstate->s - pstate->n) < wld.map.ysize, NULL);
|
||
|
fc_assert_ret_val((pstate->e - pstate->w) > 0, nullptr);
|
||
|
fc_assert_ret_val((pstate->e - pstate->w) < MAP_NATIVE_WIDTH, nullptr);
|
||
|
fc_assert_ret_val((pstate->s - pstate->n) > 0, nullptr);
|
||
|
fc_assert_ret_val((pstate->s - pstate->n) < MAP_NATIVE_HEIGHT, nullptr);
|
||
|
xrnd = pstate->w + fc_rand(pstate->e - pstate->w);
|
||
|
yrnd = pstate->n + fc_rand(pstate->s - pstate->n);
|
||
| ... | ... | |
|
ycur + nat_y - pstate->n);
|
||
|
if (!tile0 || !tile1) {
|
||
|
return FALSE;
|
||
|
return FALSE;
|
||
|
}
|
||
|
if (hmap(tile0) != 0 && is_near_land(tile1)) {
|
||
|
return FALSE;
|
||
|
return FALSE;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
xcur + nat_x - pstate->w,
|
||
|
ycur + nat_y - pstate->n);
|
||
|
checkmass--;
|
||
|
if (checkmass <= 0) {
|
||
|
checkmass--;
|
||
|
if (checkmass <= 0) {
|
||
|
log_error("mapgen.c: mass doesn't sum up.");
|
||
|
return i != 0;
|
||
|
}
|
||
|
return i != 0;
|
||
|
}
|
||
|
tile_set_terrain(tile1, T_UNKNOWN);
|
||
|
map_unset_placed(tile1);
|
||
|
map_unset_placed(tile1);
|
||
|
tile_set_continent(tile1, pstate->isleindex);
|
||
|
tile_set_continent(tile1, pstate->isleindex);
|
||
|
i++;
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
}
|
||
|
/**********************************************************************//**
|
||
|
finds a place and drop the island created when called with islemass != 0
|
||
|
Finds a place and drop the island created when called with islemass != 0
|
||
|
**************************************************************************/
|
||
|
static bool create_island(int islemass, struct gen234_state *pstate)
|
||
|
{
|
||
|
int i, nat_x, nat_y;
|
||
|
long int tries = islemass * (2 + islemass / 20) + 99;
|
||
|
bool j;
|
||
|
struct tile *ptile = native_pos_to_tile(&(wld.map),
|
||
|
wld.map.xsize / 2, wld.map.ysize / 2);
|
||
|
struct tile *ptile
|
||
|
= native_pos_to_tile(&(wld.map),
|
||
|
MAP_NATIVE_WIDTH / 2, MAP_NATIVE_HEIGHT / 2);
|
||
|
memset(height_map, '\0', MAP_INDEX_SIZE * sizeof(*height_map));
|
||
|
hmap(native_pos_to_tile(&(wld.map),
|
||
|
wld.map.xsize / 2, wld.map.ysize / 2)) = 1;
|
||
|
MAP_NATIVE_WIDTH / 2, MAP_NATIVE_HEIGHT / 2)) = 1;
|
||
|
index_to_native_pos(&nat_x, &nat_y, tile_index(ptile));
|
||
|
pstate->n = nat_y - 1;
|
||
| ... | ... | |
|
&& hmap(ptile) == 0 && count_card_adjc_elevated_tiles(ptile) > 0) {
|
||
|
hmap(ptile) = 1;
|
||
|
i--;
|
||
|
if (nat_y >= pstate->s - 1 && pstate->s < wld.map.ysize - 2) {
|
||
|
if (nat_y >= pstate->s - 1 && pstate->s < MAP_NATIVE_HEIGHT - 2) {
|
||
|
pstate->s++;
|
||
|
}
|
||
|
if (nat_x >= pstate->e - 1 && pstate->e < wld.map.xsize - 2) {
|
||
|
if (nat_x >= pstate->e - 1 && pstate->e < MAP_NATIVE_WIDTH - 2) {
|
||
|
pstate->e++;
|
||
|
}
|
||
|
if (nat_y <= pstate->n && pstate->n > 2) {
|
||
| ... | ... | |
|
log_error("create_island ended early with %d/%d.", islemass-i, islemass);
|
||
|
}
|
||
|
tries = map_num_tiles() / 4; /* on a 40x60 map, there are 2400 places */
|
||
|
tries = map_num_tiles() / 4; /* On a 40x60 map, there are 2400 places */
|
||
|
while (!(j = place_island(pstate)) && (--tries) > 0) {
|
||
|
/* nothing */
|
||
|
/* Nothing */
|
||
|
}
|
||
|
return j;
|
||
|
}
|
||
| ... | ... | |
|
}
|
||
|
/**********************************************************************//**
|
||
|
make an island, fill every tile type except plains
|
||
|
note: you have to create big islands first.
|
||
|
Make an island, fill every tile type except plains
|
||
|
Note: you have to create big islands first.
|
||
|
Return TRUE if successful.
|
||
|
min_specific_island_size is a percent value.
|
||
|
**************************************************************************/
|
||
| ... | ... | |
|
struct gen234_state *pstate,
|
||
|
int min_specific_island_size)
|
||
|
{
|
||
|
/* int may be only 2 byte ! */
|
||
|
/* int may be only 2 bytes ! */
|
||
|
static long int tilefactor, balance, lastplaced;
|
||
|
static long int riverbuck, mountbuck, desertbuck, forestbuck, swampbuck;
|
||
|
int i;
|
||
| ... | ... | |
|
fc_assert_ret_val(island_terrain.init, FALSE);
|
||
|
if (islemass == 0) {
|
||
|
/* this only runs to initialise static things, not to actually
|
||
|
/* This only runs to initialise static things, not to actually
|
||
|
* create an island. */
|
||
|
balance = 0;
|
||
|
/* 0 = none, poles, then isles */
|
||
| ... | ... | |
|
checkmass = pstate->totalmass;
|
||
|
/* caveat: this should really be sent to all players */
|
||
|
/* Caveat: this should really be sent to all players */
|
||
|
if (pstate->totalmass > 3000) {
|
||
|
log_normal(_("High landmass - this may take a few seconds."));
|
||
|
}
|
||
| ... | ... | |
|
lastplaced = pstate->totalmass;
|
||
|
} else {
|
||
|
/* makes the islands this big */
|
||
|
/* Makes the islands this big */
|
||
|
islemass = islemass - balance;
|
||
|
if (islemass > lastplaced + 1 + lastplaced / 50) {
|
||
|
/* don't create big isles we can't place */
|
||
|
/* Don't create big isles we can't place */
|
||
|
islemass = lastplaced + 1 + lastplaced / 50;
|
||
|
}
|
||
|
/* isle creation does not perform well for nonsquare islands */
|
||
|
if (islemass > (wld.map.ysize - 6) * (wld.map.ysize - 6)) {
|
||
|
islemass = (wld.map.ysize - 6) * (wld.map.ysize - 6);
|
||
|
/* Isle creation does not perform well for nonsquare islands */
|
||
|
if (islemass > (MAP_NATIVE_HEIGHT - 6) * (MAP_NATIVE_HEIGHT - 6)) {
|
||
|
islemass = (MAP_NATIVE_HEIGHT - 6) * (MAP_NATIVE_HEIGHT - 6);
|
||
|
}
|
||
|
if (islemass > (wld.map.xsize - 2) * (wld.map.xsize - 2)) {
|
||
|
islemass = (wld.map.xsize - 2) * (wld.map.xsize - 2);
|
||
|
if (islemass > (MAP_NATIVE_WIDTH - 2) * (MAP_NATIVE_WIDTH - 2)) {
|
||
|
islemass = (MAP_NATIVE_WIDTH - 2) * (MAP_NATIVE_WIDTH - 2);
|
||
|
}
|
||
|
i = islemass;
|
||
| ... | ... | |
|
fc_assert_ret_val(starters >= 0, FALSE);
|
||
|
log_verbose("island %i", pstate->isleindex);
|
||
|
/* keep trying to place an island, and decrease the size of
|
||
|
/* Keep trying to place an island, and decrease the size of
|
||
|
* the island we're trying to create until we succeed.
|
||
|
* If we get too small, return an error. */
|
||
|
while (!create_island(i, pstate)) {
|
||
|
if (i < islemass * min_specific_island_size / 100) {
|
||
|
return FALSE;
|
||
|
return FALSE;
|
||
|
}
|
||
|
i--;
|
||
|
}
|
||
| ... | ... | |
|
riverbuck += river_pct * i;
|
||
|
fill_island_rivers(1, &riverbuck, pstate);
|
||
|
/* forest */
|
||
|
/* Forest */
|
||
|
forestbuck += forest_pct * i;
|
||
|
fill_island(60, &forestbuck, island_terrain.forest, pstate);
|
||
|
/* desert */
|
||
|
/* Desert */
|
||
|
desertbuck += desert_pct * i;
|
||
|
fill_island(40, &desertbuck, island_terrain.desert, pstate);
|
||
|
/* mountain */
|
||
|
/* Mountain */
|
||
|
mountbuck += mountain_pct * i;
|
||
|
fill_island(20, &mountbuck, island_terrain.mountain, pstate);
|
||
|
/* swamp */
|
||
|
/* Swamp */
|
||
|
swampbuck += swamp_pct * i;
|
||
|
fill_island(80, &swampbuck, island_terrain.swamp, pstate);
|
||
|
pstate->isleindex++;
|
||
|
wld.map.num_continents++;
|
||
|
}
|
||
|
return TRUE;
|
||
|
}
|
||
| ... | ... | |
|
int i;
|
||
|
bool done = FALSE;
|
||
|
int spares = 1;
|
||
|
/* constant that makes up that an island actually needs additional space */
|
||
|
/* Constant that makes up that an island actually needs additional space */
|
||
|
/* put 70% of land in big continents,
|
||
|
/* Put 70% of land in big continents,
|
||
|
* 20% in medium, and
|
||
|
* 10% in small. */
|
||
|
int bigfrac = 70, midfrac = 20, smallfrac = 10;
|
||
| ... | ... | |
|
return;
|
||
|
}
|
||
|
pstate->totalmass = ((wld.map.ysize - 6 - spares) * wld.map.server.landpercent
|
||
|
* (wld.map.xsize - spares)) / 100;
|
||
|
pstate->totalmass = ((MAP_NATIVE_HEIGHT - 6 - spares) * wld.map.server.landpercent
|
||
|
* (MAP_NATIVE_WIDTH - spares)) / 100;
|
||
|
totalweight = 100 * player_count();
|
||
|
fc_assert_action(!placed_map_is_initialized(),
|
||
| ... | ... | |
|
/* Create one big island for each player. */
|
||
|
for (i = player_count(); i > 0; i--) {
|
||
|
if (!make_island(bigfrac * pstate->totalmass / totalweight,
|
||
|
1, pstate, 95)) {
|
||
|
/* we couldn't make an island at least 95% as big as we wanted,
|
||
|
* and since we're trying hard to be fair, we need to start again,
|
||
|
* with all big islands reduced slightly in size.
|
||
|
* Take the size reduction from the big islands and add it to the
|
||
|
* small islands to keep overall landmass unchanged.
|
||
|
* Note that the big islands can get very small if necessary, and
|
||
|
* the smaller islands will not exist if we can't place them
|
||
|
1, pstate, 95)) {
|
||
|
/* We couldn't make an island at least 95% as big as we wanted,
|
||
|
* and since we're trying hard to be fair, we need to start again,
|
||
|
* with all big islands reduced slightly in size.
|
||
|
* Take the size reduction from the big islands and add it to the
|
||
|
* small islands to keep overall landmass unchanged.
|
||
|
* Note that the big islands can get very small if necessary, and
|
||
|
* the smaller islands will not exist if we can't place them
|
||
|
* easily. */
|
||
|
log_verbose("Island too small, trying again with all smaller "
|
||
|
"islands.");
|
||
|
midfrac += bigfrac * 0.01;
|
||
|
smallfrac += bigfrac * 0.04;
|
||
|
bigfrac *= 0.95;
|
||
|
done = FALSE;
|
||
|
break;
|
||
|
midfrac += bigfrac * 0.01;
|
||
|
smallfrac += bigfrac * 0.04;
|
||
|
bigfrac *= 0.95;
|
||
|
done = FALSE;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
destroy_placed_map();
|
||
|
free(height_map);
|
||
|
height_map = nullptr;
|
||
|
return;
|
||
|
}
|
||
| ... | ... | |
|
free(height_map);
|
||
|
height_map = nullptr;
|
||
|
if (checkmass > wld.map.xsize + wld.map.ysize + totalweight) {
|
||
|
if (checkmass > MAP_NATIVE_WIDTH + MAP_NATIVE_HEIGHT + totalweight) {
|
||
|
log_verbose("%ld mass left unplaced", checkmass);
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
return;
|
||
|
}
|
||
|
if (wld.map.xsize < 40 || wld.map.ysize < 40) {
|
||
|
if (MAP_NATIVE_WIDTH < 40 || MAP_NATIVE_HEIGHT < 40) {
|
||
|
log_verbose("ISLAND generator: falling back to FRACTAL generator due "
|
||
|
"to unsupported map size.");
|
||
|
wld.map.server.generator = MAPGEN_FRACTAL;
|
||
|
return;
|
||
|
}
|
||
|
pstate->totalmass = (((wld.map.ysize - 6 - spares) * wld.map.server.landpercent
|
||
|
* (wld.map.xsize - spares)) / 100);
|
||
|
pstate->totalmass = (((MAP_NATIVE_HEIGHT - 6 - spares) * wld.map.server.landpercent
|
||
|
* (MAP_NATIVE_WIDTH - spares)) / 100);
|
||
|
bigislands = player_count();
|
||
|
landmass = (wld.map.xsize * (wld.map.ysize - 6) * wld.map.server.landpercent)/100;
|
||
|
/* subtracting the arctics */
|
||
|
if (landmass > 3 * wld.map.ysize + player_count() * 3) {
|
||
|
landmass -= 3 * wld.map.ysize;
|
||
|
landmass = (MAP_NATIVE_WIDTH * (MAP_NATIVE_HEIGHT - 6) * wld.map.server.landpercent) / 100;
|
||
|
/* Subtracting the arctics */
|
||
|
if (landmass > 3 * MAP_NATIVE_HEIGHT + player_count() * 3) {
|
||
|
landmass -= 3 * MAP_NATIVE_HEIGHT;
|
||
|
}
|
||
|
islandmass = (landmass)/(3 * bigislands);
|
||
|
islandmass = (landmass) / (3 * bigislands);
|
||
|
if (islandmass < 4 * maxmassdiv6) {
|
||
|
islandmass = (landmass)/(2 * bigislands);
|
||
|
islandmass = (landmass) / (2 * bigislands);
|
||
|
}
|
||
|
if (islandmass < 3 * maxmassdiv6 && player_count() * 2 < landmass) {
|
||
|
islandmass = (landmass)/(bigislands);
|
||
|
islandmass = (landmass) / (bigislands);
|
||
|
}
|
||
|
if (islandmass < 2) {
|
||
|
islandmass = 2;
|
||
|
}
|
||
|
if (islandmass > maxmassdiv6 * 6) {
|
||
|
islandmass = maxmassdiv6 * 6;/* !PS: let's try this */
|
||
|
islandmass = maxmassdiv6 * 6; /* !PS: Let's try this */
|
||
|
}
|
||
|
initworld(pstate);
|
||
| ... | ... | |
|
}
|
||
|
make_island(size, (pstate->isleindex - 2 <= player_count()) ? 1 : 0,
|
||
|
pstate, DMSIS);
|
||
|
pstate, DMSIS);
|
||
|
}
|
||
|
height_map_to_map();
|
||
| ... | ... | |
|
if (j == 1500) {
|
||
|
log_normal(_("Generator 3 left %li landmass unplaced."), checkmass);
|
||
|
} else if (checkmass > wld.map.xsize + wld.map.ysize) {
|
||
|
} else if (checkmass > MAP_NATIVE_WIDTH + MAP_NATIVE_HEIGHT) {
|
||
|
log_verbose("%ld mass left unplaced", checkmass);
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
struct gen234_state state;
|
||
|
struct gen234_state *pstate = &state;
|
||
|
/* no islands with mass >> sqr(min(xsize,ysize)) */
|
||
|
/* No islands with mass >> sqr(min(xsize,ysize)) */
|
||
|
if (player_count() < 2 || wld.map.server.landpercent > 80) {
|
||
|
log_verbose("ISLAND generator: falling back to startpos=SINGLE");
|
||
| ... | ... | |
|
spares = (wld.map.server.landpercent - 5) / 30;
|
||
|
pstate->totalmass = (((wld.map.ysize - 6 - spares) * wld.map.server.landpercent
|
||
|
* (wld.map.xsize - spares)) / 100);
|
||
|
pstate->totalmass = (((MAP_NATIVE_HEIGHT - 6 - spares) * wld.map.server.landpercent
|
||
|
* (MAP_NATIVE_WIDTH - spares)) / 100);
|
||
|
/*!PS: The weights NEED to sum up to totalweight (dammit) */
|
||
|
totalweight = (30 + bigweight) * player_count();
|
||
| ... | ... | |
|
i = player_count() / 2;
|
||
|
if ((player_count() % 2) == 1) {
|
||
|
make_island(bigweight * 3 * pstate->totalmass / totalweight, 3,
|
||
|
pstate, DMSIS);
|
||
|
pstate, DMSIS);
|
||
|
} else {
|
||
|
i++;
|
||
|
}
|
||
|
while ((--i) > 0) {
|
||
|
make_island(bigweight * 2 * pstate->totalmass / totalweight, 2,
|
||
|
pstate, DMSIS);
|
||
|
pstate, DMSIS);
|
||
|
}
|
||
|
for (i = player_count(); i > 0; i--) {
|
||
|
make_island(20 * pstate->totalmass / totalweight, 0, pstate, DMSIS);
|
||
| ... | ... | |
|
free(height_map);
|
||
|
height_map = nullptr;
|
||
|
if (checkmass > wld.map.xsize + wld.map.ysize + totalweight) {
|
||
|
if (checkmass > MAP_NATIVE_WIDTH + MAP_NATIVE_HEIGHT + totalweight) {
|
||
|
log_verbose("%ld mass left unplaced", checkmass);
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
MAP_TO_NATIVE_POS(&nat_x, &nat_y, x, y);
|
||
|
/* Wrap in X and Y directions, as needed. */
|
||
|
if (nat_x < 0 || nat_x >= wld.map.xsize) {
|
||
|
if (nat_x < 0 || nat_x >= MAP_NATIVE_WIDTH) {
|
||
|
if (current_wrap_has_flag(WRAP_X)) {
|
||
|
nat_x = FC_WRAP(nat_x, wld.map.xsize);
|
||
|
nat_x = FC_WRAP(nat_x, MAP_NATIVE_WIDTH);
|
||
|
} else {
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
}
|
||
|
if (nat_y < 0 || nat_y >= wld.map.ysize) {
|
||
|
if (nat_y < 0 || nat_y >= MAP_NATIVE_HEIGHT) {
|
||
|
if (current_wrap_has_flag(WRAP_Y)) {
|
||
|
nat_y = FC_WRAP(nat_y, wld.map.ysize);
|
||
|
nat_y = FC_WRAP(nat_y, MAP_NATIVE_HEIGHT);
|
||
|
} else {
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
fair_map_tile_pos(pmap, ptile, &x, &y);
|
||
|
DIRSTEP(dx, dy, dir);
|
||
|
return fair_map_pos_tile(pmap, x + dx, y + dy);
|
||
|
}
|
||
| ... | ... | |
|
index_to_native_pos(&nat_x, &nat_y, ptile - pmap);
|
||
|
if (!current_wrap_has_flag(WRAP_X)
|
||
|
&& (nat_x < dist || nat_x >= wld.map.xsize - dist)) {
|
||
|
&& (nat_x < dist || nat_x >= MAP_NATIVE_WIDTH - dist)) {
|
||
|
return TRUE;
|
||
|
}
|
||
| ... | ... | |
|
}
|
||
|
if (!current_wrap_has_flag(WRAP_Y)
|
||
|
&& (nat_y < dist || nat_y >= wld.map.ysize - dist)) {
|
||
|
&& (nat_y < dist || nat_y >= MAP_NATIVE_HEIGHT - dist)) {
|
||
|
return TRUE;
|
||
|
}
|
||
| ... | ... | |
|
const struct fair_geometry_data *data,
|
||
|
int startpos_team_id)
|
||
|
{
|
||
|
int sdx = wld.map.xsize / 2, sdy = wld.map.ysize / 2;
|
||
|
int sdx = MAP_NATIVE_WIDTH / 2, sdy = MAP_NATIVE_HEIGHT / 2;
|
||
|
struct fair_tile *smax_tile = psource + MAP_INDEX_SIZE;
|
||
|
struct fair_tile *pstile, *pttile;
|
||
|
int x, y;
|
||
| ... | ... | |
|
size = CLIP(startpos_num, size, ARRAY_SIZE(land_tiles));
|
||
|
fantasy = (size * 2) / 5;
|
||
|
pisland = fair_map_new();
|
||
|
pftile = fair_map_pos_tile(pisland, wld.map.xsize / 2, wld.map.ysize / 2);
|
||
|
pftile = fair_map_pos_tile(pisland, MAP_NATIVE_WIDTH / 2, MAP_NATIVE_HEIGHT / 2);
|
||
|
fc_assert(!fair_map_tile_border(pisland, pftile, sea_around_island));
|
||
|
pftile->flags |= FTF_ASSIGNED;
|
||
|
land_tiles[0] = pftile;
|
||
| ... | ... | |
|
/* Make start point for teams. */
|
||
|
if (current_wrap_has_flag(WRAP_X)) {
|
||
|
dx = fc_rand(wld.map.xsize);
|
||
|
dx = fc_rand(MAP_NATIVE_WIDTH);
|
||
|
}
|
||
|
if (current_wrap_has_flag(WRAP_Y)) {
|
||
|
dy = fc_rand(wld.map.ysize);
|
||
|
dy = fc_rand(MAP_NATIVE_HEIGHT);
|
||
|
}
|
||
|
for (j = 0; j < teams_num; j++) {
|
||
|
start_x[j] = (wld.map.xsize * (2 * j + 1)) / (2 * teams_num) + dx;
|
||
|
start_y[j] = (wld.map.ysize * (2 * j + 1)) / (2 * teams_num) + dy;
|
||
|
start_x[j] = (MAP_NATIVE_WIDTH * (2 * j + 1)) / (2 * teams_num) + dx;
|
||
|
start_y[j] = (MAP_NATIVE_HEIGHT * (2 * j + 1)) / (2 * teams_num) + dy;
|
||
|
if (current_wrap_has_flag(WRAP_X)) {
|
||
|
start_x[j] = FC_WRAP(start_x[j], wld.map.xsize);
|
||
|
start_x[j] = FC_WRAP(start_x[j], MAP_NATIVE_WIDTH);
|
||
|
}
|
||
|
if (current_wrap_has_flag(WRAP_Y)) {
|
||
|
start_y[j] = FC_WRAP(start_y[j], wld.map.ysize);
|
||
|
start_y[j] = FC_WRAP(start_y[j], MAP_NATIVE_HEIGHT);
|
||
|
}
|
||
|
}
|
||
|
/* Randomize. */
|
||
| server/generator/temperature_map.c | ||
|---|---|---|
|
char *p = buf;
|
||
|
int i, idx;
|
||
|
for (i = 0; i < wld.map.xsize; i++) {
|
||
|
idx = ycoor * wld.map.xsize + i;
|
||
|
for (i = 0; i < MAP_NATIVE_WIDTH; i++) {
|
||
|
idx = ycoor * MAP_NATIVE_WIDTH + i;
|
||
|
if (idx > wld.map.xsize * wld.map.ysize) {
|
||
|
if (idx > MAP_NATIVE_WIDTH * MAP_NATIVE_HEIGHT) {
|
||
|
break;
|
||
|
}
|
||
|
switch (temperature_map[idx]) {
|
||
|
case TT_TROPICAL:
|
||
|
*p++ = 't'; /* tropical */
|
||
|
*p++ = 't'; /* Tropical */
|
||
|
break;
|
||
|
case TT_TEMPERATE:
|
||
|
*p++ = 'm'; /* medium */
|
||
|
*p++ = 'm'; /* Medium */
|
||
|
break;
|
||
|
case TT_COLD:
|
||
|
*p++ = 'c'; /* cold */
|
||
|
*p++ = 'c'; /* Cold */
|
||
|
break;
|
||
|
case TT_FROZEN:
|
||
|
*p++ = 'f'; /* frozen */
|
||
|
*p++ = 'f'; /* Frozen */
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
{
|
||
|
int i;
|
||
|
/* if map is defined this is not changed */
|
||
|
/* TODO: load if from scenario game with tmap */
|
||
|
/* If map is defined this is not changed. */
|
||
|
/* TODO: Load if from scenario game with tmap */
|
||
|
/* to debug, never load a this time */
|
||
|
fc_assert_ret(NULL == temperature_map);
|
||
|
temperature_map = fc_malloc(sizeof(*temperature_map) * MAP_INDEX_SIZE);
|
||
|
whole_map_iterate(&(wld.map), ptile) {
|
||
|
/* the base temperature is equal to base map_colatitude */
|
||
|
/* The base temperature is equal to base map_colatitude */
|
||
|
int t = map_colatitude(ptile);
|
||
|
if (!real) {
|
||
|
tmap(ptile) = t;
|
||
|
} else {
|
||
|
/* high land can be 30% cooler */
|
||
|
/* High land can be 30% cooler */
|
||
|
float height = - 0.3 * MAX(0, hmap(ptile) - hmap_shore_level)
|
||
|
/ (hmap_max_level - hmap_shore_level);
|
||
|
int tcn = count_terrain_class_near_tile(&(wld.map), ptile, FALSE, TRUE, TC_OCEAN);
|
||
|
/* near ocean temperature can be 15% more "temperate" */
|
||
|
/* Near ocean temperature can be 15% more "temperate" */
|
||
|
float temperate = (0.15 * (wld.map.server.temperature / 100 - t
|
||
|
/ MAX_COLATITUDE)
|
||
|
* 2 * MIN(50, tcn)
|
||
| ... | ... | |
|
}
|
||
|
} whole_map_iterate_end;
|
||
|
/* adjust to get evenly distributed frequencies
|
||
|
/* Adjust to get evenly distributed frequencies.
|
||
|
* Only call adjust when the colatitude range is large enough for this to
|
||
|
* make sense - if most variation comes from height and coast, don't try
|
||
|
* to squish that back into its original narrow range */
|
||
| ... | ... | |
|
MAX_REAL_COLATITUDE(wld.map));
|
||
|
}
|
||
|
/* now simplify to 4 base values */
|
||
|
/* Now simplify to 4 base values */
|
||
|
for (i = 0; i < MAP_INDEX_SIZE; i++) {
|
||
|
int t = temperature_map[i];
|
||
| ... | ... | |
|
log_debug("%stemperature map ({f}rozen, {c}old, {m}edium, {t}ropical):",
|
||
|
real ? "real " : "");
|
||
|
for (i = 0; i < wld.map.ysize; i++) {
|
||
|
for (i = 0; i < MAP_NATIVE_HEIGHT; i++) {
|
||
|
log_debug("%5d: %s", i, tmap_y2str(i));
|
||
|
}
|
||
|
}
|
||
| server/maphand.c | ||
|---|---|---|
|
dest = game.est_connections;
|
||
|
}
|
||
|
/* send whole map piece by piece to each player to balance the load
|
||
|
/* Send whole map piece by piece to each player to balance the load
|
||
|
of the send buffers better */
|
||
|
tiles_sent = 0;
|
||
|
conn_list_do_buffer(dest);
|
||
|
whole_map_iterate(&(wld.map), ptile) {
|
||
|
tiles_sent++;
|
||
|
if ((tiles_sent % wld.map.xsize) == 0) {
|
||
|
if ((tiles_sent % MAP_NATIVE_WIDTH) == 0) {
|
||
|
conn_list_do_unbuffer(dest);
|
||
|
flush_packets();
|
||
|
conn_list_do_buffer(dest);
|
||
| ... | ... | |
|
{
|
||
|
struct packet_map_info minfo;
|
||
|
minfo.xsize = wld.map.xsize;
|
||
|
minfo.ysize = wld.map.ysize;
|
||
|
minfo.xsize = MAP_NATIVE_WIDTH;
|
||
|
minfo.ysize = MAP_NATIVE_HEIGHT;
|
||
|
minfo.topology_id = wld.map.topology_id;
|
||
|
minfo.wrap_id = wld.map.wrap_id;
|
||
|
minfo.north_latitude = wld.map.north_latitude;
|
||
| server/savegame/savegame2.c | ||
|---|---|---|
|
*/
|
||
|
#define SAVE_MAP_CHAR(ptile, GET_XY_CHAR, secfile, secpath, ...) \
|
||
|
{ \
|
||
|
char _line[wld.map.xsize + 1]; \
|
||
|
char _line[MAP_NATIVE_WIDTH + 1]; \
|
||
|
int _nat_x, _nat_y; \
|
||
|
\
|
||
|
for (_nat_y = 0; _nat_y < wld.map.ysize; _nat_y++) { \
|
||
|
for (_nat_x = 0; _nat_x < wld.map.xsize; _nat_x++) { \
|
||
|
for (_nat_y = 0; _nat_y < MAP_NATIVE_HEIGHT; _nat_y++) { \
|
||
|
for (_nat_x = 0; _nat_x < MAP_NATIVE_WIDTH; _nat_x++) { \
|
||
|
struct tile *ptile = native_pos_to_tile(&(wld.map), _nat_x, _nat_y); \
|
||
|
fc_assert_action(ptile != NULL, continue); \
|
||
|
_line[_nat_x] = (GET_XY_CHAR); \
|
||