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

List small wonders in the client, but hide them by default #1305

Merged
merged 3 commits into from
Aug 23, 2022
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
1 change: 1 addition & 0 deletions ai/default/daieffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ adv_want dai_effect_value(struct player *pplayer, struct government *gov,
case EFT_STEALINGS_IGNORE:
case EFT_MAPS_STOLEN_PCT:
case EFT_UNIT_SHIELD_VALUE_PCT:
case EFT_WONDER_VISIBLE:
break;
// This has no effect for AI
case EFT_VISIBLE_WALLS:
Expand Down
36 changes: 36 additions & 0 deletions client/plrdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@
#include <QPainter>
#include <QSortFilterProxyModel>
// utility
#include "astring.h"
#include "fcintl.h"
// common
#include "city.h"
#include "colors_common.h"
#include "game.h"
#include "government.h"
#include "improvement.h"
#include "nation.h"
#include "research.h"
// client
Expand Down Expand Up @@ -633,6 +637,38 @@ void plr_widget::nation_selected(const QItemSelection &sl,
+ QStringLiteral("</i>") + sp;
}
}
// Wonder information
auto wonders = QStringList();
for (int i = 0; i < improvement_count(); ++i) {
if (pplayer->wonders[i] == WONDER_NOT_BUILT) {
continue;
}

const auto improve = improvement_by_number(i);
const auto name =
QString(improvement_name_translation(improve)).toHtmlEscaped();
if (pplayer->wonders[i] == WONDER_LOST) {
// TRANS: %1 is a wonder name
wonders += QString(_("%1 (lost)")).arg(name);
} else if (const auto city = game_city_by_number(pplayer->wonders[i])) {
// TRANS: %1 is a wonder name, %2 is a city name
wonders += QString(_("%1 (in %2)"))
.arg(name)
.arg(QString(city_name_get(city)).toHtmlEscaped());
} else {
wonders += name;
}
}
if (!tech_str.isEmpty()) {
tech_str += nl;
}
// TRANS: Followed by a list of wonders the player knows another player has
tech_str += QString(_("<b>Known Wonders: </b>"));
if (wonders.isEmpty()) {
tech_str += QString(Q_("?wonder:None"));
} else {
tech_str += strvec_to_and_list(wonders.toVector());
}
plr->update_report(false);
}

Expand Down
1 change: 1 addition & 0 deletions common/effects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1215,6 +1215,7 @@ QString effect_type_unit_text(effect_type type, int value)
case EFT_BORDER_VISION:
case EFT_STEALINGS_IGNORE:
case EFT_CASUS_BELLI_COMPLETE:
case EFT_WONDER_VISIBLE:
case EFT_COUNT:
return QStringLiteral("%1").arg(value);
}
Expand Down
2 changes: 2 additions & 0 deletions common/effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@
#define SPECENUM_VALUE130NAME "Bombard_Limit_Pct"
#define SPECENUM_VALUE131 EFT_TRADE_REVENUE_EXPONENT
#define SPECENUM_VALUE131NAME "Trade_Revenue_Exponent"
#define SPECENUM_VALUE132 EFT_WONDER_VISIBLE
#define SPECENUM_VALUE132NAME "Wonder_Visible"
// keep this last
#define SPECENUM_COUNT EFT_COUNT
#include "specenum_gen.h"
Expand Down
5 changes: 4 additions & 1 deletion common/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "ai.h"
#include "city.h"
#include "disaster.h"
#include "effects.h"
#include "extras.h"
#include "government.h"
#include "idex.h"
Expand Down Expand Up @@ -650,7 +651,9 @@ void initialize_globals()
game.info.great_wonder_owners[improvement_index(pimprove)] =
player_number(pplayer);
}
pplayer->wonders[improvement_index(pimprove)] = pcity->id;
if (get_building_bonus(pcity, pimprove, EFT_WONDER_VISIBLE) > 0) {
pplayer->wonders[improvement_index(pimprove)] = pcity->id;
}
}
}
city_built_iterate_end;
Expand Down
12 changes: 12 additions & 0 deletions docs/Modding/Rulesets/effects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -708,3 +708,15 @@ Bombard_Limit_Pct
.. note::
This effect is added automatically with a value of 1 and no reqs. This behavior can be turned
off by requiring the ``+Bombard_Limit_Pct`` option in ``effects.ruleset``.

Wonder_Visible
If the value of this effect is larger than 0 for a Small Wonder, the wonder will be visible to all
players and reported in the intelligence screen. Great Wonders are always visible to everyone through the
Wonders Report. When a Small Wonder is lost (for instance, because the city it is in is lost or some of
its requirements become invalid), it also becomes visible to everyone (this is a limitation of the
server).

.. note::
This effect is added automatically with a value of 1 for Great Wonders (since they are shown in the
Wonders Report anyway). This behavior can be turned off by requiring the ``+Wonder_Visible`` option
in ``effects.ruleset``.
25 changes: 22 additions & 3 deletions server/plrhand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
#include "citizens.h"
#include "culture.h"
#include "diptreaty.h"
#include "game.h"
#include "government.h"
#include "improvement.h"
#include "map.h"
#include "multipliers.h"
#include "packets.h"
Expand Down Expand Up @@ -1134,9 +1136,6 @@ static void package_player_common(struct player *plr,
packet->phase_done = plr->phase_done;
packet->nturns_idle = plr->nturns_idle;

for (i = 0; i < B_LAST /*improvement_count()*/; i++) {
packet->wonders[i] = plr->wonders[i];
}
packet->science_cost = plr->ai_common.science_cost;
}

Expand Down Expand Up @@ -1198,6 +1197,26 @@ static void package_player_info(struct player *plr,
}
players_iterate_end;

// Wonder information
for (int i = 0; i < B_LAST; ++i) {
// Lost, not built or doesn't exist (still need to fill the array)
if (plr->wonders[i] <= 0 || i >= improvement_count()) {
packet->wonders[i] = plr->wonders[i];
continue;
}

const auto pimprove = improvement_by_number(i);
const auto pcity = game_city_by_number(plr->wonders[i]);
const auto bonus = get_target_bonus_effects(
nullptr, city_owner(pcity), receiver, pcity, pimprove, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, EFT_WONDER_VISIBLE);
if (bonus > 0) {
packet->wonders[i] = plr->wonders[i];
} else {
packet->wonders[i] = WONDER_NOT_BUILT;
}
}

if (plr->rgb != nullptr) {
packet->color_valid = true;
packet->color_red = plr->rgb->r;
Expand Down
7 changes: 7 additions & 0 deletions server/rscompat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,13 @@ static void rscompat_optional_capabilities(rscompat_info *info)
unit_type_iterate_end;
}

if (!has_capability(CAP_EFT_WONDER_VISIBLE, info->cap_effects.data())) {
// Make Great Wonders visible to everyone
auto effect = effect_new(EFT_WONDER_VISIBLE, 1, nullptr);
effect_req_append(effect, req_from_str("BuildingGenus", "Local", false,
true, false, "GreatWonder"));
}

if (!has_capability(CAP_VUT_VISIONLAYER, info->cap_effects.data())) {
// Add vlayer=Main to existing vision effects
iterate_effect_cache(rscompat_vision_effect_cb, info);
Expand Down
4 changes: 3 additions & 1 deletion server/ruleset.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@

#define CAP_EFT_HP_REGEN_MIN "HP_Regen_Min"
#define CAP_EFT_BOMBARD_LIMIT_PCT "Bombard_Limit_Pct"
#define CAP_EFT_WONDER_VISIBLE "Wonder_Visible"
#define CAP_VUT_VISIONLAYER "Vision_Layer"
#define RULESET_CAPABILITIES \
"+Freeciv-ruleset-Devel-2017.Jan.02 " CAP_EFT_HP_REGEN_MIN \
" " CAP_EFT_BOMBARD_LIMIT_PCT " " CAP_VUT_VISIONLAYER
" " CAP_EFT_BOMBARD_LIMIT_PCT " " CAP_EFT_WONDER_VISIBLE \
" " CAP_VUT_VISIONLAYER
/*
* Ruleset capabilities acceptable to this program:
*
Expand Down