Feature #1914 ยป 0052-unit.c-Replace-parameter-checking-fc_asserts-with-no.patch
| common/unit.c | ||
|---|---|---|
|
const struct unit_type *ptype;
|
||
|
int move_rate;
|
||
|
fc_assert_ret_val(punit != nullptr, 0);
|
||
|
ptype = unit_type_get(punit);
|
||
|
vlevel = utype_veteran_level(ptype, punit->veteran);
|
||
|
fc_assert_ret_val(vlevel != nullptr, 0);
|
||
| ... | ... | |
|
**************************************************************************/
|
||
|
struct player *unit_nationality(const struct unit *punit)
|
||
|
{
|
||
|
fc_assert_ret_val(punit != nullptr, nullptr);
|
||
|
return punit->nationality;
|
||
|
}
|
||
| ... | ... | |
|
**************************************************************************/
|
||
|
void unit_tile_set(struct unit *punit, struct tile *ptile)
|
||
|
{
|
||
|
fc_assert_ret(punit != nullptr);
|
||
|
punit->tile = ptile;
|
||
|
}
|
||
| ... | ... | |
|
/* It does not register the unit so the id is set to 0. */
|
||
|
punit->id = IDENTITY_NUMBER_ZERO;
|
||
|
fc_assert_ret_val(punittype != nullptr, nullptr); /* No untyped units! */
|
||
|
punit->utype = punittype;
|
||
|
fc_assert_ret_val(!is_server() || pplayer != nullptr, nullptr); /* No unowned units! */
|
||
| ... | ... | |
|
**************************************************************************/
|
||
|
int get_transporter_occupancy(const struct unit *ptrans)
|
||
|
{
|
||
|
fc_assert_ret_val(ptrans, -1);
|
||
|
return unit_list_size(ptrans->transporting);
|
||
|
}
|
||
| ... | ... | |
|
const struct unit *punit,
|
||
|
const struct unit_type *to_unittype)
|
||
|
{
|
||
|
fc_assert_ret_val(to_unittype != nullptr, UU_NO_UNITTYPE);
|
||
|
if (!can_type_transport_units_cargo(to_unittype, punit)) {
|
||
|
return UU_NOT_ENOUGH_ROOM;
|
||
|
}
|
||
| ... | ... | |
|
struct player *owner = unit_owner(punit);
|
||
|
const struct unit_type *ptype = unit_type_get(punit);
|
||
|
fc_assert_ret_val(punit != nullptr, 0);
|
||
|
default_hp = ptype->hp;
|
||
|
cost = game.info.base_bribe_cost;
|
||
| ... | ... | |
|
**************************************************************************/
|
||
|
bool unit_transport_load(struct unit *pcargo, struct unit *ptrans, bool force)
|
||
|
{
|
||
|
fc_assert_ret_val(ptrans != nullptr, FALSE);
|
||
|
fc_assert_ret_val(pcargo != nullptr, FALSE);
|
||
|
fc_assert_ret_val(!unit_list_search(ptrans->transporting, pcargo), FALSE);
|
||
|
if (force || can_unit_load(pcargo, ptrans)) {
|
||
| ... | ... | |
|
{
|
||
|
struct unit *ptrans;
|
||
|
fc_assert_ret_val(pcargo != nullptr, FALSE);
|
||
|
if (!unit_transported(pcargo)) {
|
||
|
/* 'pcargo' is not transported. */
|
||
|
return FALSE;
|
||
| ... | ... | |
|
**************************************************************************/
|
||
|
bool unit_transported(const struct unit *pcargo)
|
||
|
{
|
||
|
fc_assert_ret_val(pcargo != nullptr, FALSE);
|
||
|
/* The unit is transported if a transporter unit is set or, (for the client)
|
||
|
* if the transported_by field is set. */
|
||
|
if (is_server()) {
|
||
| ... | ... | |
|
**************************************************************************/
|
||
|
struct unit *unit_transport_get(const struct unit *pcargo)
|
||
|
{
|
||
|
fc_assert_ret_val(pcargo != nullptr, nullptr);
|
||
|
return pcargo->transporter;
|
||
|
}
|
||
| ... | ... | |
|
**************************************************************************/
|
||
|
struct unit_list *unit_transport_cargo(const struct unit *ptrans)
|
||
|
{
|
||
|
fc_assert_ret_val(ptrans != nullptr, nullptr);
|
||
|
fc_assert_ret_val(ptrans->transporting != nullptr, nullptr);
|
||
|
return ptrans->transporting;
|
||
| common/unit.h | ||
|---|---|---|
|
enum unit_activity new_activity,
|
||
|
struct extra_type *new_target,
|
||
|
enum gen_action trigger_action);
|
||
|
int get_activity_rate(const struct unit *punit);
|
||
|
int get_activity_rate(const struct unit *punit)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
int get_activity_rate_this_turn(const struct unit *punit);
|
||
|
int get_turns_for_activity_at(const struct unit *punit,
|
||
|
enum unit_activity activity,
|
||
| ... | ... | |
|
#define is_unit_homeless(_pu_) (punit->homecity == IDENTITY_NUMBER_ZERO)
|
||
|
#define unit_owner(_pu) ((_pu)->owner)
|
||
|
#define unit_tile(_pu) ((_pu)->tile)
|
||
|
struct player *unit_nationality(const struct unit *punit);
|
||
|
void unit_tile_set(struct unit *punit, struct tile *ptile);
|
||
|
struct player *unit_nationality(const struct unit *punit)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
void unit_tile_set(struct unit *punit, struct tile *ptile)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
struct unit *tile_allied_unit(const struct tile *ptile,
|
||
| ... | ... | |
|
struct unit *unit_virtual_create(struct player *pplayer, struct city *pcity,
|
||
|
const struct unit_type *punittype,
|
||
|
int veteran_level);
|
||
|
int veteran_level)
|
||
|
fc__attribute((nonnull(3)));
|
||
|
void unit_virtual_destroy(struct unit *punit);
|
||
|
bool unit_is_virtual(const struct unit *punit);
|
||
|
void free_unit_orders(struct unit *punit);
|
||
|
int get_transporter_occupancy(const struct unit *ptrans);
|
||
|
int get_transporter_occupancy(const struct unit *ptrans)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
struct unit *transporter_for_unit(const struct unit *pcargo);
|
||
|
struct unit *transporter_for_unit_at(const struct unit *pcargo,
|
||
|
const struct tile *ptile);
|
||
| ... | ... | |
|
enum unit_upgrade_result
|
||
|
unit_transform_result(const struct civ_map *nmap,
|
||
|
const struct unit *punit,
|
||
|
const struct unit_type *to_unittype);
|
||
|
const struct unit_type *to_unittype)
|
||
|
fc__attribute((nonnull(3)));
|
||
|
enum unit_upgrade_result unit_upgrade_test(const struct civ_map *nmap,
|
||
|
const struct unit *punit,
|
||
|
bool is_free);
|
||
| ... | ... | |
|
void *data);
|
||
|
int unit_bribe_cost(const struct unit *punit, const struct player *briber,
|
||
|
const struct unit *briber_unit);
|
||
|
const struct unit *briber_unit)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
int stack_bribe_cost(const struct tile *ptile, const struct player *briber,
|
||
|
const struct unit *briber_unit);
|
||
|
int unit_upkeep_cost(const struct unit *punit, Output_type_id otype);
|
||
|
bool unit_transport_load(struct unit *pcargo, struct unit *ptrans,
|
||
|
bool force);
|
||
|
bool unit_transport_unload(struct unit *pcargo);
|
||
|
struct unit *unit_transport_get(const struct unit *pcargo);
|
||
|
bool force)
|
||
|
fc__attribute((nonnull(1, 2)));
|
||
|
bool unit_transport_unload(struct unit *pcargo)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
struct unit *unit_transport_get(const struct unit *pcargo)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
#define unit_transported_server(_pcargo_) ((_pcargo_)->transporter != nullptr)
|
||
| ... | ... | |
|
((_pcargo_)->client.transported_by != -1 \
|
||
|
|| (_pcargo_)->transporter != nullptr)
|
||
|
bool unit_transported(const struct unit *pcargo);
|
||
|
struct unit_list *unit_transport_cargo(const struct unit *ptrans);
|
||
|
bool unit_transported(const struct unit *pcargo)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
struct unit_list *unit_transport_cargo(const struct unit *ptrans)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
bool unit_transport_check(const struct unit *pcargo,
|
||
|
const struct unit *ptrans);
|
||
|
bool unit_contained_in(const struct unit *pcargo, const struct unit *ptrans);
|
||