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

1.15 changed behavior of affect_allies #4257

Closed
stevecotton opened this issue Aug 21, 2019 · 6 comments
Closed

1.15 changed behavior of affect_allies #4257

stevecotton opened this issue Aug 21, 2019 · 6 comments
Labels
MP Issues with multiplayer support or bundled multiplayer content. Question Issues that are actually questions rather than problem reports. Regression Issues that were not present in previous releases. WML Issues involving the WML engine or WML APIs.

Comments

@stevecotton
Copy link
Contributor

Commit 2b65a8c changed the meaning of abilities' affect_allies attribute, this issue is to work out what should be done with the affect_allies and affect_enemies attributes.

Before then, affect_allies was a tristate rather than a boolean before that change: it has a different meaning if it's unset vs "yes" or "no". The value determines both whether the ability affects units on the same side, and units on allied sides, as shown the diff of affects_side:
2b65a8c#diff-b1309a16dace4f5829b1ccb49d1d2ce5

@stevecotton stevecotton added this to the 1.16.0 milestone Aug 21, 2019
@stevecotton stevecotton added MP Issues with multiplayer support or bundled multiplayer content. WML Issues involving the WML engine or WML APIs. labels Aug 21, 2019
@jostephd jostephd added Question Issues that are actually questions rather than problem reports. Regression Issues that were not present in previous releases. labels Sep 9, 2019
@soliton-
Copy link
Member

What is this issue for compared to #4258? Is there any question whether the unintentional change should be corrected?

@ProditorMagnus
Copy link
Contributor

This task is to revert/split affect_allies behavior.

#4258 is whether to keep current unintentional state for leadership only.

@gfgtdf
Copy link
Contributor

gfgtdf commented Sep 10, 2019

Before then, affect_allies was a tristate rather than a boolean before that change: it has a different meaning if it's unset vs "yes" or "no".

This behaviour is not documented in the wiki isn't it? I think that if we want to keep the tristate behviour it'd be better to name the tree state explicitly (and opf course to document them properly). Alterntiveley we coudl also add a new key somethign like affect_own_side that' also allow us to create abilities that affect allies only but not the same team (altough that shoudl alos be possibel with extded filters already.)

@stevecotton
Copy link
Contributor Author

Or a key that takes a list, something like 'affects=self, own_side, allied_sides, enemies'.

@jostephd
Copy link
Member

There's another instance here:

, affect_allies(cfg["affect_allies"].to_bool())

but that struct member is unused, as far as I can tell.

Making the WML key a tristate or a list is a good idea, but in the meantime I think the following would restore the old behavior (there's just no reason to change it, even if it's undocumented):

diff --git a/src/units/abilities.cpp b/src/units/abilities.cpp
index 049c23f8575..c2fd4fe7f62 100644
--- a/src/units/abilities.cpp
+++ b/src/units/abilities.cpp
@@ -131,8 +131,10 @@ bool affects_side(const config& cfg, std::size_t side, std::size_t other_side)
 	// display::get_singleton() has already been confirmed valid by both callers.
 	const team& side_team = display::get_singleton()->get_disp_context().get_team(side);
 
-	if(side == other_side || !side_team.is_enemy(other_side)) {
+	if(side == other_side) {
 		return cfg["affect_allies"].to_bool(true);
+	if(!side_team.is_enemy(other_side)) {
+		return cfg["affect_allies"].to_bool(false);
 	} else {
 		return cfg["affect_enemies"].to_bool();
 	}

OK to push that?

@jostephd
Copy link
Member

jostephd commented Oct 1, 2019

but that struct member is unused, as far as I can tell.

Confirmed that it's unused: I removed it from the hpp and from the constructor and wesnoth bult cleanly.

Pushed the patch with minor changes to make the diff from the pre-2b65a8c5c8dfa0e58061d78f208499304805078a state even smaller. This is the result:

$ git diff 2b65a8c5c8dfa0e58061d78f208499304805078a^ -- src/units/abilities.cpp
diff --git a/src/units/abilities.cpp b/src/units/abilities.cpp
index a688c0bba7c..e8f0fed2821 100644
--- a/src/units/abilities.cpp
+++ b/src/units/abilities.cpp
@@ -124,11 +126,14 @@ A poisoned unit cannot be cured of its poison by a healer, and must seek the car
 
 namespace {
 
-bool affects_side(const config& cfg, const std::vector<team>& teams, std::size_t side, std::size_t other_side)
+bool affects_side(const config& cfg, std::size_t side, std::size_t other_side)
 {
-	if (side == other_side)
+	// display::get_singleton() has already been confirmed valid by both callers.
+	const team& side_team = display::get_singleton()->get_disp_context().get_team(side);
+
+	if(side == other_side)
 		return cfg["affect_allies"].to_bool(true);
-	if (teams[side - 1].is_enemy(other_side))
+	if(side_team.is_enemy(other_side))
 		return cfg["affect_enemies"].to_bool();
 	else
 		return cfg["affect_allies"].to_bool();

newfrenchy83 added a commit to newfrenchy83/wesnoth that referenced this issue Oct 7, 2019
* tips: New tip about terrains.

* Abilities: Revert an unintentional change of the behavior of affect_allies.

Fixes wesnoth#4257

* switch from map_data to map_file in SP

* add map_file to schema

* remove TODOs regaring overlays

* schema: Use same definition as in actionwml

* updated Korean translation

* Improve the terrain code's encapsulation (wesnoth#4411)

Change terrain_type_data's documentation and some methods to avoid exposing
implementation details, for example renaming try_merge_terrains to is_known.

Move the code to load all the [terrain_types] in to the terrain_type_data
class's own .cpp file, and out of terrain.cpp.

Add documentation about "underlying", and why worst(best(a,b),c,d) terrains don't work
The commented-out code for merging pluses and minuses in the middle of an alias
was commented out in 1.5's d2edbe1, but the
concept of pluses and minuses in the middle of an alias seems broken anyway
(see comments added to merge_alias_lists in this commit).

Descriptions are t_strings, avoid converting them to std::string and back.

* Changelog entry for wesnoth#4411, terrain encapsulation

* NR S06a: Fix the filter for Tallin complaining that they're sitting in the caves (wesnoth#4371)

Now it only triggers if five or less units are outside.

(cherry picked from commit 0be05d0)

* updated Portuguese (Brazil) translation

* Rename [unit_type_fix] to [modify_unit_type] for clarity.

* Alter the special notes syntax in EffectWML so that the note macros can be reused in that context

* updated Italian translation

* fix [modify_side] controller=ai for the current side

* Tutorial S02: Make the grunt cross the bridge without bait (wesnoth#4425)

Not a code-revert, but a behavior-revert of the switch of this unit
to use the guardian AI. 26327a5.

If he somehow doesn't get across the bridge, warn the player
that something has broken.

(cherry picked from commit 656a446)

* Experimental AI: fix poisoners ignoring [avoid] tag

* Simple Attack Micro AI Demo: Update dialogue for 1.14's AI improvements (wesnoth#4431)

The default 1.14 already considers high-XP attacks.  Other than the dialogue,
the only change is to reduce the AI's default aggression, so there's more
contrast between what the Micro AI does compared to what the default AI does.

Switched to typographic quotation marks in the dialogue, and removed double
spaces between sentences.

* Added labler action

* Added some rules for the labler

* Restrict labler to PRs being opened, enabled it for issues being opened

* Remove issue trigger

I don't think the labler action is meant to work with issues

* WoV translation: it hasn't been translated into en@shaw

I don't know what happened here, but c61b9b3
had WoV's en@shaw.po filled in with normal English. That's an error, this
commit removes all of those strings.

* Fix the MP lobby reloaded indicator always saying the game isn't reloaded.

Currently, the value of `game["savegame"]` is one of `mp_game_settings::SAVED_GAME_MODE`.  However, the `to_bool()` function doesn't recognize any of those values as being true, so a game is always shown in the MP lobby as not being a reload, even if it actually is.

* Revert to default PR trigger types

This allows them to trigger when synchronized and reopened too.

* Help for the ^Uf mushrooms terrains, including an editor-only hint

As the terrain is hidden in help, these hints can only be seen by
using the "Terrain Description" command on a ^Uf or ^Ufi mushroom
hex, and then switching to the overlay's own page.

A hint for players about how these mushrooms behave, and an editor-only
hint about replacing the ^Uf mushroom terrains with ^Tf.

* Allow translatable strings to display carets to the user (wesnoth#4359)

Treat "editor^The overlays '^Uf' and '^Ufi' are deprecated because ..."
as a having translation hint "editor", and show "The overlays ..." to the
user. This disallows using carets inside the translation hint itself.

Code already reviewed in the discussion in wesnoth#4359.

* Changelog for wesnoth#4359
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MP Issues with multiplayer support or bundled multiplayer content. Question Issues that are actually questions rather than problem reports. Regression Issues that were not present in previous releases. WML Issues involving the WML engine or WML APIs.
Projects
None yet
Development

No branches or pull requests

5 participants