Skip to content

Commit

Permalink
Remove update_unit_pix_label and related functions
Browse files Browse the repository at this point in the history
The function wasn't doing anything.
  • Loading branch information
lmoureaux committed Nov 2, 2024
1 parent 778195b commit 3c0a00a
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 98 deletions.
1 change: 0 additions & 1 deletion client/climisc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ void client_remove_unit(struct unit *punit)
if (old > 0 && get_num_units_in_focus() == 0) {
unit_focus_advance();
} else if (update) {
update_unit_pix_label(get_units_in_focus());
update_unit_info_label(get_units_in_focus());
}

Expand Down
62 changes: 0 additions & 62 deletions client/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ static int disband_unit_alternatives[3] = {
ACTION_HELP_WONDER,
};

// gui-dep code may adjust depending on tile size etc:
int num_units_below = MAX_NUM_UNITS_BELOW;

// current_focus points to the current unit(s) in focus
static auto current_focus = std::vector<unit *>();

Expand Down Expand Up @@ -902,65 +899,6 @@ int blink_turn_done_button()
return blink_time;
}

/**
Update unit icons (and arrow) in the information display, for specified
punit as the active unit and other units on the same square. In practice
punit is almost always (or maybe strictly always?) the focus unit.
Static vars store some info on current (ie previous) state, to avoid
unnecessary redraws; initialise to "flag" values to always redraw first
time. In principle we _might_ need more info (eg ai.control, connecting),
but in practice this is enough?
Used to store unit_ids for below units, to use for callbacks (now done
inside gui-dep set_unit_icon()), but even with ids here they would not
be enough information to know whether to redraw -- instead redraw every
time. (Could store enough info to know, but is it worth it?)
*/
void update_unit_pix_label(const std::vector<unit *> &units)
{
int i;

/* Check for any change in the unit's state. This assumes that a unit's
* orders cannot be changed directly but must be removed and then reset. */
if (!units.empty() && C_S_OVER != client_state()) {
/* There used to be a complicated and bug-prone check here to see if
* the unit had actually changed. This was misguided since the stacked
* units (below) are redrawn in any case. Unless we write a general
* system for unit updates here we might as well just redraw it every
* time. */
struct unit *punit = units.front();

set_unit_icon(-1, punit);

i = 0; // index into unit_below_canvas
unit_list_iterate(unit_tile(punit)->units, aunit)
{
if (aunit != punit) {
if (i < num_units_below) {
set_unit_icon(i, aunit);
}
i++;
}
}
unit_list_iterate_end;

if (i > num_units_below) {
set_unit_icons_more_arrow(true);
} else {
set_unit_icons_more_arrow(false);
for (; i < num_units_below; i++) {
set_unit_icon(i, nullptr);
}
}
} else {
for (i = -1; i < num_units_below; i++) {
set_unit_icon(i, nullptr);
}
set_unit_icons_more_arrow(false);
}
}

/**
Adjusts way combatants are displayed suitable for combat.
*/
Expand Down
7 changes: 0 additions & 7 deletions client/control.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ void unit_focus_update();
void set_auto_center_enabled(bool enabled);
void auto_center_on_focus_unit();

void update_unit_pix_label(const std::vector<unit *> &units);

unit *find_visible_unit(const ::tile *ptile);
void set_units_in_combat(struct unit *pattacker, struct unit *pdefender);
int blink_active_unit();
Expand Down Expand Up @@ -213,8 +211,3 @@ void key_unit_wakeup_others();

void finish_city(struct tile *ptile, const char *name);
void cancel_city(struct tile *ptile);

/* don't change this unless you also put more entries in data/Freeciv */
#define MAX_NUM_UNITS_BELOW 4

extern int num_units_below;
26 changes: 0 additions & 26 deletions client/gui_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,32 +146,6 @@ void sound_bell()
*/
void add_net_input(QIODevice *sock) { king()->add_server_source(sock); }

/**
Set one of the unit icons (specified by idx) in the information area
based on punit.
punit is the unit the information should be taken from. Use nullptr to
clear the icon.
idx specified which icon should be modified. Use idx == -1 to indicate
the icon for the active unit. Or idx in [0..num_units_below-1] for
secondary (inactive) units on the same tile.
*/
void set_unit_icon(int idx, struct unit *punit)
{ // PORTME
}

/**
Most clients use an arrow (e.g., sprites.right_arrow) to indicate when
the units_below will not fit. This function is called to activate or
deactivate the arrow.
Is disabled by default.
*/
void set_unit_icons_more_arrow(bool onoff)
{ // PORTME
}

/**
Called when the set of units in focus (get_units_in_focus()) changes.
Standard updates like update_unit_info_label() are handled in the
Expand Down
2 changes: 0 additions & 2 deletions client/qtg_cxxside.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ client_pages get_current_client_page();
void popup_combat_info(int attacker_unit_id, int defender_unit_id,
int attacker_hp, int defender_hp,
bool make_att_veteran, bool make_def_veteran);
void set_unit_icon(int idx, unit *punit);
void set_unit_icons_more_arrow(bool onoff);
void real_focus_units_changed();
void gui_update_font(const QString &font_name, const QFont &font_value);

Expand Down

0 comments on commit 3c0a00a

Please sign in to comment.