Project

Profile

Help

HostedRedmine.com has moved to the Planio platform. All logins and passwords remained the same. All users will be able to login and use Redmine just as before. *Read more...*

Feature #826830 ยป 0039-Make-extra-placing-to-take-place-at-turn-change.patch

Marko Lindqvist, 2019-07-16 02:04 AM

View differences:

client/packhand.c
tile_changed = TRUE;
}
if (packet->placing < 0) {
ptile->placing = NULL;
} else {
ptile->placing = extra_by_number(packet->placing);
}
if (NULL == tile_worked(ptile)
|| tile_worked(ptile)->id != packet->worked) {
if (IDENTITY_NUMBER_ZERO != packet->worked) {
common/extras.c
return FALSE;
}
if (ptile->placing != NULL) {
/* Already placing something */
return FALSE;
}
if (game.info.borders != BORDERS_DISABLED) {
if (tile_owner(ptile) != pplayer) {
return FALSE;
......
} else {
struct city *pcity = tile_worked(ptile);
if (pcity != NULL) {
if (city_owner(pcity) != pplayer) {
return FALSE;
}
} else {
bool suitable_city = FALSE;
city_tile_iterate(CITY_MAP_MAX_RADIUS_SQ, ptile, ctile) {
pcity = tile_city(ctile);
if (pcity != NULL && city_owner(pcity) == pplayer) {
int dist = map_distance(ptile, ctile);
if (city_map_radius_sq_get(pcity) <= dist * dist) {
suitable_city = TRUE;
break;
}
}
} city_tile_iterate_end;
if (!suitable_city) {
return FALSE;
}
if (pcity == NULL || city_owner(pcity) != pplayer) {
return FALSE;
}
}
common/map.c
ptile->units = unit_list_new();
ptile->owner = NULL; /* Not claimed by any player. */
ptile->extras_owner = NULL;
ptile->placing = NULL;
ptile->claimer = NULL;
ptile->worked = NULL; /* No city working here. */
ptile->spec_sprite = NULL;
common/networking/packets.def
TERRAIN terrain;
RESOURCE resource;
BV_EXTRAS extras;
EXTRA placing;
STRING spec_sprite[MAX_LEN_NAME];
STRING label[MAX_LEN_MAP_LABEL];
end
common/tile.c
vtile->units = unit_list_new();
vtile->worked = NULL;
vtile->owner = NULL;
vtile->placing = NULL;
vtile->extras_owner = NULL;
vtile->claimer = NULL;
vtile->spec_sprite = NULL;
......
return changed;
}
/************************************************************************//**
Is there a placing ongoing?
****************************************************************************/
bool tile_is_placing(const struct tile *ptile)
{
return ptile->placing != NULL;
}
common/tile.h
struct unit_list *units;
struct city *worked; /* NULL for not worked */
struct player *owner; /* NULL for not owned */
struct extra_type *placing;
struct player *extras_owner;
struct tile *claimer;
char *label; /* NULL for no label */
......
bool tile_set_label(struct tile *ptile, const char *label);
bool tile_is_placing(const struct tile *ptile);
#ifdef __cplusplus
}
#endif /* __cplusplus */
common/unit.c
/* FIXME: Should check also the cases where one of the activities is terrain
* change that destroys the target of the other activity */
if (target != NULL && is_build_activity(activity, ptile)) {
if (tile_is_placing(ptile)) {
return FALSE;
}
unit_list_iterate(ptile->units, tunit) {
if (is_build_activity(tunit->activity, ptile)
&& !can_extras_coexist(target, tunit->activity_target)) {
fc_version
# - No new mandatory capabilities can be added to the release branch; doing
# so would break network capability of supposedly "compatible" releases.
#
NETWORK_CAPSTRING="+Freeciv.Devel-3.1-2019.Jul.16"
NETWORK_CAPSTRING="+Freeciv.Devel-3.1-2019.Jul.16b"
FREECIV_DISTRIBUTOR=""
server/infrapts.c
pplayer->economic.infra_points -= pextra->infracost;
send_player_info_c(pplayer, pplayer->connections);
create_extra(ptile, pextra, pplayer);
ptile->placing = pextra;
update_tile_knowledge(ptile);
}
server/maphand.c
info.resource = (NULL != tile_resource(ptile))
? extra_number(tile_resource(ptile))
: MAX_EXTRA_TYPES;
info.placing = (NULL != ptile->placing)
? extra_number(ptile->placing)
: -1;
if (pplayer != NULL) {
info.extras = map_get_player_tile(ptile, pplayer)->extras;
......
info.resource = (NULL != plrtile->resource)
? extra_number(plrtile->resource)
: MAX_EXTRA_TYPES;
info.placing = -1;
info.extras = plrtile->extras;
......
info.terrain = terrain_count();
info.resource = MAX_EXTRA_TYPES;
info.placing = -1;
BV_CLR_ALL(info.extras);
server/savegame/savegame3.c
struct player *owner = NULL;
struct tile *claimer = NULL;
struct player *eowner = NULL;
struct extra_type *placing = NULL;
/* Check status and return if not OK (sg_success != TRUE). */
sg_check_ret();
......
"map.source%04d", y);
const char *buffer3 = secfile_lookup_str(loading->file,
"map.eowner%04d", y);
const char *buffer_placing = secfile_lookup_str_default(loading->file,
NULL,
"map.placing%04d", y);
const char *ptr1 = buffer1;
const char *ptr2 = buffer2;
const char *ptr3 = buffer3;
const char *ptr_placing = buffer_placing;
sg_failure_ret(buffer1 != NULL, "%s", secfile_error());
sg_failure_ret(buffer2 != NULL, "%s", secfile_error());
......
char token1[TOKEN_SIZE];
char token2[TOKEN_SIZE];
char token3[TOKEN_SIZE];
char token_placing[TOKEN_SIZE];
int number;
struct tile *ptile = native_pos_to_tile(&(wld.map), x, y);
......
eowner = player_by_number(number);
}
if (ptr_placing != NULL) {
scanin(&ptr_placing, ",", token_placing, sizeof(token_placing));
sg_failure_ret(token_placing[0] != '\0',
"Map size not correct (map.placing%d).", y);
if (strcmp(token_placing, "-") == 0) {
placing = NULL;
} else {
sg_failure_ret(str_to_int(token_placing, &number),
"Got placing extra %s in (%d, %d).", token_placing, x, y);
placing = extra_by_number(number);
}
} else {
placing = NULL;
}
map_claim_ownership(ptile, owner, claimer, FALSE);
tile_claim_bases(ptile, eowner);
ptile->placing = placing;
log_debug("extras_owner(%d, %d) = %s", TILE_XY(ptile), player_name(eowner));
}
}
......
}
secfile_insert_str(saving->file, line, "map.eowner%04d", y);
}
for (y = 0; y < wld.map.ysize; y++) {
char line[wld.map.xsize * TOKEN_SIZE];
line[0] = '\0';
for (x = 0; x < wld.map.xsize; x++) {
char token[TOKEN_SIZE];
struct tile *ptile = native_pos_to_tile(&(wld.map), x, y);
if (ptile->placing == NULL) {
strcpy(token, "-");
} else {
fc_snprintf(token, sizeof(token), "%d",
extra_number(ptile->placing));
}
strcat(line, token);
if (x + 1 < wld.map.xsize) {
strcat(line, ",");
}
}
secfile_insert_str(saving->file, line, "map.placing%04d", y);
}
}
/************************************************************************//**
server/srv_main.c
if (is_new_phase) {
/* Unit "end of turn" activities - of course these actually go at
* the start of the turn! */
whole_map_iterate(&(wld.map), ptile) {
if (ptile->placing != NULL) {
struct player *owner = NULL;
if (game.info.borders != BORDERS_DISABLED) {
owner = tile_owner(ptile);
} else {
struct city *pcity = tile_worked(ptile);
if (pcity != NULL) {
owner = city_owner(pcity);
}
}
if (owner == NULL) {
/* Abandoned extra placing, clear it. */
ptile->placing = NULL;
} else {
if (is_player_phase(owner, game.info.phase)) {
create_extra(ptile, ptile->placing, owner);
update_tile_knowledge(ptile);
ptile->placing = NULL;
}
}
}
} whole_map_iterate_end;
phase_players_iterate(pplayer) {
update_unit_activities(pplayer);
flush_packets();
    (1-1/1)