ref: 866fafddd2ed5846be26848e123cd899f384c461
parent: eccbc52df2c10e7efad9fd798ad0836a2a8b7bb4
author: Snesrev <snesrev@protonmail.com>
date: Thu Sep 29 20:14:00 EDT 2022
Ensure Cane of Somaria can't overflow the magic meter (#126)
--- a/player.c
+++ b/player.c
@@ -3397,7 +3397,12 @@
void Refund_Magic(uint8 x) { // 87b0e9
uint8 cost = kLinkItem_MagicCosts[x * 3 + link_magic_consumption];
- link_magic_power += cost;
+
+ int new_magic = link_magic_power + cost;
+ // Ensure magic can't overflow (for example the cane of somaria bug)
+ if (enhanced_features0 & kFeatures0_MiscBugFixes && new_magic >= 128)
+ new_magic = 128;
+ link_magic_power = new_magic;
}
void Link_ItemReset_FromOverworldThings() { // 87b107