-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
add savedBattlerAttacker and stack for saved target/attacker #4061
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good changes, should be merged soon.
Added requisite safety checks. Also added debug warning statements as failsafe checks. Added a final safety check in MOVEEND_CLEAR_BITS to ensure all saved attackers/targets were restored within a given turn. Ready for re review |
Good idea! Would it be possible to turn them into errors in tests? I think something like: #if TESTING
Test_ExitWithResult(TEST_RESULT_ERROR, "BS_RestoreTarget attempting to restore an empty target!");
#else
DebugPrintfLevel(MGBA_LOG_WARN, "BS_RestoreTarget attempting to restore an empty target!");
#endif With a: #if TESTING
#include "test/test.h"
#endif Ought to work. Annoyingly Maybe in the future we should use |
good suggestion. Just pushed these changes. Also added to the checks in MOVEEND_CLEAR_BITS. In my project I use a lot of asserts, but warnings may be better because assertion fails just shut down mgba. But discussion on that is probably better on discord. |
This keeps failing with |
It doesn't build with |
Even after adding that make check fails |
My bad, sorry. |
Fixed the error by including test/test.h in battle_script_commands.c but make check them bombs with illegal op codes after a while. I think I saw an error with the sticky web/mirror armor test? |
Illegal opcodes usually means stack corruption—something overwriting an |
…s on SaveAttacker,SaveTarget
ready for review. I put incorporating into tests on the backburner. Will open a reminder issue upon merging |
#4061 change `ABILITY_FRISK` to use `gBattleScripting.battler` but the script wasn't fully updated. BS_ATTACKER needed to be changed to `BS_SCRIPTING`
#4061 change `ABILITY_FRISK` to use `gBattleScripting.battler` but the script wasn't fully updated. BS_ATTACKER needed to be changed to `BS_SCRIPTING`
Several effects have had issues overwriting gBattlerAttacker/gBattlerTarget in the past and present. We should move away from backing up battler IDs into other id slots by using savetarget/saveattacker. So I added a stack for redundancy. An example of one possible issue would be backing up a battler id to saved battler and then having a chaining effect that also saved a different battler id to saved battler. The top-most call stack would restore the incorrect battler id.