Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/remove unused functions4 #1082

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 0 additions & 40 deletions common/actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5238,36 +5238,6 @@ struct act_prob action_speculate_unit_on_city(const action_id act_id,
}
}

/**
Returns a speculation about the actor unit's probability of successfully
performing the chosen action on the target unit given the specified
game state changes.
*/
struct act_prob action_speculate_unit_on_unit(action_id act_id,
const struct unit *actor,
const struct city *actor_home,
const struct tile *actor_tile,
bool omniscient_cheat,
const struct unit *target)
{
/* FIXME: some unit state requirements still depend on the actor unit's
* current position rather than on actor_tile. Maybe this function should
* return ACTPROB_NOT_IMPLEMENTED when one of those is detected and no
* other requirement makes the action ACTPROB_IMPOSSIBLE? */

if (omniscient_cheat) {
if (is_action_enabled_unit_on_unit_full(act_id, actor, actor_home,
actor_tile, target)) {
return ACTPROB_CERTAIN;
} else {
return ACTPROB_IMPOSSIBLE;
}
} else {
return action_prob_vs_unit_full(actor, actor_home, actor_tile, act_id,
target);
}
}

/**
Returns a speculation about the actor unit's probability of successfully
performing the chosen action on the target unit stack given the specified
Expand Down Expand Up @@ -5416,16 +5386,6 @@ bool action_prob_possible(const struct act_prob probability)
|| action_prob_not_impl(probability));
}

/**
Returns TRUE iff the given action probability is certain that its action
is possible.
*/
bool action_prob_certain(const struct act_prob probability)
{
return (ACTPROB_VAL_MAX == probability.min
&& ACTPROB_VAL_MAX == probability.max);
}

/**
Returns TRUE iff the given action probability represents the lack of
an action probability.
Expand Down
9 changes: 0 additions & 9 deletions common/actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -687,13 +687,6 @@ struct act_prob action_speculate_unit_on_city(action_id act_id,
bool omniscient_cheat,
const struct city *target);

struct act_prob action_speculate_unit_on_unit(action_id act_id,
const struct unit *actor,
const struct city *actor_home,
const struct tile *actor_tile,
bool omniscient_cheat,
const struct unit *target);

struct act_prob action_speculate_unit_on_units(action_id act_id,
const struct unit *actor,
const struct city *actor_home,
Expand All @@ -715,8 +708,6 @@ struct act_prob action_speculate_unit_on_self(action_id act_id,

bool action_prob_possible(const struct act_prob probability);

bool action_prob_certain(const struct act_prob probability);

bool are_action_probabilitys_equal(const struct act_prob *ap1,
const struct act_prob *ap2);

Expand Down
30 changes: 0 additions & 30 deletions common/city.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1188,8 +1188,6 @@ bool city_has_building(const struct city *pcity,
const struct impr_type *pimprove)
{
if (nullptr == pimprove) {
/* Callers should ensure that any external data is tested with
* valid_improvement_by_number() */
lmoureaux marked this conversation as resolved.
Show resolved Hide resolved
return false;
}
return (pcity->built[improvement_index(pimprove)].turn > I_NEVER);
Expand Down Expand Up @@ -1626,34 +1624,6 @@ struct city *city_list_find_name(struct city_list *This, const char *name)
return nullptr;
}

/**
Comparison function for qsort for city _pointers_, sorting by city name.
Args are really (struct city**), to sort an array of pointers.
(Compare with old_city_name_compare() in game.c, which use city_id's)
*/
int city_name_compare(const void *p1, const void *p2)
{
return fc_strcasecmp((*(const struct city **) p1)->name,
(*(const struct city **) p2)->name);
}

/**
Returns the city style that has the given (translated) name.
Returns -1 if none match.
*/
int city_style_by_translated_name(const char *s)
{
int i;

for (i = 0; i < game.control.styles_count; i++) {
if (0 == strcmp(city_style_name_translation(i), s)) {
return i;
}
}

return -1;
}

/**
Returns the city style that has the given (untranslated) rule name.
Returns -1 if none match.
Expand Down
3 changes: 0 additions & 3 deletions common/city.h
Original file line number Diff line number Diff line change
Expand Up @@ -659,14 +659,11 @@ bool city_can_be_built_tile_only(const struct tile *ptile);
struct city *city_list_find_number(struct city_list *This, int id);
struct city *city_list_find_name(struct city_list *This, const char *name);

int city_name_compare(const void *p1, const void *p2);

// city style functions
const char *city_style_rule_name(const int style);
const char *city_style_name_translation(const int style);

int city_style_by_rule_name(const char *s);
int city_style_by_translated_name(const char *s);

struct city *is_enemy_city_tile(const struct tile *ptile,
const struct player *pplayer);
Expand Down
33 changes: 0 additions & 33 deletions common/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -781,39 +781,6 @@ struct unit *get_defender(const struct unit *attacker,
return bestdef;
}

/**
Get unit at (x, y) that wants to kill defender.

Works like get_defender; see comment there.
This function is mostly used by the AI.
*/
struct unit *get_attacker(const struct unit *defender,
const struct tile *ptile)
{
struct unit *bestatt = 0;
int bestvalue = -1, unit_a, best_cost = 0;

unit_list_iterate(ptile->units, attacker)
{
int build_cost = unit_build_shield_cost_base(attacker);

if (pplayers_allied(unit_owner(defender), unit_owner(attacker))) {
return nullptr;
}
unit_a =
static_cast<int>(100000 * (unit_win_chance(attacker, defender)));
if (unit_a > bestvalue
|| (unit_a == bestvalue && build_cost < best_cost)) {
bestvalue = unit_a;
bestatt = attacker;
best_cost = build_cost;
}
}
unit_list_iterate_end;

return bestatt;
}

/**
Returns the defender of the tile in a diplomatic battle or nullptr if no
diplomatic defender could be found.
Expand Down
3 changes: 0 additions & 3 deletions common/combat.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ void get_modified_firepower(const struct unit *attacker,
double unit_win_chance(const struct unit *attacker,
const struct unit *defender);

bool unit_really_ignores_citywalls(const struct unit *punit);
struct city *sdi_try_defend(const struct player *owner,
const struct tile *ptile);
bool is_tired_attack(int moves_left);
Expand All @@ -74,8 +73,6 @@ int get_total_attack_power(const struct unit *attacker,

struct unit *get_defender(const struct unit *attacker,
const struct tile *ptile);
struct unit *get_attacker(const struct unit *defender,
const struct tile *ptile);

struct unit *get_diplomatic_defender(const struct unit *act_unit,
const struct unit *pvictim,
Expand Down
22 changes: 0 additions & 22 deletions common/improvement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,17 +208,6 @@ const struct impr_type *valid_improvement(const struct impr_type *pimprove)
return pimprove;
}

/**
Returns pointer when the improvement_type "exists" in this game,
returns nullptr otherwise.

In addition to valid_improvement(), tests for id is out of range.
*/
const struct impr_type *valid_improvement_by_number(const Impr_type_id id)
{
return valid_improvement(improvement_by_number(id));
}

/**
Return the (translated) name of the given improvement.
You don't have to free the return pointer.
Expand Down Expand Up @@ -979,17 +968,6 @@ struct player *great_wonder_owner(const struct impr_type *pimprove)
}
}

/**
Returns whether the player has built this small wonder.
*/
bool small_wonder_is_built(const struct player *pplayer,
const struct impr_type *pimprove)
{
fc_assert_ret_val(is_small_wonder(pimprove), false);

return (nullptr != pplayer && wonder_is_built(pplayer, pimprove));
}

/**
Get the player city with this small wonder.
*/
Expand Down
3 changes: 0 additions & 3 deletions common/improvement.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ Impr_type_id improvement_number(const struct impr_type *pimprove);
struct impr_type *improvement_by_number(const Impr_type_id id);

const struct impr_type *valid_improvement(const struct impr_type *pimprove);
const struct impr_type *valid_improvement_by_number(const Impr_type_id id);

struct impr_type *improvement_by_rule_name(const char *name);
struct impr_type *improvement_by_translated_name(const char *name);
Expand Down Expand Up @@ -165,8 +164,6 @@ bool great_wonder_is_available(const struct impr_type *pimprove);
struct city *city_from_great_wonder(const struct impr_type *pimprove);
struct player *great_wonder_owner(const struct impr_type *pimprove);

bool small_wonder_is_built(const struct player *pplayer,
const struct impr_type *pimprove);
struct city *city_from_small_wonder(const struct player *pplayer,
const struct impr_type *pimprove);

Expand Down
52 changes: 0 additions & 52 deletions common/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -904,14 +904,6 @@ bool same_pos(const struct tile *tile1, const struct tile *tile2)
return (tile1->index == tile2->index);
}

/**
Is given position real position
*/
bool is_real_map_pos(const struct civ_map *nmap, int x, int y)
{
return normalize_map_pos(nmap, &x, &y);
}

/**
Returns TRUE iff the map position is normal. "Normal" here means that
it is both a real/valid coordinate set and that the coordinates are in
Expand Down Expand Up @@ -1038,42 +1030,6 @@ void map_distance_vector(int *dx, int *dy, const struct tile *tile0,
base_map_distance_vector(dx, dy, tx0, ty0, tx1, ty1);
}

/**
Random neighbouring square.
*/
struct tile *rand_neighbour(const struct civ_map *nmap,
const struct tile *ptile)
{
int n;
struct tile *tile1;

/*
* list of all 8 directions
*/
enum direction8 dirs[8] = {DIR8_NORTHWEST, DIR8_NORTH, DIR8_NORTHEAST,
DIR8_WEST, DIR8_EAST, DIR8_SOUTHWEST,
DIR8_SOUTH, DIR8_SOUTHEAST};

/* This clever loop by Trent Piepho will take no more than
* 8 tries to find a valid direction. */
for (n = 8; n > 0; n--) {
enum direction8 choice = static_cast<enum direction8>(fc_rand(n));

// this neighbour's OK
tile1 = mapstep(nmap, ptile, dirs[choice]);
if (tile1) {
return tile1;
}

/* Choice was bad, so replace it with the last direction in the list.
* On the next iteration, one fewer choices will remain. */
dirs[choice] = dirs[n - 1];
}

fc_assert(false); // Are we on a 1x1 map with no wrapping???
return nullptr;
}

/**
Random square anywhere on the map. Only normal positions (for which
is_normal_map_pos returns true) will be found.
Expand Down Expand Up @@ -1423,14 +1379,6 @@ static void startpos_destroy(struct startpos *psp)
delete psp;
}

/**
Returns the start position associated to the given ID.
*/
struct startpos *map_startpos_by_number(int id)
{
return map_startpos_get(index_to_tile(&(wld.map), id));
}

/**
Returns the unique ID number for this start position. This is just the
tile index of the tile where this start position is located.
Expand Down
5 changes: 0 additions & 5 deletions common/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ int get_direction_for_step(const struct civ_map *nmap,
const struct tile *src_tile,
const struct tile *dst_tile);

// Specific functions for start positions.
struct startpos *map_startpos_by_number(int id);
int startpos_number(const struct startpos *psp);

bool startpos_allow(struct startpos *psp, struct nation_type *pnation);
Expand Down Expand Up @@ -206,7 +204,6 @@ struct tile *native_pos_to_tile(const struct civ_map *nmap, int nat_x,
int nat_y);
struct tile *index_to_tile(const struct civ_map *imap, int mindex);

bool is_real_map_pos(const struct civ_map *nmap, int x, int y);
bool is_normal_map_pos(int x, int y);

bool is_singular_tile(const struct tile *ptile, int dist);
Expand All @@ -219,8 +216,6 @@ void map_distance_vector(int *dx, int *dy, const struct tile *ptile0,
int map_num_tiles();
#define map_size_checked() MAX(map_num_tiles() / 1000, 1)

struct tile *rand_neighbour(const struct civ_map *nmap,
const struct tile *ptile);
struct tile *rand_map_pos(const struct civ_map *nmap);
struct tile *rand_map_pos_filtered(const struct civ_map *nmap, void *data,
bool (*filter)(const struct tile *ptile,
Expand Down
19 changes: 0 additions & 19 deletions common/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1405,17 +1405,6 @@ bool gives_shared_vision(const struct player *me, const struct player *them)
return BV_ISSET(me->gives_shared_vision, player_index(them));
}

/**
Return TRUE iff the two diplstates are equal.
*/
bool are_diplstates_equal(const struct player_diplstate *pds1,
const struct player_diplstate *pds2)
{
return (pds1->type == pds2->type && pds1->turns_left == pds2->turns_left
&& pds1->has_reason_to_cancel == pds2->has_reason_to_cancel
&& pds1->contact_turns_left == pds2->contact_turns_left);
}

/**
Return TRUE iff player1 has the diplomatic relation to player2
*/
Expand Down Expand Up @@ -1828,14 +1817,6 @@ bool is_settable_ai_level(enum ai_level level)
return true;
}

/**
Return number of AI levels in game
*/
int number_of_ai_levels()
{
return AI_LEVEL_COUNT - 1; // AI_LEVEL_AWAY is not real AI
}

/**
Return pointer to ai data of given player and ai type.
*/
Expand Down
3 changes: 0 additions & 3 deletions common/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,6 @@ enum diplstate_type cancel_pact_result(enum diplstate_type oldstate);

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);
enum dipl_reason pplayer_can_make_treaty(const struct player *p1,
const struct player *p2,
enum diplstate_type treaty);
Expand Down Expand Up @@ -542,7 +540,6 @@ bool is_valid_username(const char *name);

#define ai_level_cmd(_level_) ai_level_name(_level_)
bool is_settable_ai_level(enum ai_level level);
int number_of_ai_levels();

void *player_ai_data(const struct player *pplayer, const struct ai_type *ai);
void player_set_ai_data(struct player *pplayer, const struct ai_type *ai,
Expand Down
Loading