Skip to content

Commit

Permalink
Remove unused stuff:/common/city|combat|player.[cpp|h]
Browse files Browse the repository at this point in the history
  • Loading branch information
psampathkumar committed Jul 5, 2022
1 parent b136a76 commit b01d7dd
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 89 deletions.
28 changes: 0 additions & 28 deletions common/city.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1624,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
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
1 change: 1 addition & 0 deletions common/worklist.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ void worklist_remove(struct worklist *pwl, int idx);
bool worklist_append(struct worklist *pwl, const struct universal *prod);
bool worklist_insert(struct worklist *pwl, const struct universal *prod,
int idx);
// Used in packets_gen.cpp
bool are_worklists_equal(const struct worklist *wlist1,
const struct worklist *wlist2);

Expand Down

0 comments on commit b01d7dd

Please sign in to comment.