Skip to content

Commit 31b53f8

Browse files
committed
Changed uses of scriptContext to event
1 parent d157c2d commit 31b53f8

File tree

6 files changed

+30
-47
lines changed

6 files changed

+30
-47
lines changed

ttyd-tools/rel/include/ttyd/evt_bero.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ extern "C" {
3131
// evt_bero_id_filter
3232
// evt_bero_read_mario_pera
3333
// evt_bero_get_into_info
34-
uint32_t evt_bero_get_info(void *scriptContext, uint32_t waitMode);
34+
uint32_t evt_bero_get_info(void *event, uint32_t waitMode);
3535
// evt_bero_get_now_number
3636
// evt_bero_set_now_number
3737
// evt_bero_get_info_nextarea

ttyd-tools/rel/include/ttyd/evt_sub.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ extern "C" {
99

1010
// mail_evt_gor_04_keyoff_check
1111
// irai_mail_check
12-
uint32_t evt_sub_check_intersect(void *scriptContext);
12+
uint32_t evt_sub_check_intersect(void *event);
1313
// bgm_start_wait
1414
// get_stop
1515
// set_stop

ttyd-tools/rel/source/codes.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,22 +1483,22 @@ int32_t warpToMapByString(const char *map)
14831483
return SUCCESS;
14841484
}
14851485

1486-
uint32_t Mod::setIndexWarpEntrance(void *scriptContext, uint32_t waitMode)
1486+
uint32_t Mod::setIndexWarpEntrance(void *event, uint32_t waitMode)
14871487
{
14881488
// Clear the array holding the loading zone names
14891489
clearMemory(WarpByIndex.EntranceList, sizeof(WarpByIndex.EntranceList));
14901490

14911491
// Get the start of the loading zone addresses
1492-
uint32_t ScriptContextLZAddresses = *reinterpret_cast<uint32_t *>(
1493-
reinterpret_cast<uint32_t>(scriptContext) + 0x9C);
1492+
uint32_t eventLZAddresses = *reinterpret_cast<uint32_t *>(
1493+
reinterpret_cast<uint32_t>(event) + 0x9C);
14941494

14951495
// Loop through the loading zones and get the total amount of them
1496-
uint32_t tempScriptContextAddress = ScriptContextLZAddresses;
1496+
uint32_t tempEventAddress = eventLZAddresses;
14971497
uint32_t LoadingZoneTotal = 0;
14981498

1499-
while (*reinterpret_cast<uint32_t *>(tempScriptContextAddress))
1499+
while (*reinterpret_cast<uint32_t *>(tempEventAddress))
15001500
{
1501-
tempScriptContextAddress += 0x3C;
1501+
tempEventAddress += 0x3C;
15021502
LoadingZoneTotal++;
15031503
}
15041504

@@ -1508,7 +1508,7 @@ uint32_t Mod::setIndexWarpEntrance(void *scriptContext, uint32_t waitMode)
15081508
{
15091509
tempEntranceArray[i] = reinterpret_cast<const char *>(
15101510
*reinterpret_cast<uint32_t *>(
1511-
ScriptContextLZAddresses + (i * 0x3C)));
1511+
eventLZAddresses + (i * 0x3C)));
15121512
}
15131513

15141514
// Check to see if warping by index
@@ -1525,7 +1525,7 @@ uint32_t Mod::setIndexWarpEntrance(void *scriptContext, uint32_t waitMode)
15251525
// Valid entrance chosen
15261526
ChosenEntranceName = reinterpret_cast<const char *>(
15271527
*reinterpret_cast<uint32_t *>(
1528-
ScriptContextLZAddresses + (ChosenEntrance * 0x3C)));
1528+
eventLZAddresses + (ChosenEntrance * 0x3C)));
15291529
}
15301530
else
15311531
{
@@ -1542,7 +1542,7 @@ uint32_t Mod::setIndexWarpEntrance(void *scriptContext, uint32_t waitMode)
15421542
}
15431543

15441544
// Call original function
1545-
return mPFN_evt_bero_get_info_trampoline(scriptContext, waitMode);
1545+
return mPFN_evt_bero_get_info_trampoline(event, waitMode);
15461546
}
15471547

15481548
}

ttyd-tools/rel/source/global.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace mod {
88

9-
const char *VersionNumber = "v3.0.25";
9+
const char *VersionNumber = "v3.0.26";
1010

1111
const char *RootLines[] =
1212
{

ttyd-tools/rel/source/main.cpp

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -182,49 +182,32 @@ const char *replaceJumpFallAnim(char *jumpFallString)
182182
{
183183
if (compareStringsSize(jumpFallString, "M_J_", 4))
184184
{
185-
if (compareStringToNextMap("gor_01"))
185+
const char *MapCheck = "gor_01";
186+
if (compareStringToNextMap(MapCheck))
186187
{
187-
// Return an arbitrary string
188-
const char *newString = "gor_01";
189-
190188
if (MarioFreeze)
191189
{
192-
return newString;
190+
// Return an arbitrary string
191+
return MapCheck;
193192
}
194193
else
195194
{
196195
ttyd::mario::Player *player = ttyd::mario::marioGetPtr();
197-
int32_t PosX = static_cast<int32_t>(player->playerPosition[0]);
198-
int32_t PosZ = static_cast<int32_t>(player->playerPosition[2]);
199-
200-
int32_t args[9];
201-
clearMemory(args, sizeof(args));
202-
203-
args[0] = PosX;
204-
args[1] = PosZ;
205-
args[2] = PosX + 5;
206-
args[3] = PosZ + 5;
207-
args[4] = 10;
208-
args[5] = 250;
209-
args[6] = -10;
210-
args[7] = 267;
211-
212-
*reinterpret_cast<uint32_t *>(&args[8]) = 0xFE363C80;
213-
214-
char fakeContext[0x1B0];
215-
clearMemory(fakeContext, sizeof(fakeContext));
216-
217-
*reinterpret_cast<int32_t **>(fakeContext + 0x18) = args;
218-
219-
ttyd::evt_sub::evt_sub_check_intersect(fakeContext);
220196

221-
if (*reinterpret_cast<bool *>(
222-
reinterpret_cast<uint32_t>(fakeContext) + 0x9F))
197+
int32_t MarPosX = static_cast<int32_t>(player->playerPosition[0]);
198+
if ((MarPosX >= -9) && (MarPosX <= 8))
223199
{
224-
if (player->playerPosition[1] >= 58)
200+
int32_t MarPosZ = static_cast<int32_t>(player->playerPosition[2]);
201+
if ((MarPosZ >= 245) && (MarPosZ <= 265))
225202
{
226-
MarioFreeze = true;
227-
return newString;
203+
int32_t MarPosY = static_cast<int32_t>(player->playerPosition[1]);
204+
if (MarPosY >= 59)
205+
{
206+
MarioFreeze = true;
207+
208+
// Return an arbitrary string
209+
return MapCheck;
210+
}
228211
}
229212
}
230213
}

ttyd-tools/rel/source/mod.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ void Mod::init()
8989
});
9090

9191
mPFN_evt_bero_get_info_trampoline = patch::hookFunction(
92-
ttyd::evt_bero::evt_bero_get_info, [](void *scriptContext, uint32_t waitMode)
92+
ttyd::evt_bero::evt_bero_get_info, [](void *event, uint32_t waitMode)
9393
{
94-
return gMod->setIndexWarpEntrance(scriptContext, waitMode);
94+
return gMod->setIndexWarpEntrance(event, waitMode);
9595
});
9696

9797
// Initialize typesetting early

0 commit comments

Comments
 (0)