diff --git a/ai/default/daicity.h b/ai/default/daicity.h index cbf410ec19..e65409fe83 100644 --- a/ai/default/daicity.h +++ b/ai/default/daicity.h @@ -22,8 +22,6 @@ struct adv_data; struct tech_vector; -struct ai_activity_cache; // defined and only used within aicity.c - // Who's coming to kill us, for attack co-ordination struct ai_invasion { int attack; // Units capable of attacking city diff --git a/client/cityrep.h b/client/cityrep.h index 29a854145c..1b3053d168 100644 --- a/client/cityrep.h +++ b/client/cityrep.h @@ -20,9 +20,7 @@ #include "cityrepdata.h" #include "climisc.h" -#define NEG_VAL(x) ((x) < 0 ? (x) : (-x)) #define CMA_NONE (10000) -#define CMA_CUSTOM (10001) class QHBoxLayout; class QItemSelection; diff --git a/client/climisc.h b/client/climisc.h index 5871b5c88e..1ae2964b3c 100644 --- a/client/climisc.h +++ b/client/climisc.h @@ -56,7 +56,6 @@ cid cid_encode_building(const struct impr_type *pimprove); cid cid_encode_from_city(const struct city *pcity); struct universal cid_decode(cid cid); -#define cid_production cid_decode bool city_unit_supported(const struct city *pcity, const struct universal *target); diff --git a/client/mapctrl_common.cpp b/client/mapctrl_common.cpp index 0dc198ec5d..36ae1fb207 100644 --- a/client/mapctrl_common.cpp +++ b/client/mapctrl_common.cpp @@ -93,20 +93,16 @@ void key_city_overlay(int canvas_x, int canvas_y) void key_city_show_open(struct city *pcity) { if (can_client_change_view() && pcity) { - if (pcity) { - pcity->client.city_opened = true; - refresh_city_mapcanvas(pcity, pcity->tile, true, false); - } + pcity->client.city_opened = true; + refresh_city_mapcanvas(pcity, pcity->tile, true, false); } } void key_city_hide_open(struct city *pcity) { if (can_client_change_view() && pcity) { - if (pcity) { - pcity->client.city_opened = false; - refresh_city_mapcanvas(pcity, pcity->tile, true, false); - } + pcity->client.city_opened = false; + refresh_city_mapcanvas(pcity, pcity->tile, true, false); } } diff --git a/client/mapview_common.h b/client/mapview_common.h index 860cef7e00..34d60f51b4 100644 --- a/client/mapview_common.h +++ b/client/mapview_common.h @@ -46,7 +46,6 @@ extern struct view mapview; * reenabled afterwards. */ extern bool can_slide; -#define BORDER_WIDTH 2 #define GOTO_WIDTH 2 /* diff --git a/client/options.h b/client/options.h index c3939a8041..4311080d48 100644 --- a/client/options.h +++ b/client/options.h @@ -201,7 +201,6 @@ extern const struct option_set *server_optset; struct option *optset_option_by_number(const struct option_set *poptset, int id); -#define optset_option_by_index optset_option_by_number struct option *optset_option_by_name(const struct option_set *poptset, const char *name); struct option *optset_option_first(const struct option_set *poptset); @@ -212,7 +211,6 @@ const char *optset_category_name(const struct option_set *poptset, // Common option functions. const struct option_set *option_optset(const struct option *poption); int option_number(const struct option *poption); -#define option_index option_number const char *option_name(const struct option *poption); const char *option_description(const struct option *poption); QString option_help_text(const struct option *poption); diff --git a/client/tradecalculation.cpp b/client/tradecalculation.cpp index 1c26c3b838..a0a8a5d78e 100644 --- a/client/tradecalculation.cpp +++ b/client/tradecalculation.cpp @@ -264,10 +264,8 @@ void trade_generator::discard() for (int i = j; i > -j; i--) { while ((tc = find_most_free())) { - if (!discard_one(tc)) { - if (!discard_any(tc, i)) { - break; - } + if (!discard_any(tc, i)) { + break; } } } @@ -287,32 +285,6 @@ void trade_generator::discard_trade(trade_city *tc, trade_city *ttc) check_if_done(tc, ttc); } -/** - Drops one trade route for given city if possible - */ -bool trade_generator::discard_one(trade_city *tc) -{ - int best = 0; - int current_candidate = 0; - int best_id; - trade_city *ttc; - - for (int i = cities.size() - 1; i >= 0; i--) { - ttc = cities.at(i); - current_candidate = ttc->over_max; - if (current_candidate > best) { - best_id = i; - } - } - if (best == 0) { - return false; - } - Q_UNREACHABLE(); - ttc = cities.at(best_id); - discard_trade(tc, ttc); - return true; -} - /** Drops all trade routes for given city */ diff --git a/client/tradecalculation.h b/client/tradecalculation.h index 3af9942ced..6955e528b0 100644 --- a/client/tradecalculation.h +++ b/client/tradecalculation.h @@ -68,7 +68,6 @@ class trade_generator { private: bool discard_any(trade_city *tc, int freeroutes); - bool discard_one(trade_city *tc); int find_over_max(struct city *pcity); trade_city *find_most_free(); void check_if_done(trade_city *tc1, trade_city *tc2); diff --git a/common/aicore/caravan.cpp b/common/aicore/caravan.cpp index c603adfcba..17c894b8f0 100644 --- a/common/aicore/caravan.cpp +++ b/common/aicore/caravan.cpp @@ -115,7 +115,7 @@ typedef bool (*search_callback)(void *data, const struct city *pcity, static void caravan_search_from(const struct unit *caravan, const struct caravan_parameter *param, - struct tile *start_tile, int turns_before, + struct tile *start_tile, int moves_left_before, bool omniscient, search_callback callback, void *callback_data) @@ -124,7 +124,7 @@ static void caravan_search_from(const struct unit *caravan, struct pf_parameter pfparam; int end_time; - end_time = param->horizon - turns_before; + end_time = param->horizon; // Initialize the pf run. pft_fill_unit_parameter(&pfparam, const_cast(caravan)); @@ -148,9 +148,7 @@ static void caravan_search_from(const struct unit *caravan, } pcity = tile_city(pos.tile); - if (pcity - && callback(callback_data, pcity, turns_before + pos.turn, - pos.moves_left)) { + if (pcity && callback(callback_data, pcity, pos.turn, pos.moves_left)) { break; } } @@ -540,8 +538,8 @@ static bool cfbdw_callback(void *vdata, const struct city *dest, */ static void caravan_find_best_destination_withtransit( const struct unit *caravan, const struct caravan_parameter *param, - const struct city *src, int turns_before, int moves_left, - bool omniscient, struct caravan_result *result) + const struct city *src, int moves_left, bool omniscient, + struct caravan_result *result) { Q_UNUSED(moves_left) struct tile *start_tile; @@ -558,9 +556,8 @@ static void caravan_find_best_destination_withtransit( start_tile = unit_tile(caravan); } - caravan_search_from(caravan, param, start_tile, turns_before, - caravan->moves_left, omniscient, cfbdw_callback, - &data); + caravan_search_from(caravan, param, start_tile, caravan->moves_left, + omniscient, cfbdw_callback, &data); } /** @@ -581,6 +578,6 @@ void caravan_find_best_destination(const struct unit *caravan, fc_assert(src != nullptr); caravan_find_best_destination_withtransit( - caravan, parameter, src, 0, caravan->moves_left, omniscient, result); + caravan, parameter, src, caravan->moves_left, omniscient, result); } } diff --git a/common/aicore/path_finding.h b/common/aicore/path_finding.h index 0548507ebb..fb10391e72 100644 --- a/common/aicore/path_finding.h +++ b/common/aicore/path_finding.h @@ -216,13 +216,6 @@ * // do something * } pf_map_positions_iterate_end; * - * 4) information about the whole path (leading to the next nearest - * position): - * pf_map_paths_iterate(pfm, path, true) { - * // do something - * pf_path_destroy(path); - * } pf_map_paths_iterate_end; - * * The third argument passed to the iteration macros is a condition that * controls if the start tile of the pf_parameter should iterated or not. * @@ -573,25 +566,3 @@ bool pf_reverse_map_unit_position(struct pf_reverse_map *pfrm, while (pf_map_iterate(_MY_pf_map_)) \ ; \ } - -/* This macro iterates all possible pathes. - * NB: you need to free the pathes with pf_path_destroy(path_iter). - * - * ARG_pfm - A pf_map structure pointer. - * NAME_path - The name of the iterator to use (type PFPath *). This - * is defined inside the macro. - * COND_from_start - A boolean value (or equivalent, it can be a function) - * which indicate if the start tile should be iterated or - * not. */ -#define pf_map_paths_iterate(ARG_pfm, NAME_path, COND_from_start) \ - if (COND_from_start || pf_map_iterate((ARG_pfm))) { \ - struct pf_map *_MY_pf_map_ = (ARG_pfm); \ - PFPath *NAME_path; \ - do { \ - NAME_path = pf_map_iter_path(_MY_pf_map_); - -#define pf_map_paths_iterate_end \ - } \ - while (pf_map_iterate(_MY_pf_map_)) \ - ; \ - } diff --git a/common/clientutils.cpp b/common/clientutils.cpp index 7e347d6656..31d833b15c 100644 --- a/common/clientutils.cpp +++ b/common/clientutils.cpp @@ -35,14 +35,9 @@ struct actcalc { /** Calculate completion time for all unit activities on tile. - If pmodunit is supplied, take into account the effect if it changed to - doing new_act on new_tgt instead of whatever it's currently doing (if - anything). */ static void calc_activity(struct actcalc *calc, const struct tile *ptile, - const struct unit *pmodunit, - Activity_type_id new_act, - const struct extra_type *new_tgt) + Activity_type_id new_act) { // This temporary working state is a bit big to allocate on the stack struct tmp_state { @@ -62,7 +57,7 @@ static void calc_activity(struct actcalc *calc, const struct tile *ptile, { Activity_type_id act = punit->activity; - if (punit == pmodunit) { + if (punit == nullptr) { // We'll account for this one later continue; } @@ -87,37 +82,6 @@ static void calc_activity(struct actcalc *calc, const struct tile *ptile, } unit_list_iterate_end; - /* Hypothetical contribution from pmodunit, if it changed to specified - * activity/target */ - if (pmodunit) { - if (is_build_activity(new_act, ptile)) { - int eidx = extra_index(new_tgt); - - if (new_act == pmodunit->changed_from - && new_tgt == pmodunit->changed_from_target) { - t->extra_total[eidx][new_act] += pmodunit->changed_from_count; - } - t->extra_total[eidx][new_act] += get_activity_rate_this_turn(pmodunit); - t->extra_units[eidx][new_act] += get_activity_rate(pmodunit); - } else if (is_clean_activity(new_act)) { - int eidx = extra_index(new_tgt); - - if (new_act == pmodunit->changed_from - && new_tgt == pmodunit->changed_from_target) { - t->rmextra_total[eidx][new_act] += pmodunit->changed_from_count; - } - t->rmextra_total[eidx][new_act] += - get_activity_rate_this_turn(pmodunit); - t->rmextra_units[eidx][new_act] += get_activity_rate(pmodunit); - } else { - if (new_act == pmodunit->changed_from) { - t->activity_total[new_act] += pmodunit->changed_from_count; - } - t->activity_total[new_act] += get_activity_rate_this_turn(pmodunit); - t->activity_units[new_act] += get_activity_rate(pmodunit); - } - } - // Turn activity counts into turn estimates activity_type_iterate(act) { @@ -188,7 +152,7 @@ QString concat_tile_activity_text(struct tile *ptile) int num_activities = 0; QString str; - calc_activity(calc, ptile, nullptr, ACTIVITY_LAST, nullptr); + calc_activity(calc, ptile, ACTIVITY_LAST); activity_type_iterate(i) { diff --git a/common/extras.h b/common/extras.h index d1868e1a91..641c25ad67 100644 --- a/common/extras.h +++ b/common/extras.h @@ -170,7 +170,6 @@ struct extra_type *extra_type_by_translated_name(const char *name); #define extra_base_get(_e_) (_e_)->data.base #define extra_road_get(_e_) (_e_)->data.road -#define extra_resource_get(_e_) (_e_)->data.resource void extra_to_caused_by_list(struct extra_type *pextra, enum extra_cause cause); diff --git a/common/game.h b/common/game.h index f638f085ec..2f3c9ed012 100644 --- a/common/game.h +++ b/common/game.h @@ -763,10 +763,6 @@ extern struct world wld; #define RS_MIN_CITY_CENTER_OUTPUT 0 #define RS_MAX_CITY_CENTER_OUTPUT RS_MAX_VALUE -#define RS_DEFAULT_CITIES_MIN_DIST 2 -#define RS_MIN_CITIES_MIN_DIST 1 -#define RS_MAX_CITIES_MIN_DIST RS_MAX_VALUE - // the constants CITY_MAP_*_RADIUS are defined in city.c #define RS_DEFAULT_CITY_RADIUS_SQ CITY_MAP_DEFAULT_RADIUS_SQ #define RS_MIN_CITY_RADIUS_SQ CITY_MAP_MIN_RADIUS_SQ diff --git a/common/map.h b/common/map.h index ce13258367..8ebbc6feb4 100644 --- a/common/map.h +++ b/common/map.h @@ -136,21 +136,6 @@ bool map_startpos_remove(struct tile *ptile); *(pnat_x) = 2 * (map_x) - *(pnat_y)) \ : (*(pnat_x) = (map_x), *(pnat_y) = (map_y))) -/* Provide a block to convert from map to native coordinates. This allows - * you to use a native version of the map position within the block. Note - * that the native position is declared as const and can't be changed - * inside the block. */ -#define do_in_native_pos(nat_x, nat_y, map_x, map_y) \ - { \ - int _nat_x, _nat_y; \ - MAP_TO_NATIVE_POS(&_nat_x, &_nat_y, map_x, map_y); \ - { \ - const int nat_x = _nat_x, nat_y = _nat_y; - -#define do_in_native_pos_end \ - } \ - } - /* Provide a block to convert from map to natural coordinates. This allows * you to use a natural version of the map position within the block. Note * that the natural position is declared as const and can't be changed @@ -167,8 +152,6 @@ bool map_startpos_remove(struct tile *ptile); } // Width and height of the map, in native coordinates. -#define NATIVE_WIDTH wld.map.xsize -#define NATIVE_HEIGHT wld.map.ysize // Width and height of the map, in natural coordinates. #define NATURAL_WIDTH (MAP_IS_ISOMETRIC ? 2 * wld.map.xsize : wld.map.xsize) diff --git a/common/map_types.h b/common/map_types.h index 744cb40520..1cde8770cc 100644 --- a/common/map_types.h +++ b/common/map_types.h @@ -22,8 +22,6 @@ *****************************************************************/ #define terrain_misc packet_ruleset_terrain_control -// Some types used below. -struct nation_hash; struct nation_type; struct packet_edit_startpos_full; diff --git a/common/requirements.h b/common/requirements.h index 912d0d4cfa..83758e6957 100644 --- a/common/requirements.h +++ b/common/requirements.h @@ -305,19 +305,6 @@ bool universal_is_relevant_to_requirement(const struct requirement *req, sv_universal_fulfills_requirements( \ false, (_rqs_), \ (struct universal){.value = {.utype = (_ut_)}, .kind = VUT_UTYPE}) -#define requirement_fulfilled_by_extra(_ex_, _rqs_) \ - sv_universal_fulfills_requirements( \ - false, (_rqs_), \ - (struct universal){.value = {.extra = (_ex_)}, .kind = VUT_EXTRA}) -#define requirement_fulfilled_by_output_type(_o_, _rqs_) \ - sv_universal_fulfills_requirements( \ - false, (_rqs_), \ - (struct universal){.value = {.outputtype = (_o_)}, \ - .kind = VUT_OTYPE}) -#define requirement_fulfilled_by_action(_act_, _rqs_) \ - sv_universal_fulfills_requirements( \ - false, (_rqs_), \ - (struct universal){.value = {.action = (_act_)}, .kind = VUT_ACTION}) #define requirement_needs_improvement(_imp_, _rqs_) \ sv_universal_fulfills_requirements( \ diff --git a/common/style.cpp b/common/style.cpp index a8af824d70..cb2c41bde5 100644 --- a/common/style.cpp +++ b/common/style.cpp @@ -205,7 +205,7 @@ int basic_city_style_for_style(struct nation_style *pstyle) requirement_vector_iterate(&city_styles[i].reqs, preq) { if (preq->source.kind == VUT_STYLE - && preq->source.value.style == pstyle && style_style != TRI_NO) { + && preq->source.value.style == pstyle) { style_style = TRI_YES; } else { /* No any other requirements allowed at the moment. diff --git a/server/advisors/advruleset.cpp b/server/advisors/advruleset.cpp index 92baf4fcd6..c59d3e1ed2 100644 --- a/server/advisors/advruleset.cpp +++ b/server/advisors/advruleset.cpp @@ -57,7 +57,7 @@ void adv_units_ruleset_init() if (move_land_enabled && !move_land_disabled) { pclass->adv.land_move = MOVE_FULL; - } else if (move_land_enabled && move_land_disabled) { + } else if (move_land_enabled) { pclass->adv.land_move = MOVE_PARTIAL; } else { fc_assert(!move_land_enabled); @@ -66,7 +66,7 @@ void adv_units_ruleset_init() if (move_sea_enabled && !move_sea_disabled) { pclass->adv.sea_move = MOVE_FULL; - } else if (move_sea_enabled && move_sea_disabled) { + } else if (move_sea_enabled) { pclass->adv.sea_move = MOVE_PARTIAL; } else { fc_assert(!move_sea_enabled);