Skip to content

Commit 1e63aea

Browse files
committed
Stats - Bug Fix + Small Optimization
Set an additional variable when the partner's rank is being adjusted. This fixes their stats being incorrectly adjusted when equipping/unequipping badges. The flags set for when the cache for Mario's or the partner's stats should be flushed is no longer set when already in a battle.
1 parent ae6897a commit 1e63aea

File tree

1 file changed

+45
-8
lines changed

1 file changed

+45
-8
lines changed

ttyd-tools/rel/source/menufunctions.cpp

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,7 +1864,11 @@ void setMarioStatsValue(uint32_t currentMenuOption)
18641864
case SPECIAL_MOVES:
18651865
case STAR_POWER:
18661866
{
1867-
ClearCacheForBattles.MarioStatsShouldBeCleared = true;
1867+
// Only set the flag for clearing the cache if not in a battle
1868+
if (!checkForSpecificSeq(ttyd::seqdrv::SeqIndex::kBattle))
1869+
{
1870+
ClearCacheForBattles.MarioStatsShouldBeCleared = true;
1871+
}
18681872
break;
18691873
}
18701874
case BP:
@@ -1886,7 +1890,11 @@ void setMarioStatsValue(uint32_t currentMenuOption)
18861890
*reinterpret_cast<int16_t *>(PouchPtr + 0x70) = MaxHP;
18871891
}
18881892

1889-
ClearCacheForBattles.MarioStatsShouldBeCleared = true;
1893+
// Only set the flag for clearing the cache if not in a battle
1894+
if (!checkForSpecificSeq(ttyd::seqdrv::SeqIndex::kBattle))
1895+
{
1896+
ClearCacheForBattles.MarioStatsShouldBeCleared = true;
1897+
}
18901898
break;
18911899
}
18921900
case MARIO_MAX_FP:
@@ -1902,7 +1910,11 @@ void setMarioStatsValue(uint32_t currentMenuOption)
19021910
*reinterpret_cast<int16_t *>(PouchPtr + 0x74) = MaxFP;
19031911
}
19041912

1905-
ClearCacheForBattles.MarioStatsShouldBeCleared = true;
1913+
// Only set the flag for clearing the cache if not in a battle
1914+
if (!checkForSpecificSeq(ttyd::seqdrv::SeqIndex::kBattle))
1915+
{
1916+
ClearCacheForBattles.MarioStatsShouldBeCleared = true;
1917+
}
19061918
break;
19071919
}
19081920
case MARIO_LEVEL:
@@ -1917,7 +1929,12 @@ void setMarioStatsValue(uint32_t currentMenuOption)
19171929
}
19181930
19191931
*reinterpret_cast<int16_t *>(PouchPtr + 0x88) = NewRank;*/
1920-
ClearCacheForBattles.MarioStatsShouldBeCleared = true;
1932+
1933+
// Only set the flag for clearing the cache if not in a battle
1934+
if (!checkForSpecificSeq(ttyd::seqdrv::SeqIndex::kBattle))
1935+
{
1936+
ClearCacheForBattles.MarioStatsShouldBeCleared = true;
1937+
}
19211938
break;
19221939
}
19231940
case MAX_STAR_POWER:
@@ -1931,7 +1948,11 @@ void setMarioStatsValue(uint32_t currentMenuOption)
19311948
*reinterpret_cast<int16_t *>(PouchPtr + 0x7A) = MaxSP;
19321949
}
19331950

1934-
ClearCacheForBattles.MarioStatsShouldBeCleared = true;
1951+
// Only set the flag for clearing the cache if not in a battle
1952+
if (!checkForSpecificSeq(ttyd::seqdrv::SeqIndex::kBattle))
1953+
{
1954+
ClearCacheForBattles.MarioStatsShouldBeCleared = true;
1955+
}
19351956
break;
19361957
}
19371958
default:
@@ -1954,7 +1975,11 @@ void setPartnerStatsValue(uint32_t currentMenuOption)
19541975
*reinterpret_cast<int16_t *>(PartnerEnabledAddress + 0x6) =
19551976
static_cast<int16_t>(tempMenuSecondaryValue);
19561977

1957-
ClearCacheForBattles.PartnerStatsShouldBeCleared = true;
1978+
// Only set the flag for clearing the cache if not in a battle
1979+
if (!checkForSpecificSeq(ttyd::seqdrv::SeqIndex::kBattle))
1980+
{
1981+
ClearCacheForBattles.PartnerStatsShouldBeCleared = true;
1982+
}
19581983
break;
19591984
}
19601985
case PARTNER_MAX_HP:
@@ -1966,7 +1991,11 @@ void setPartnerStatsValue(uint32_t currentMenuOption)
19661991
*reinterpret_cast<int16_t *>(PartnerEnabledAddress + 0x4) =
19671992
static_cast<int16_t>(tempMenuSecondaryValue);
19681993

1969-
ClearCacheForBattles.PartnerStatsShouldBeCleared = true;
1994+
// Only set the flag for clearing the cache if not in a battle
1995+
if (!checkForSpecificSeq(ttyd::seqdrv::SeqIndex::kBattle))
1996+
{
1997+
ClearCacheForBattles.PartnerStatsShouldBeCleared = true;
1998+
}
19701999
break;
19712000
}
19722001
case PARTNER_RANK:
@@ -1978,7 +2007,15 @@ void setPartnerStatsValue(uint32_t currentMenuOption)
19782007
*reinterpret_cast<int16_t *>(PartnerEnabledAddress + 0xC) =
19792008
static_cast<int16_t>(tempMenuSecondaryValue);
19802009

1981-
ClearCacheForBattles.PartnerStatsShouldBeCleared = true;
2010+
// Set the rank used to verify the partner's stats when equipping/unequipping badges
2011+
*reinterpret_cast<int16_t *>(PartnerEnabledAddress + 0x8) =
2012+
static_cast<int16_t>(tempMenuSecondaryValue);
2013+
2014+
// Only set the flag for clearing the cache if not in a battle
2015+
if (!checkForSpecificSeq(ttyd::seqdrv::SeqIndex::kBattle))
2016+
{
2017+
ClearCacheForBattles.PartnerStatsShouldBeCleared = true;
2018+
}
19822019
break;
19832020
}
19842021
default:

0 commit comments

Comments
 (0)