Page 1 of 1

[fixed/closed]Bug in tapping lands

PostPosted: 17 Apr 2014, 15:07
by 0rion79
BUG: when cards with special casting cost are cast, like Kangee, Aerie Keeper (kicker) or Court Hussar (white mana variant), the game does no longer auto-tap special lands as Wasteland or Kabira Crossroads, which must be tapped for mana in advance.
Patch: April 2014
mmode: tested in EDH

Re: [confirmed]Bug in tapping lands

PostPosted: 18 Apr 2014, 02:02
by BAgate
At least with Wasteland, you can't tap it for mana after the spell has been cast (so if you cast Court Hussar for ex., you choose what type of mana to spend [ex. the kicker is paid] but then when you try to pay the mana Wasteland can not be tapped for mana regardless of if you used autotap or are doing it manually).

Re: [confirmed]Bug in tapping lands

PostPosted: 18 Apr 2014, 02:19
by Korath
I've noticed this, and I'm not sure what causes it.

Or, rather, I know why nothing happens when you click the unhighlit Wasteland, and why that worked in previous versions, and even what broke it: a fix to a more severe bug, which let lands tap for mana even if our response to EVENT_CAN_ACTIVATE says it isn't activateable, and which caused multi-mana lands to tap for one mana instead. (eea7596 is the relevant commit.) What I don't know is why it doesn't get highlit (and didn't in previous versions either).

Highlightedness is stored in card_instance_t::unknown0x70, and is set in reassess_all_cards_helper() at 0x477410. Whether the card is considered activateable doesn't go through that, and is determined in at least two other places; one is sub_476B90() (which doesn't use the same logic as reassess_all_card_helper(), but seems to end up with the same results) and the other is in something called from sub_4378E0(), most likely the SendMessage() call to hwnd_MainWindow (which both uses w32api directly and is multithreaded, either of which would make it very difficult to fully understand even if we had the source).

Now, the thing that all the nonfunctional lands have in common is that they're flagged as having both mana and non-mana abilities (EA_MANA_SOURCE and EA_ACT_ABILITY). There's a function is_mana_source_but_not_act_ability() that checks specifically for this case, called by dispatch_event_to_single_card() and sub_475A30() (the main front-end to the function that chooses a card to activate, whether from an AI decision or from a player clicking on one). If I disable the check of EA_ACT_ABILITY in is_mana_source_but_not_act_ability() - essentially making it return true for every mana source, no matter its other abilities - the lands in question both get highlit and can be activated. There's an experimental patch in branch 14239.

I have no idea what the side effects will be, though, and I'm not thrilled about individually testing every card so flagged (there's 301 of them). Some, like Kabira Crossroads, are misflagged, but I suspect most aren't. And there's a couple of original MicroProse cards like Celestial Prism and Coal Golem and Fire Sprites that are flagged like that which I'd think shouldn't be, which makes me suspect we understand those flags less well than I'd thought.

Re: [confirmed]Bug in tapping lands

PostPosted: 18 Apr 2014, 13:21
by HarlequinCasts
I believe this is the same problem, but this is the example I am seeing in the April patch that was not a problem in BNGv2

Cast Chalice of the Void
Try to pay X = 2 using Ancient Tomb
Cannot tap Ancient Tomb

Work around is to tap for the mana first. Like I said this is new as of April patch.

Re: [confirmed]Bug in tapping lands

PostPosted: 18 Apr 2014, 20:03
by Korath
Yes, Ancient Tomb is one of the lands affected. It was flagged both EA_MANA_SOURCE and EA_ACT_ABILITY to try to work around the same bug whose fix precipitated this - it kept damage from being dealt in the same circumstances that it only gave one mana. (Related bug, also in need of non-developer assistance.)

Here's an executable version of the experimental patch I mentioned earlier, if anyone cares to look for side effects. You'll want to back up Magic.exe first. If you apply this, please say you've done so in any further bug reports, whether they seem related to this one or not.

Re: [confirmed]Bug in tapping lands

PostPosted: 29 Apr 2014, 13:27
by Korath
Haven't had a chance to check cards systematically, but seems to have been working ok. Merged to master in ccc7430.

Re: [confirmed]Bug in tapping lands

PostPosted: 30 Apr 2014, 14:52
by Aswan jaguar
What you are trying to change makes these mana producing cards not to be able to be activated on stack and their activation doesn't use the stack.The engine doesn't recognise that there is a card that can be activated at instant/interrupt speed so you can't respond to a Swords of Plowshares targeting your Coal Golem so you can't pay {3} &sacrifice it to get the {R} {R} {R} using it's ability.And you can't activate any of these cards on the stack if there isn't any other card that can be cast or activated at instant speed.

As I have told you through pm when I did the work on some mana artifacts,creatures & lands these cards need those values.

Re: [confirmed]Bug in tapping lands

PostPosted: 01 May 2014, 21:47
by Nexhro
Korath wrote:(Related bug, also in need of non-developer assistance.)
Done.

Re: [confirmed]Bug in tapping lands

PostPosted: 05 Jan 2016, 12:20
by Korath
This has been fixed for forever, but as of ee91a88 it's done differently.