[fixed] Bad Parameter Alert - Hurricane
Moderators: BAgate, drool66, Aswan jaguar, gmzombie, stassy, CCGHQ Admins
[fixed] Bad Parameter Alert - Hurricane
by etphonehome » 26 Jul 2021, 22:48
Another Bad Parameter Alert
Savegame and Dump included
THX
Savegame and Dump included
THX
- Attachments
-
- dump.rar
- (249 Bytes) Downloaded 55 times
-
- Bad Parameters.rar
- (2.34 KiB) Downloaded 55 times
Last edited by drool66 on 29 Jul 2021, 18:05, edited 3 times in total.
Reason: fixed
Reason: fixed
- etphonehome
- Posts: 299
- Joined: 21 May 2020, 12:50
- Has thanked: 270 times
- Been thanked: 39 times
Re: Another Bad Parameter Alert
by drool66 » 29 Jul 2021, 00:57
It's Hurricane - it triggers because of the instance->info_slot in new_damage_all(); I can't figure out how to code around this without throttling the AI somewhat
The latest images for Manalink will be here.
The latest Manalink installation directory will be here. Well, not quite, anymore. Check the latest patches.
The latest Manalink installation directory will be here. Well, not quite, anymore. Check the latest patches.
-
drool66 - Programmer
- Posts: 1163
- Joined: 25 Nov 2010, 22:38
- Has thanked: 186 times
- Been thanked: 267 times
Re: [confirmed] Another Bad Parameter Alert
by Korath » 29 Jul 2021, 03:52
Why would that matter? By the time it gets to new_damage_all(), the argument's just a number like any other.
What's really happening here is the assumption in new_damage_all() that damage_creature(target_player, target_card, amount_of_damage, player, card) always returns a valid card index controlled by player. It just returns -1 when it fails early, whether because target_player or player is unset, or if it can't create a damage card, or - as here - damage is 0 or less. The easy repro is to put a creature with flying on the bf and cast Hurricane with X = 0.
(damage_creature() - which really should have been named deal_damage() or similar instead, since it's also the function implementing damage to players - also doesn't return a card index controlled by player when {target_player,target_card} is player's opponent. Damage cards attached to players are always controlled by the player they're attached to, due to a display bug dating back to the original MicroProse release; anything attached to a player is displayed attached to its controller's player, rather than the player it's actually attached to. So, since only damage cards attached to players back then, they worked around it by giving them to the wrong player so they looked right. If you really do need to get a damage card for damage to a player, you have to do get_card_instance(target_player, whatever_damage_creature_returned) instead of get_card_instance(player, ...). But new_damage_all() only does stuff with the created damage card when it's damaging a permanent, so that doesn't matter here.)
The solution is to A) return at the start of new_damage_all() if dmg is <= 0, since comp rule 120.8 makes dealing 0 or less damage equivalent to no damage event at all anyway; and B) check that dmg_card >= 0 before getting an instance in the inner loop of new_damage_all().
Also, why does card_hurricane() tell generic_spell() that it has a target?
What's really happening here is the assumption in new_damage_all() that damage_creature(target_player, target_card, amount_of_damage, player, card) always returns a valid card index controlled by player. It just returns -1 when it fails early, whether because target_player or player is unset, or if it can't create a damage card, or - as here - damage is 0 or less. The easy repro is to put a creature with flying on the bf and cast Hurricane with X = 0.
(damage_creature() - which really should have been named deal_damage() or similar instead, since it's also the function implementing damage to players - also doesn't return a card index controlled by player when {target_player,target_card} is player's opponent. Damage cards attached to players are always controlled by the player they're attached to, due to a display bug dating back to the original MicroProse release; anything attached to a player is displayed attached to its controller's player, rather than the player it's actually attached to. So, since only damage cards attached to players back then, they worked around it by giving them to the wrong player so they looked right. If you really do need to get a damage card for damage to a player, you have to do get_card_instance(target_player, whatever_damage_creature_returned) instead of get_card_instance(player, ...). But new_damage_all() only does stuff with the created damage card when it's damaging a permanent, so that doesn't matter here.)
The solution is to A) return at the start of new_damage_all() if dmg is <= 0, since comp rule 120.8 makes dealing 0 or less damage equivalent to no damage event at all anyway; and B) check that dmg_card >= 0 before getting an instance in the inner loop of new_damage_all().
Also, why does card_hurricane() tell generic_spell() that it has a target?
-
Korath - DEVELOPER
- Posts: 3707
- Joined: 02 Jun 2013, 05:57
- Has thanked: 496 times
- Been thanked: 1106 times
Re: [confirmed] Bad Parameter Alert - Hurricane
by drool66 » 29 Jul 2021, 18:05
That makes sense, thanks. I figured because I could change instance->info_slot to a constant it had something to do with that instance, but I hadn't gotten to the bottom of it.
The target in Hurricane has to be an error.
Implemented and fixed in 3bd4eea
The target in Hurricane has to be an error.
Implemented and fixed in 3bd4eea
The latest images for Manalink will be here.
The latest Manalink installation directory will be here. Well, not quite, anymore. Check the latest patches.
The latest Manalink installation directory will be here. Well, not quite, anymore. Check the latest patches.
-
drool66 - Programmer
- Posts: 1163
- Joined: 25 Nov 2010, 22:38
- Has thanked: 186 times
- Been thanked: 267 times
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 51 guests