Skip to content

Commit

Permalink
Merge pull request longturn#2372 from XHawk87/master
Browse files Browse the repository at this point in the history
Include both the veteran rank name and number in sentry message
  • Loading branch information
hugomflavio authored Sep 10, 2024
2 parents 70d5da1 + c9e086f commit 470a541
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Freeciv21 contributors are listed below in alphabetical order:
- panch93 (Pranav Sampathkumar)
- soundnfury (Ed Cree)
- TriClad (Hugo Flávio)
- XHawk87

Freeciv contributors are too numerous to list here. You will find a complete
list at:
Expand Down
23 changes: 23 additions & 0 deletions common/featured_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,29 @@ const char *unit_tile_link(const struct unit *punit)
return buf;
}

/**
* Get a text of a unit's numerical veteran level and the bonus percentage it
* confers. N.B.: The returned string is static, so every call to this
* function overwrites the previous.
* @param punit The unit to display the veteran level and bonus of
* @return The veteran level and bonus in string format
*/
const char *unit_veteran_level_and_bonus(const unit *punit)
{
static char buf[MAX_LEN_LINK];

if (!punit) {
buf[0] = '\0'; /* If no unit, return empty string */
return buf;
}

const veteran_level *vlevel =
utype_veteran_level(unit_type_get(punit), punit->veteran);
snprintf(buf, sizeof(buf), _("v%d %d%%"), punit->veteran,
vlevel->power_fact);
return buf;
}

/**
Get a text of a unit's vet level.
N.B.: The returned string is static, so every call to this function
Expand Down
1 change: 1 addition & 0 deletions common/featured_text.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ const char *tile_link(const struct tile *ptile);
const char *unit_link(const struct unit *punit);
const char *unit_tile_link(const struct unit *punit);

const char *unit_veteran_level_and_bonus(const struct unit *punit);
const char *unit_veteran_level_string(const struct unit *punit);
const char *unit_achieved_rank_string(const struct unit *punit);
const char *unit_tired_attack_string(const struct unit *punit);
Expand Down
8 changes: 5 additions & 3 deletions server/unittools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3572,10 +3572,12 @@ static void wakeup_neighbor_sentries(struct unit *punit)
send_unit_info(nullptr, penemy);
notify_player(
unit_owner(penemy), unit_tile(punit), E_UNIT_ORDERS, ftc_server,
_("Your sentried %s spotted a %s v%d %s [id:%d hp:%d] at %s "),
_("Your sentried %s spotted a %s %s %s [id:%d, %s, hp:%d] at "
"%s."),
unit_link(penemy),
nation_adjective_for_player(unit_owner(punit)), punit->veteran,
unit_name_translation(punit), punit->id, punit->hp,
nation_adjective_for_player(unit_owner(punit)),
unit_veteran_level_string(punit), unit_name_translation(punit),
punit->id, unit_veteran_level_and_bonus(punit), punit->hp,
tile_link(punit->tile));
}
}
Expand Down

0 comments on commit 470a541

Please sign in to comment.