Feature #1736 ยป 0046-improvement.c-Replace-parameter-checking-fc_asserts-.patch
| common/improvement.c | ||
|---|---|---|
|
**************************************************************************/
|
||
|
Impr_type_id improvement_index(const struct impr_type *pimprove)
|
||
|
{
|
||
|
fc_assert_ret_val(pimprove != nullptr, -1);
|
||
|
return pimprove - improvement_types;
|
||
|
}
|
||
| ... | ... | |
|
**************************************************************************/
|
||
|
Impr_type_id improvement_number(const struct impr_type *pimprove)
|
||
|
{
|
||
|
fc_assert_ret_val(pimprove != nullptr, -1);
|
||
|
return pimprove->item_number;
|
||
|
}
|
||
| ... | ... | |
|
if (!victory_enabled(VC_SPACERACE)
|
||
|
&& (building_has_effect(pimprove, EFT_SS_STRUCTURAL)
|
||
|
|| building_has_effect(pimprove, EFT_SS_COMPONENT)
|
||
|
|| building_has_effect(pimprove, EFT_SS_MODULE))) {
|
||
|
|| building_has_effect(pimprove, EFT_SS_COMPONENT)
|
||
|
|| building_has_effect(pimprove, EFT_SS_MODULE))) {
|
||
|
/* This assumes that space parts don't have any other effects. */
|
||
|
return nullptr;
|
||
|
}
|
||
| ... | ... | |
|
Return TRUE if the impr has this flag, otherwise FALSE
|
||
|
**************************************************************************/
|
||
|
bool improvement_has_flag(const struct impr_type *pimprove,
|
||
|
enum impr_flag_id flag)
|
||
|
enum impr_flag_id flag)
|
||
|
{
|
||
|
fc_assert_ret_val(impr_flag_id_is_valid(flag), FALSE);
|
||
| ... | ... | |
|
Returns TRUE if the improvement or wonder is obsolete
|
||
|
**************************************************************************/
|
||
|
bool improvement_obsolete(const struct player *pplayer,
|
||
|
const struct impr_type *pimprove,
|
||
|
const struct impr_type *pimprove,
|
||
|
const struct city *pcity)
|
||
|
{
|
||
|
const struct req_context context = {
|
||
| ... | ... | |
|
Returns FALSE if building is obsolete.
|
||
|
**************************************************************************/
|
||
|
bool can_player_build_improvement_now(const struct player *p,
|
||
|
struct impr_type *pimprove)
|
||
|
struct impr_type *pimprove)
|
||
|
{
|
||
|
if (!can_player_build_improvement_direct(p, pimprove)) {
|
||
|
return FALSE;
|
||
| ... | ... | |
|
struct player *pplayer;
|
||
|
int windex = improvement_number(pimprove);
|
||
|
fc_assert_ret(pcity != nullptr);
|
||
|
fc_assert_ret(is_wonder(pimprove));
|
||
|
pplayer = city_owner(pcity);
|
||
| ... | ... | |
|
struct player *pplayer;
|
||
|
int windex = improvement_number(pimprove);
|
||
|
fc_assert_ret(pcity != nullptr);
|
||
|
fc_assert_ret(is_wonder(pimprove));
|
||
|
pplayer = city_owner(pcity);
|
||
| ... | ... | |
|
bool wonder_is_lost(const struct player *pplayer,
|
||
|
const struct impr_type *pimprove)
|
||
|
{
|
||
|
fc_assert_ret_val(pplayer != nullptr, FALSE);
|
||
|
fc_assert_ret_val(is_wonder(pimprove), FALSE);
|
||
|
return pplayer->wonders[improvement_index(pimprove)] == WONDER_LOST;
|
||
| ... | ... | |
|
bool wonder_is_built(const struct player *pplayer,
|
||
|
const struct impr_type *pimprove)
|
||
|
{
|
||
|
fc_assert_ret_val(pplayer != nullptr, FALSE);
|
||
|
fc_assert_ret_val(is_wonder(pimprove), FALSE);
|
||
|
return WONDER_BUILT(pplayer->wonders[improvement_index(pimprove)]);
|
||
| ... | ... | |
|
city_id = pplayer->wonders[idx];
|
||
|
fc_assert_ret_val(pplayer != nullptr, nullptr);
|
||
|
fc_assert_ret_val(is_wonder(pimprove), nullptr);
|
||
|
if (!WONDER_BUILT(city_id)) {
|
||
| common/improvement.h | ||
|---|---|---|
|
/* General improvement accessor functions. */
|
||
|
Impr_type_id improvement_count(void);
|
||
|
Impr_type_id improvement_index(const struct impr_type *pimprove);
|
||
|
Impr_type_id improvement_number(const struct impr_type *pimprove);
|
||
|
Impr_type_id improvement_index(const struct impr_type *pimprove)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
Impr_type_id improvement_number(const struct impr_type *pimprove)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
struct impr_type *improvement_by_number(const Impr_type_id id);
|
||
| ... | ... | |
|
#define WONDER_NOT_BUILT 0 /* Used as city id. */
|
||
|
#define WONDER_BUILT(city_id) ((city_id) > 0)
|
||
|
void wonder_built(const struct city *pcity, const struct impr_type *pimprove);
|
||
|
void wonder_built(const struct city *pcity, const struct impr_type *pimprove)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
void wonder_destroyed(const struct city *pcity,
|
||
|
const struct impr_type *pimprove);
|
||
|
const struct impr_type *pimprove)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
bool wonder_is_lost(const struct player *pplayer,
|
||
|
const struct impr_type *pimprove);
|
||
|
const struct impr_type *pimprove)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
bool wonder_is_built(const struct player *pplayer,
|
||
|
const struct impr_type *pimprove);
|
||
|
const struct impr_type *pimprove)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
struct city *city_from_wonder(const struct player *pplayer,
|
||
|
const struct impr_type *pimprove);
|
||
|
const struct impr_type *pimprove)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
bool wonder_visible_to_player(const struct impr_type *wonder,
|
||
|
const struct player *pplayer,
|
||
|
const struct player *owner,
|
||