Feature #1650 ยป 0051-player.-ch-Replace-NULL-with-nullptr.patch
| common/player.c | ||
|---|---|---|
|
{
|
||
|
struct player_diplstate *diplstate;
|
||
|
fc_assert_ret(plr1 != NULL);
|
||
|
fc_assert_ret(plr2 != NULL);
|
||
|
fc_assert_ret(plr1 != nullptr);
|
||
|
fc_assert_ret(plr2 != nullptr);
|
||
|
const struct player_diplstate **diplstate_slot
|
||
|
= plr1->diplstates + player_index(plr2);
|
||
|
fc_assert_ret(*diplstate_slot == NULL);
|
||
|
fc_assert_ret(*diplstate_slot == nullptr);
|
||
|
diplstate = fc_calloc(1, sizeof(*diplstate));
|
||
|
*diplstate_slot = diplstate;
|
||
| ... | ... | |
|
{
|
||
|
struct player_diplstate *diplstate = player_diplstate_get(plr1, plr2);
|
||
|
fc_assert_ret(diplstate != NULL);
|
||
|
fc_assert_ret(diplstate != nullptr);
|
||
|
diplstate->type = DS_NO_CONTACT;
|
||
|
diplstate->max_state = DS_NO_CONTACT;
|
||
| ... | ... | |
|
struct player_diplstate *player_diplstate_get(const struct player *plr1,
|
||
|
const struct player *plr2)
|
||
|
{
|
||
|
fc_assert_ret_val(plr1 != NULL, NULL);
|
||
|
fc_assert_ret_val(plr2 != NULL, NULL);
|
||
|
fc_assert_ret_val(plr1 != nullptr, nullptr);
|
||
|
fc_assert_ret_val(plr2 != nullptr, nullptr);
|
||
|
const struct player_diplstate **diplstate_slot
|
||
|
= plr1->diplstates + player_index(plr2);
|
||
|
fc_assert_ret_val(*diplstate_slot != NULL, NULL);
|
||
|
fc_assert_ret_val(*diplstate_slot != nullptr, nullptr);
|
||
|
return (struct player_diplstate *) *diplstate_slot;
|
||
|
}
|
||
| ... | ... | |
|
static void player_diplstate_destroy(const struct player *plr1,
|
||
|
const struct player *plr2)
|
||
|
{
|
||
|
fc_assert_ret(plr1 != NULL);
|
||
|
fc_assert_ret(plr2 != NULL);
|
||
|
fc_assert_ret(plr1 != nullptr);
|
||
|
fc_assert_ret(plr2 != nullptr);
|
||
|
const struct player_diplstate **diplstate_slot
|
||
|
= plr1->diplstates + player_index(plr2);
|
||
|
if (*diplstate_slot != NULL) {
|
||
|
if (*diplstate_slot != nullptr) {
|
||
|
free(player_diplstate_get(plr1, plr2));
|
||
|
}
|
||
|
*diplstate_slot = NULL;
|
||
|
*diplstate_slot = nullptr;
|
||
|
}
|
||
|
/*******************************************************************//**
|
||
| ... | ... | |
|
/* Can't use the defined functions as the needed data will be
|
||
|
* defined here. */
|
||
|
for (i = 0; i < player_slot_count(); i++) {
|
||
|
player_slots.slots[i].player = NULL;
|
||
|
player_slots.slots[i].player = nullptr;
|
||
|
}
|
||
|
player_slots.used_slots = 0;
|
||
|
}
|
||
| ... | ... | |
|
***********************************************************************/
|
||
|
bool player_slots_initialised(void)
|
||
|
{
|
||
|
return (player_slots.slots != NULL);
|
||
|
return (player_slots.slots != nullptr);
|
||
|
}
|
||
|
/*******************************************************************//**
|
||
| ... | ... | |
|
player_destroy(pplayer);
|
||
|
} players_iterate_end;
|
||
|
free(player_slots.slots);
|
||
|
player_slots.slots = NULL;
|
||
|
player_slots.slots = nullptr;
|
||
|
player_slots.used_slots = 0;
|
||
|
}
|
||
| ... | ... | |
|
struct player_slot *player_slot_next(struct player_slot *pslot)
|
||
|
{
|
||
|
pslot++;
|
||
|
return (pslot < player_slots.slots + player_slot_count() ? pslot : NULL);
|
||
|
return (pslot < player_slots.slots + player_slot_count()
|
||
|
? pslot : nullptr);
|
||
|
}
|
||
|
/*******************************************************************//**
|
||
| ... | ... | |
|
***********************************************************************/
|
||
|
int player_slot_index(const struct player_slot *pslot)
|
||
|
{
|
||
|
fc_assert_ret_val(NULL != pslot, -1);
|
||
|
fc_assert_ret_val(pslot != nullptr, -1);
|
||
|
return pslot - player_slots.slots;
|
||
|
}
|
||
|
/*******************************************************************//**
|
||
|
Returns the team corresponding to the slot. If the slot is not used, it
|
||
|
will return NULL. See also player_slot_is_used().
|
||
|
will return nullptr. See also player_slot_is_used().
|
||
|
***********************************************************************/
|
||
|
struct player *player_slot_get_player(const struct player_slot *pslot)
|
||
|
{
|
||
|
fc_assert_ret_val(NULL != pslot, NULL);
|
||
|
fc_assert_ret_val(pslot != nullptr, nullptr);
|
||
|
return pslot->player;
|
||
|
}
|
||
| ... | ... | |
|
***********************************************************************/
|
||
|
bool player_slot_is_used(const struct player_slot *pslot)
|
||
|
{
|
||
|
fc_assert_ret_val(NULL != pslot, FALSE);
|
||
|
fc_assert_ret_val(pslot != nullptr, FALSE);
|
||
|
/* No player slot available, if the game is not initialised. */
|
||
|
if (!player_slots_initialised()) {
|
||
|
return FALSE;
|
||
|
}
|
||
|
return NULL != pslot->player;
|
||
|
return pslot->player != nullptr;
|
||
|
}
|
||
|
/*******************************************************************//**
|
||
| ... | ... | |
|
{
|
||
|
if (!player_slots_initialised()
|
||
|
|| !(0 <= player_id && player_id < player_slot_count())) {
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
return player_slots.slots + player_id;
|
||
| ... | ... | |
|
}
|
||
|
/*******************************************************************//**
|
||
|
Creates a new player for the slot. If slot is NULL, it will lookup to a
|
||
|
Creates a new player for the slot. If slot is nullptr, it will lookup to a
|
||
|
free slot. If the slot is already used, then just return the player.
|
||
|
***********************************************************************/
|
||
|
struct player *player_new(struct player_slot *pslot)
|
||
|
{
|
||
|
struct player *pplayer;
|
||
|
fc_assert_ret_val(player_slots_initialised(), NULL);
|
||
|
fc_assert_ret_val(player_slots_initialised(), nullptr);
|
||
|
if (pslot == NULL) {
|
||
|
if (pslot == nullptr) {
|
||
|
player_slots_iterate(aslot) {
|
||
|
if (!player_slot_is_used(aslot)) {
|
||
|
pslot = aslot;
|
||
| ... | ... | |
|
}
|
||
|
} player_slots_iterate_end;
|
||
|
if (pslot == NULL) {
|
||
|
return NULL;
|
||
|
if (pslot == nullptr) {
|
||
|
return nullptr;
|
||
|
}
|
||
|
} else if (NULL != pslot->player) {
|
||
|
} else if (pslot->player != nullptr) {
|
||
|
return pslot->player;
|
||
|
}
|
||
| ... | ... | |
|
const struct player_diplstate **diplstate_slot
|
||
|
= pplayer->diplstates + player_slot_index(dslot);
|
||
|
*diplstate_slot = NULL;
|
||
|
*diplstate_slot = nullptr;
|
||
|
} player_slots_iterate_end;
|
||
|
players_iterate(aplayer) {
|
||
| ... | ... | |
|
pplayer->unassigned_ranked = TRUE;
|
||
|
pplayer->user_turns = 0;
|
||
|
pplayer->is_male = TRUE;
|
||
|
pplayer->government = NULL;
|
||
|
pplayer->target_government = NULL;
|
||
|
pplayer->government = nullptr;
|
||
|
pplayer->target_government = nullptr;
|
||
|
pplayer->nation = NO_NATION_SELECTED;
|
||
|
pplayer->team = NULL;
|
||
|
pplayer->team = nullptr;
|
||
|
pplayer->is_ready = FALSE;
|
||
|
pplayer->nturns_idle = 0;
|
||
|
pplayer->is_alive = TRUE;
|
||
| ... | ... | |
|
player_slots_iterate(pslot) {
|
||
|
pplayer->ai_common.love[player_slot_index(pslot)] = 1;
|
||
|
} player_slots_iterate_end;
|
||
|
pplayer->ai_common.traits = NULL;
|
||
|
pplayer->ai_common.traits = nullptr;
|
||
|
pplayer->ai = NULL;
|
||
|
pplayer->ai = nullptr;
|
||
|
pplayer->was_created = FALSE;
|
||
|
pplayer->savegame_ai_type_name = NULL;
|
||
|
pplayer->savegame_ai_type_name = nullptr;
|
||
|
pplayer->random_name = TRUE;
|
||
|
pplayer->is_connected = FALSE;
|
||
|
pplayer->current_conn = NULL;
|
||
|
pplayer->current_conn = nullptr;
|
||
|
pplayer->connections = conn_list_new();
|
||
|
pplayer->autoselect_weight = -1;
|
||
|
BV_CLR_ALL(pplayer->gives_shared_vision);
|
||
| ... | ... | |
|
pplayer->wonders[i] = WONDER_NOT_BUILT;
|
||
|
}
|
||
|
pplayer->attribute_block.data = NULL;
|
||
|
pplayer->attribute_block.data = nullptr;
|
||
|
pplayer->attribute_block.length = 0;
|
||
|
pplayer->attribute_block_buffer.data = NULL;
|
||
|
pplayer->attribute_block_buffer.data = nullptr;
|
||
|
pplayer->attribute_block_buffer.length = 0;
|
||
|
pplayer->tile_known.vec = NULL;
|
||
|
pplayer->tile_known.vec = nullptr;
|
||
|
pplayer->tile_known.bits = 0;
|
||
|
pplayer->rgb = NULL;
|
||
|
pplayer->rgb = nullptr;
|
||
|
memset(pplayer->multipliers, 0, sizeof(pplayer->multipliers));
|
||
| ... | ... | |
|
/*******************************************************************//**
|
||
|
Set the player's color.
|
||
|
May be NULL in pregame.
|
||
|
May be nullptr in pregame.
|
||
|
***********************************************************************/
|
||
|
void player_set_color(struct player *pplayer,
|
||
|
const struct rgbcolor *prgbcolor)
|
||
|
{
|
||
|
if (pplayer->rgb != NULL) {
|
||
|
if (pplayer->rgb != nullptr) {
|
||
|
rgbcolor_destroy(pplayer->rgb);
|
||
|
pplayer->rgb = NULL;
|
||
|
pplayer->rgb = nullptr;
|
||
|
}
|
||
|
if (prgbcolor) {
|
||
| ... | ... | |
|
{
|
||
|
bool client = !is_server();
|
||
|
if (pplayer == NULL) {
|
||
|
if (pplayer == nullptr) {
|
||
|
return;
|
||
|
}
|
||
|
if (pplayer->savegame_ai_type_name != NULL) {
|
||
|
if (pplayer->savegame_ai_type_name != nullptr) {
|
||
|
free(pplayer->savegame_ai_type_name);
|
||
|
pplayer->savegame_ai_type_name = NULL;
|
||
|
pplayer->savegame_ai_type_name = nullptr;
|
||
|
}
|
||
|
/* Clears the attribute blocks. */
|
||
|
if (pplayer->attribute_block.data) {
|
||
|
free(pplayer->attribute_block.data);
|
||
|
pplayer->attribute_block.data = NULL;
|
||
|
pplayer->attribute_block.data = nullptr;
|
||
|
}
|
||
|
pplayer->attribute_block.length = 0;
|
||
|
if (pplayer->attribute_block_buffer.data) {
|
||
|
free(pplayer->attribute_block_buffer.data);
|
||
|
pplayer->attribute_block_buffer.data = NULL;
|
||
|
pplayer->attribute_block_buffer.data = nullptr;
|
||
|
}
|
||
|
pplayer->attribute_block_buffer.length = 0;
|
||
| ... | ... | |
|
} unit_list_iterate_end;
|
||
|
city_list_iterate(pplayer->cities, pcity) {
|
||
|
if (fc_funcs->destroy_city != NULL) {
|
||
|
if (fc_funcs->destroy_city != nullptr) {
|
||
|
fc_funcs->destroy_city(pcity);
|
||
|
} else {
|
||
|
game_remove_city(&wld, pcity);
|
||
| ... | ... | |
|
/* This comes last because log calls in the above functions
|
||
|
* may use it. */
|
||
|
if (pplayer->nation != NULL) {
|
||
|
player_set_nation(pplayer, NULL);
|
||
|
if (pplayer->nation != nullptr) {
|
||
|
player_set_nation(pplayer, nullptr);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
***********************************************************************/
|
||
|
void player_ruleset_close(struct player *pplayer)
|
||
|
{
|
||
|
pplayer->government = NULL;
|
||
|
pplayer->target_government = NULL;
|
||
|
player_set_nation(pplayer, NULL);
|
||
|
pplayer->style = NULL;
|
||
|
pplayer->government = nullptr;
|
||
|
pplayer->target_government = nullptr;
|
||
|
player_set_nation(pplayer, nullptr);
|
||
|
pplayer->style = nullptr;
|
||
|
}
|
||
|
/*******************************************************************//**
|
||
| ... | ... | |
|
{
|
||
|
struct player_slot *pslot;
|
||
|
fc_assert_ret(NULL != pplayer);
|
||
|
fc_assert_ret(pplayer != nullptr);
|
||
|
pslot = pplayer->slot;
|
||
|
fc_assert(pslot->player == pplayer);
|
||
| ... | ... | |
|
if (pcity->original == pplayer) {
|
||
|
/* Unknown origin is better than giving baseless
|
||
|
* benefits to current owner */
|
||
|
pcity->original = NULL;
|
||
|
pcity->original = nullptr;
|
||
|
}
|
||
|
} city_list_iterate_end;
|
||
|
}
|
||
| ... | ... | |
|
}
|
||
|
free(pplayer);
|
||
|
pslot->player = NULL;
|
||
|
pslot->player = nullptr;
|
||
|
player_slots.used_slots--;
|
||
|
}
|
||
| ... | ... | |
|
***********************************************************************/
|
||
|
int player_number(const struct player *pplayer)
|
||
|
{
|
||
|
fc_assert_ret_val(NULL != pplayer, -1);
|
||
|
fc_assert_ret_val(pplayer != nullptr, -1);
|
||
|
return player_slot_index(pplayer->slot);
|
||
|
}
|
||
| ... | ... | |
|
Return struct player pointer for the given player index.
|
||
|
You can retrieve players that are not in the game (with IDs larger than
|
||
|
player_count). An out-of-range player request will return NULL.
|
||
|
player_count). An out-of-range player request will return nullptr.
|
||
|
***********************************************************************/
|
||
|
struct player *player_by_number(const int player_id)
|
||
|
{
|
||
|
struct player_slot *pslot = player_slot_by_number(player_id);
|
||
|
return (NULL != pslot ? player_slot_get_player(pslot) : NULL);
|
||
|
return (pslot != nullptr ? player_slot_get_player(pslot) : nullptr);
|
||
|
}
|
||
|
/*******************************************************************//**
|
||
|
Set the player's nation to the given nation (may be NULL). Returns TRUE
|
||
|
iff there was a change.
|
||
|
Set the player's nation to the given nation (may be nullptr).
|
||
|
Returns TRUE iff there was a change.
|
||
|
Doesn't check if the nation is legal wrt nationset.
|
||
|
***********************************************************************/
|
||
|
bool player_set_nation(struct player *pplayer, struct nation_type *pnation)
|
||
| ... | ... | |
|
if (pplayer->nation != pnation) {
|
||
|
if (pplayer->nation) {
|
||
|
fc_assert(pplayer->nation->player == pplayer);
|
||
|
pplayer->nation->player = NULL;
|
||
|
pplayer->nation->player = nullptr;
|
||
|
}
|
||
|
if (pnation) {
|
||
|
fc_assert(pnation->player == NULL);
|
||
|
fc_assert(pnation->player == nullptr);
|
||
|
pnation->player = pplayer;
|
||
|
}
|
||
|
pplayer->nation = pnation;
|
||
|
return TRUE;
|
||
|
}
|
||
|
return FALSE;
|
||
|
}
|
||
| ... | ... | |
|
}
|
||
|
} players_iterate_end;
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
/*******************************************************************//**
|
||
| ... | ... | |
|
const char *player_name(const struct player *pplayer)
|
||
|
{
|
||
|
if (!pplayer) {
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
return pplayer->name;
|
||
|
}
|
||
|
/*******************************************************************//**
|
||
|
Find player by name, allowing unambiguous prefix (i.e. abbreviation).
|
||
|
Returns NULL if could not match, or if ambiguous or other
|
||
|
Returns nullptr if could not match, or if ambiguous or other
|
||
|
problem, and fills *result with characterisation of match/non-match
|
||
|
(see shared.[ch])
|
||
|
***********************************************************************/
|
||
| ... | ... | |
|
struct player *pplayer;
|
||
|
pplayer = player_by_number(i);
|
||
|
return player_name(pplayer);
|
||
|
}
|
||
| ... | ... | |
|
if (*result < M_PRE_AMBIGUOUS) {
|
||
|
return player_by_number(ind);
|
||
|
} else {
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
}
|
||
|
} players_iterate_end;
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
/*******************************************************************//**
|
||
| ... | ... | |
|
***********************************************************************/
|
||
|
int player_age(const struct player *pplayer)
|
||
|
{
|
||
|
fc_assert_ret_val(pplayer != NULL, 0);
|
||
|
fc_assert_ret_val(pplayer != nullptr, 0);
|
||
|
return pplayer->turns_alive;
|
||
|
}
|
||
| ... | ... | |
|
See can_player_see_unit_at().
|
||
|
***********************************************************************/
|
||
|
bool can_player_see_unit(const struct player *pplayer,
|
||
|
const struct unit *punit)
|
||
|
const struct unit *punit)
|
||
|
{
|
||
|
return can_player_see_unit_at(pplayer, punit, unit_tile(punit),
|
||
|
unit_transported(punit));
|
||
| ... | ... | |
|
Otherwise the player would not know anything about the city's units at
|
||
|
all, since the full city packet has no "occupied" flag.
|
||
|
Returns TRUE if given a NULL player. This is used by the client when in
|
||
|
Returns TRUE if given a nullptr player. This is used by the client when in
|
||
|
observer mode.
|
||
|
***********************************************************************/
|
||
|
bool can_player_see_units_in_city(const struct player *pplayer,
|
||
|
const struct city *pcity)
|
||
|
const struct city *pcity)
|
||
|
{
|
||
|
return (!pplayer
|
||
|
|| can_player_see_city_internals(pplayer, pcity)
|
||
|
|| pplayers_allied(pplayer, city_owner(pcity)));
|
||
|
|| can_player_see_city_internals(pplayer, pcity)
|
||
|
|| pplayers_allied(pplayer, city_owner(pcity)));
|
||
|
}
|
||
|
/*******************************************************************//**
|
||
| ... | ... | |
|
full city packet is sent to the client, who should then be able to popup
|
||
|
a dialog for it.
|
||
|
Returns TRUE if given a NULL player. This is used by the client when in
|
||
|
Returns TRUE if given a nullptr player. This is used by the client when in
|
||
|
observer mode.
|
||
|
***********************************************************************/
|
||
|
bool can_player_see_city_internals(const struct player *pplayer,
|
||
|
const struct city *pcity)
|
||
|
const struct city *pcity)
|
||
|
{
|
||
|
return (!pplayer || pplayer == city_owner(pcity));
|
||
|
}
|
||
| ... | ... | |
|
/*******************************************************************//**
|
||
|
If the specified player owns the city with the specified id,
|
||
|
return pointer to the city struct. Else return NULL.
|
||
|
return pointer to the city struct. Else return nullptr.
|
||
|
Now always uses fast idex_lookup_city.
|
||
|
pplayer may be NULL in which case all cities registered to
|
||
|
pplayer may be nullptr in which case all cities registered to
|
||
|
hash are considered - even those not currently owned by any
|
||
|
player. Callers expect this behavior.
|
||
|
***********************************************************************/
|
||
| ... | ... | |
|
struct city *pcity = idex_lookup_city(&wld, city_id);
|
||
|
if (!pcity) {
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
if (!pplayer || (city_owner(pcity) == pplayer)) {
|
||
| ... | ... | |
|
return pcity;
|
||
|
}
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
/*******************************************************************//**
|
||
|
If the specified player owns the unit with the specified id,
|
||
|
return pointer to the unit struct. Else return NULL.
|
||
|
Uses fast idex_lookup_city.
|
||
|
return pointer to the unit struct. Else return nullptr.
|
||
|
Uses fast idex_lookup_city().
|
||
|
pplayer may be NULL in which case all units registered to
|
||
|
pplayer may be nullptr in which case all units registered to
|
||
|
hash are considered - even those not currently owned by any
|
||
|
player. Callers expect this behavior.
|
||
|
***********************************************************************/
|
||
| ... | ... | |
|
struct unit *punit = idex_lookup_unit(&wld, unit_id);
|
||
|
if (!punit) {
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
if (!pplayer || (unit_owner(punit) == pplayer)) {
|
||
| ... | ... | |
|
return punit;
|
||
|
}
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
/*******************************************************************//**
|
||
| ... | ... | |
|
struct city *pcity = tile_city(ptile1);
|
||
|
if (pcity
|
||
|
&& (pplayer == NULL || city_owner(pcity) == pplayer)
|
||
|
&& (pplayer == nullptr || city_owner(pcity) == pplayer)
|
||
|
&& city_map_radius_sq_get(pcity) >= sq_map_distance(ptile,
|
||
|
ptile1)) {
|
||
|
return TRUE;
|
||
| ... | ... | |
|
given flag.
|
||
|
***********************************************************************/
|
||
|
bool player_knows_techs_with_flag(const struct player *pplayer,
|
||
|
enum tech_flag_id flag)
|
||
|
enum tech_flag_id flag)
|
||
|
{
|
||
|
return num_known_tech_with_flag(pplayer, flag) > 0;
|
||
|
}
|
||
|
/*******************************************************************//**
|
||
|
Locate the player's primary capital city, (NULL Otherwise)
|
||
|
Locate the player's primary capital city, (nullptr Otherwise)
|
||
|
***********************************************************************/
|
||
|
struct city *player_primary_capital(const struct player *pplayer)
|
||
|
{
|
||
| ... | ... | |
|
if (!pplayer) {
|
||
|
/* The client depends on this behavior in some places. */
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
capital = player_city_by_number(pplayer, pplayer->primary_capital_id);
|
||
| ... | ... | |
|
const struct player *player2,
|
||
|
int diplrel)
|
||
|
{
|
||
|
fc_assert(player1 != NULL);
|
||
|
fc_assert(player2 != NULL);
|
||
|
fc_assert(player1 != nullptr);
|
||
|
fc_assert(player2 != nullptr);
|
||
|
/* No relationship to it self. */
|
||
|
if (player1 == player2 && diplrel != DRO_FOREIGN) {
|
||
| ... | ... | |
|
***********************************************************************/
|
||
|
bool is_diplrel_to_other(const struct player *pplayer, int diplrel)
|
||
|
{
|
||
|
fc_assert(pplayer != NULL);
|
||
|
fc_assert(pplayer != nullptr);
|
||
|
players_iterate_alive(oplayer) {
|
||
|
if (oplayer == pplayer) {
|
||
| ... | ... | |
|
/* The victim gets a casus belli if CASUS_BELLI_VICTIM or above. Everyone
|
||
|
* gets a casus belli if CASUS_BELLI_OUTRAGE or above. */
|
||
|
casus_belli_amount =
|
||
|
get_target_bonus_effects(NULL,
|
||
|
get_target_bonus_effects(nullptr,
|
||
|
&(const struct req_context) {
|
||
|
.player = offender,
|
||
|
.city = tile_city(tgt_tile),
|
||
| ... | ... | |
|
/* An array of mutually exclusive requirement sets for the DiplRel
|
||
|
* requirement type. Is initialized the first time diplrel_mess_get() is
|
||
|
* called. */
|
||
|
static bv_diplrel_all_reqs *diplrel_mess = NULL;
|
||
|
static bv_diplrel_all_reqs *diplrel_mess = nullptr;
|
||
|
/*******************************************************************//**
|
||
|
Get the mutually exclusive requirement sets for DiplRel.
|
||
|
***********************************************************************/
|
||
|
static bv_diplrel_all_reqs *diplrel_mess_get(void)
|
||
|
{
|
||
|
if (diplrel_mess == NULL) {
|
||
|
if (diplrel_mess == nullptr) {
|
||
|
/* This is the first call. Initialize diplrel_mess. */
|
||
|
diplrel_mess = diplrel_mess_gen();
|
||
|
}
|
||
| ... | ... | |
|
***********************************************************************/
|
||
|
void diplrel_mess_close(void)
|
||
|
{
|
||
|
if (diplrel_mess != NULL) {
|
||
|
if (diplrel_mess != nullptr) {
|
||
|
free(diplrel_mess);
|
||
|
diplrel_mess = NULL;
|
||
|
diplrel_mess = nullptr;
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
will not be found (this function doesn't cheat).
|
||
|
***********************************************************************/
|
||
|
int player_in_territory(const struct player *pplayer,
|
||
|
const struct player *pplayer2)
|
||
|
const struct player *pplayer2)
|
||
|
{
|
||
|
int in_territory = 0;
|
||
| ... | ... | |
|
case PLRS_BARBARIAN:
|
||
|
return is_barbarian(pplayer);
|
||
|
case PLRS_HAS_CAPITAL:
|
||
|
return player_primary_capital(pplayer) != NULL;
|
||
|
return player_primary_capital(pplayer) != nullptr;
|
||
|
case PLRS_LAST:
|
||
|
fc_assert(state != PLRS_LAST);
|
||
|
break;
|
||
| common/player.h | ||
|---|---|---|
|
int techout;
|
||
|
int landarea;
|
||
|
int settledarea;
|
||
|
int population; /* in thousand of citizen */
|
||
|
int population; /* In thousand of citizen */
|
||
|
int cities;
|
||
|
int units;
|
||
|
int pollution;
|
||
| ... | ... | |
|
struct player_ai {
|
||
|
int maxbuycost;
|
||
|
void *handicaps;
|
||
|
enum ai_level skill_level; /* 0-10 value for save/load/display */
|
||
|
int fuzzy; /* chance in 1000 to mis-decide */
|
||
|
int expand; /* percentage factor to value new cities */
|
||
|
enum ai_level skill_level; /* 0-10 value for save/load/display */
|
||
|
int fuzzy; /* Chance in 1000 to mis-decide */
|
||
|
int expand; /* Percentage factor to value new cities */
|
||
|
int science_cost; /* Cost in bulbs to get new tech, relative
|
||
|
to non-AI players (100: Equal cost) */
|
||
|
int warmth, frost; /* threat of global warming / nuclear winter */
|
||
|
int warmth, frost; /* Threat of global warming / nuclear winter */
|
||
|
enum barbarian_type barbarian_type;
|
||
|
int love[MAX_NUM_PLAYER_SLOTS];
|
||
| ... | ... | |
|
#define SPECENUM_VALUE6NAME N_("?diplomatic_state:Team")
|
||
|
/* When adding or removing entries, note that first value
|
||
|
* of diplrel_other should be next to last diplstate_type */
|
||
|
#define SPECENUM_COUNT DS_LAST /* leave this last */
|
||
|
#define SPECENUM_COUNT DS_LAST /* Leave this last */
|
||
|
#include "specenum_gen.h"
|
||
|
/* Other diplomatic relation properties.
|
||
| ... | ... | |
|
struct attribute_block_s {
|
||
|
void *data;
|
||
|
int length;
|
||
|
#define MAX_ATTRIBUTE_BLOCK (256*1024) /* largest attribute block */
|
||
|
#define MAX_ATTRIBUTE_BLOCK (256*1024) /* Largest attribute block */
|
||
|
};
|
||
|
struct ai_type;
|
||
| ... | ... | |
|
char name[MAX_LEN_NAME];
|
||
|
char username[MAX_LEN_NAME];
|
||
|
bool unassigned_user;
|
||
|
char ranked_username[MAX_LEN_NAME]; /* the user who will be ranked */
|
||
|
char ranked_username[MAX_LEN_NAME]; /* The user who will be ranked */
|
||
|
bool unassigned_ranked;
|
||
|
int user_turns; /* number of turns this user has played */
|
||
|
int user_turns; /* Number of turns this user has played */
|
||
|
bool is_male;
|
||
|
struct government *government; /* may be NULL in pregame */
|
||
|
struct government *target_government; /* may be NULL */
|
||
|
struct government *government; /* May be nullptr in pregame */
|
||
|
struct government *target_government; /* May be nullptr */
|
||
|
struct nation_type *nation;
|
||
|
struct team *team;
|
||
|
bool is_ready; /* Did the player click "start" yet? */
|
||
| ... | ... | |
|
bool can_player_see_hypotetic_units_at(const struct player *pplayer,
|
||
|
const struct tile *ptile);
|
||
|
bool can_player_see_unit(const struct player *pplayer,
|
||
|
const struct unit *punit);
|
||
|
const struct unit *punit);
|
||
|
bool can_player_see_unit_at(const struct player *pplayer,
|
||
|
const struct unit *punit,
|
||
|
const struct unit *punit,
|
||
|
const struct tile *ptile,
|
||
|
bool is_transported);
|
||
|
bool can_player_see_tile(const struct player *plr,
|
||
|
const struct tile *ptile);
|
||
|
bool can_player_see_units_in_city(const struct player *pplayer,
|
||
|
const struct city *pcity);
|
||
|
const struct city *pcity);
|
||
|
bool can_player_see_city_internals(const struct player *pplayer,
|
||
|
const struct city *pcity);
|
||
|
const struct city *pcity);
|
||
|
bool player_can_see_city_externals(const struct player *pow_player,
|
||
|
const struct city *target_city);
|
||
|
bool player_owns_city(const struct player *pplayer,
|
||
|
const struct city *pcity);
|
||
|
const struct city *pcity);
|
||
|
bool player_can_invade_tile(const struct player *pplayer,
|
||
|
const struct tile *ptile);
|
||
| ... | ... | |
|
bool player_in_city_map(const struct player *pplayer,
|
||
|
const struct tile *ptile);
|
||
|
bool player_knows_techs_with_flag(const struct player *pplayer,
|
||
|
enum tech_flag_id flag);
|
||
|
enum tech_flag_id flag);
|
||
|
int num_known_tech_with_flag(const struct player *pplayer,
|
||
|
enum tech_flag_id flag);
|
||
|
enum tech_flag_id flag);
|
||
|
int player_get_expected_income(const struct player *pplayer);
|
||
|
struct city *player_primary_capital(const struct player *pplayer);
|
||
| ... | ... | |
|
struct player_diplstate *player_diplstate_get(const struct player *plr1,
|
||
|
const struct player *plr2);
|
||
|
bool are_diplstates_equal(const struct player_diplstate *pds1,
|
||
|
const struct player_diplstate *pds2);
|
||
|
const struct player_diplstate *pds2);
|
||
|
enum dipl_reason pplayer_can_make_treaty(const struct player *p1,
|
||
|
const struct player *p2,
|
||
|
enum diplstate_type treaty);
|
||
|
enum dipl_reason pplayer_can_cancel_treaty(const struct player *p1,
|
||
|
const struct player *p2);
|
||
|
bool pplayers_at_war(const struct player *pplayer,
|
||
|
const struct player *pplayer2);
|
||
|
const struct player *pplayer2);
|
||
|
bool pplayers_allied(const struct player *pplayer,
|
||
|
const struct player *pplayer2);
|
||
|
const struct player *pplayer2);
|
||
|
bool pplayers_in_peace(const struct player *pplayer,
|
||
|
const struct player *pplayer2);
|
||
|
bool players_non_invade(const struct player *pplayer1,
|
||
|
const struct player *pplayer2);
|
||
|
const struct player *pplayer2);
|
||
|
bool pplayers_non_attack(const struct player *pplayer,
|
||
|
const struct player *pplayer2);
|
||
|
const struct player *pplayer2);
|
||
|
bool players_on_same_team(const struct player *pplayer1,
|
||
|
const struct player *pplayer2);
|
||
|
int player_in_territory(const struct player *pplayer,
|
||
|
const struct player *pplayer2);
|
||
|
const struct player *pplayer2);
|
||
|
/**************************************************************************
|
||
|
Return TRUE iff player is any kind of barbarian
|
||
| ... | ... | |
|
#define player_slots_iterate(_pslot) \
|
||
|
if (player_slots_initialised()) { \
|
||
|
struct player_slot *_pslot = player_slot_first(); \
|
||
|
for (; NULL != _pslot; _pslot = player_slot_next(_pslot)) {
|
||
|
for (; _pslot != nullptr; _pslot = player_slot_next(_pslot)) {
|
||
|
#define player_slots_iterate_end \
|
||
|
} \
|
||
|
}
|
||
|
/* iterate over all players, which are used at the moment */
|
||
|
/* Iterate over all players, which are used at the moment */
|
||
|
#define players_iterate(_pplayer) \
|
||
|
player_slots_iterate(_pslot##_pplayer) { \
|
||
|
struct player *_pplayer = player_slot_get_player(_pslot##_pplayer); \
|
||
|
if (_pplayer != NULL) {
|
||
|
if (_pplayer != nullptr) {
|
||
|
#define players_iterate_end \
|
||
|
} \
|
||
|
} player_slots_iterate_end;
|
||
|
/* iterate over all players, which are used at the moment and are alive */
|
||
|
/* Iterate over all players, which are used at the moment and are alive */
|
||
|
#define players_iterate_alive(_pplayer) \
|
||
|
players_iterate(_pplayer) { \
|
||
|
if (!_pplayer->is_alive) { \
|
||
| ... | ... | |
|
#define players_iterate_alive_end \
|
||
|
} players_iterate_end;
|
||
|
/* get 'struct player_list' and related functions: */
|
||
|
/* Get 'struct player_list' and related functions: */
|
||
|
#define SPECLIST_TAG player
|
||
|
#define SPECLIST_TYPE struct player
|
||
|
#include "speclist.h"
|
||
| ... | ... | |
|
#define player_list_iterate_end \
|
||
|
LIST_ITERATE_END
|
||
|
/* ai love values should be in range [-MAX_AI_LOVE..MAX_AI_LOVE] */
|
||
|
/* AI love values should be in range [-MAX_AI_LOVE..MAX_AI_LOVE] */
|
||
|
#define MAX_AI_LOVE 1000
|
||