Skip to content

Commit 74249f4

Browse files
authored
Merge pull request #17 from lunarsoap5/master
Patched Goats Minigame and adjust readFile call for gci's generated with DVD params
2 parents 9414fc4 + 4b79ed6 commit 74249f4

4 files changed

Lines changed: 41 additions & 6 deletions

File tree

GameCube/include/events.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ namespace mod::events
153153
uint16_t getPauseRupeeMax(libtp::tp::d_save::dSv_player_status_a_c* plyrStatus);
154154
uint32_t autoMashThroughText(libtp::tp::m_do_controller_pad::CPadInfo* padInfo);
155155
void* handleTransformAnywhere(libtp::tp::f_op_actor_iter::fopAcIt_JudgeFunc unk1, void* unk2);
156+
bool checkValidTransformAnywhere();
156157

157158
void performStaticASMReplacement(uint32_t memoryOffset, uint32_t value);
158159

GameCube/source/events.cpp

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ namespace mod::events
914914

915915
int32_t proc_query042(void* unk1, void* unk2, int32_t unk3)
916916
{
917-
if (transformAnywhereEnabled)
917+
if (checkValidTransformAnywhere())
918918
{
919919
// Return false to allow transforming infront of NPCs using Midna's transform option
920920
return 0;
@@ -1111,6 +1111,7 @@ namespace mod::events
11111111
void handleQuickTransform()
11121112
{
11131113
rando::Seed* seed;
1114+
using namespace libtp::tp::d_com_inf_game;
11141115
if (seed = getCurrentSeed(randomizer), !seed)
11151116
{
11161117
return;
@@ -1122,7 +1123,7 @@ namespace mod::events
11221123
}
11231124

11241125
// Ensure that Link is loaded on the map.
1125-
libtp::tp::d_a_alink::daAlink* linkMapPtr = libtp::tp::d_com_inf_game::dComIfG_gameInfo.play.mPlayer;
1126+
libtp::tp::d_a_alink::daAlink* linkMapPtr = dComIfG_gameInfo.play.mPlayer;
11261127
if (!linkMapPtr)
11271128
{
11281129
return;
@@ -1178,7 +1179,7 @@ namespace mod::events
11781179
return;
11791180
}
11801181

1181-
if (!transformAnywhereEnabled)
1182+
if (!checkValidTransformAnywhere())
11821183
{
11831184
if (daMidna_c__checkMetamorphoseEnableBase)
11841185
{
@@ -1490,7 +1491,7 @@ namespace mod::events
14901491

14911492
void* handleTransformAnywhere(libtp::tp::f_op_actor_iter::fopAcIt_JudgeFunc unk1, void* unk2)
14921493
{
1493-
if (transformAnywhereEnabled)
1494+
if (checkValidTransformAnywhere())
14941495
{
14951496
// Return nullptr to make the calling function return true
14961497
return nullptr;
@@ -1500,6 +1501,39 @@ namespace mod::events
15001501
return libtp::tp::f_op_actor_iter::fopAcIt_Judge(unk1, unk2);
15011502
}
15021503

1504+
bool checkValidTransformAnywhere()
1505+
{
1506+
using namespace libtp::data::stage;
1507+
using namespace libtp::tp::d_com_inf_game;
1508+
1509+
if (!transformAnywhereEnabled)
1510+
{
1511+
return false;
1512+
}
1513+
1514+
// Check if the player is currently playing the Goats minigame
1515+
if (libtp::tp::d_a_alink::checkStageName(allStages[StageIDs::Ordon_Ranch]))
1516+
{
1517+
switch (dComIfG_gameInfo.play.mStartStage.mLayer)
1518+
{
1519+
// Layer 4 or 5 is used when the minigame is taking place
1520+
case 4:
1521+
case 5:
1522+
{
1523+
// Return false, as the game will crash if the player is in wolf form after the minigame ends
1524+
return false;
1525+
}
1526+
default:
1527+
{
1528+
break;
1529+
}
1530+
}
1531+
}
1532+
1533+
// Return true, as the bool is set and there are no conflicting scenarios to prevent transformation
1534+
return true;
1535+
}
1536+
15031537
KEEP_FUNC void performStaticASMReplacement(uint32_t memoryOffset, uint32_t value)
15041538
{
15051539
*reinterpret_cast<uint32_t*>(memoryOffset) = value;

GameCube/subrel/boot/source/rando/seedlist.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ namespace mod::rando
123123
snprintf(filePath, sizeof(filePath), "/mod/seed/%s", currentFileName);
124124

125125
// Try to open the file and get the header data
126-
if (DVD_STATE_END != libtp::tools::ReadFile(filePath, sizeof(header), 0, &header))
126+
if (DVD_STATE_END != libtp::tools::readFile(filePath, sizeof(header), 0, &header))
127127
{
128128
#else
129129
// Try to get the status of an arbitrary file slot

GameCube/subrel/seed/source/rando/seed.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ namespace mod::rando
5656
char filePath[96];
5757
snprintf(filePath, sizeof(filePath), "/mod/seed/%s", fileName);
5858

59-
m_CARDResult = libtp::tools::ReadFile(filePath, totalSize, 0, data);
59+
m_CARDResult = libtp::tools::readFile(filePath, totalSize, 0, data);
6060
constexpr int32_t resultComparison = DVD_STATE_END;
6161
#else
6262
// The memory card should already be mounted

0 commit comments

Comments
 (0)