From 550774d96b8e225f77cb89e8ece5ed65acbab1ad Mon Sep 17 00:00:00 2001 From: Lilia <58743698+lilousky@users.noreply.github.com> Date: Sun, 29 Sep 2024 22:45:01 -0400 Subject: [PATCH 1/4] Track check feature Uses the hash of the enemy points section to determine players are on the same track as the host --- .github/workflows/main.yml | 2 +- .gitignore | 2 ++ src/include/dwc.h | 5 ++++ src/include/hidenseek.h | 4 +-- src/include/inputdata.h | 2 +- src/include/itemholder.h | 2 +- src/include/jgpt.h | 4 +-- src/include/killdata.h | 4 +-- src/include/menudata.h | 4 +-- src/include/musichandler.h | 2 +- src/include/os.h | 7 +++++ src/include/player.h | 2 +- src/include/racedata.h | 2 +- src/include/raceinfo.h | 2 +- src/include/racemodeonline.h | 33 +++++++++++++++++++++ src/include/racepacket.h | 2 +- src/include/rknetcontroller.h | 2 +- src/include/screentext.h | 2 +- src/include/selecthandler.h | 2 +- src/include/utils.h | 6 ++-- src/include/vec.h | 2 +- src/make.py | 5 ++-- src/payload/main.c | 7 +++-- src/payload/main/battlefixes.c | 12 ++++---- src/payload/main/hnsdata.c | 10 +++---- src/payload/main/hudedits.c | 8 ++--- src/payload/main/invisibility.c | 12 ++++---- src/payload/main/itemhit.c | 18 ++++++------ src/payload/main/killdata.c | 6 ++-- src/payload/main/noclip.c | 4 +-- src/payload/main/spectator.c | 10 +++---- src/payload/main/tag.c | 8 ++--- src/payload/main/timer.c | 16 +++++----- src/payload/main/trackcheck.S | 12 ++++++++ src/payload/main/trackcheck.c | 52 +++++++++++++++++++++++++++++++++ src/rmce.ld | 12 ++++++++ src/rmcj.ld | 12 ++++++++ src/rmck.ld | 12 ++++++++ src/rmcp.ld | 12 ++++++++ 39 files changed, 242 insertions(+), 79 deletions(-) create mode 100644 src/include/dwc.h create mode 100644 src/include/os.h create mode 100644 src/include/racemodeonline.h create mode 100644 src/payload/main/trackcheck.S create mode 100644 src/payload/main/trackcheck.c diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 64d6bd0..a03cf00 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -33,7 +33,7 @@ jobs: - name: Compile run: | - PATH=$(pwd)/devkitpro/devkitPPC/bin:$PATH DEVKITPPC=$(pwd)/devkitpro/devkitPPC DEVKITPRO=$(pwd)/devkitpro + cp -r $(pwd)/devkitpro/devkitPPC devkitPPC/ cd src python3 make.py diff --git a/.gitignore b/.gitignore index 686e0c6..24bd99d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ src/bin files/UIPatches/*.szs __pycache__/ *.zip +devkitPPC/ +.vscode/ diff --git a/src/include/dwc.h b/src/include/dwc.h new file mode 100644 index 0000000..577dba3 --- /dev/null +++ b/src/include/dwc.h @@ -0,0 +1,5 @@ +#pragma once +#include "common.h" + +int DWC_CloseConnectionHard(u8 playerAid); +bool DWC_IsServerMyself(); diff --git a/src/include/hidenseek.h b/src/include/hidenseek.h index 86666d0..c572068 100644 --- a/src/include/hidenseek.h +++ b/src/include/hidenseek.h @@ -1,8 +1,8 @@ #pragma once -#include +#include "common.h" typedef struct { - u8 isStopped, isSeeker, isRealSeeker, unused; + u8 isStopped, isSeeker, isRealSeeker, doneTrackCheck; } HideNSeekPlayer; typedef struct { diff --git a/src/include/inputdata.h b/src/include/inputdata.h index df4f0e9..b933b71 100644 --- a/src/include/inputdata.h +++ b/src/include/inputdata.h @@ -1,5 +1,5 @@ #pragma once -#include +#include "common.h" // Documentation by Seeky, SwareJonge and _tZ diff --git a/src/include/itemholder.h b/src/include/itemholder.h index 3982e9e..9851832 100644 --- a/src/include/itemholder.h +++ b/src/include/itemholder.h @@ -1,5 +1,5 @@ #pragma once -#include +#include "common.h" typedef struct { u8 unk[0x8C]; diff --git a/src/include/jgpt.h b/src/include/jgpt.h index de1f266..279f9a8 100644 --- a/src/include/jgpt.h +++ b/src/include/jgpt.h @@ -1,6 +1,6 @@ #pragma once -#include -#include +#include "common.h" +#include "vec.h" typedef struct { VEC3 pos, rot; diff --git a/src/include/killdata.h b/src/include/killdata.h index b408544..50eb7f2 100644 --- a/src/include/killdata.h +++ b/src/include/killdata.h @@ -1,6 +1,6 @@ #pragma once -#include -#include +#include "common.h" +#include "screentext.h" extern void* GetBMGPlayer(u16 pid); extern void ApplyKillData(screenText* textData); diff --git a/src/include/menudata.h b/src/include/menudata.h index 08a99d2..ee2d644 100644 --- a/src/include/menudata.h +++ b/src/include/menudata.h @@ -1,6 +1,6 @@ #pragma once -#include -#include +#include "common.h" +#include "inputdata.h" typedef struct { u32 controllerInfo, unk, wantsController; diff --git a/src/include/musichandler.h b/src/include/musichandler.h index 5f75d79..fc330c9 100644 --- a/src/include/musichandler.h +++ b/src/include/musichandler.h @@ -1,5 +1,5 @@ #pragma once -#include +#include "common.h" typedef struct { u8 unk[0x40]; diff --git a/src/include/os.h b/src/include/os.h new file mode 100644 index 0000000..b184519 --- /dev/null +++ b/src/include/os.h @@ -0,0 +1,7 @@ +#pragma once + +#include "common.h" + +bool OSDisableInterrupts(); +bool OSRestoreInterrupts(bool); +void OSReport(const char *format, ...); diff --git a/src/include/player.h b/src/include/player.h index 0f60447..acee3b4 100644 --- a/src/include/player.h +++ b/src/include/player.h @@ -1,5 +1,5 @@ #pragma once -#include +#include "common.h" // Documentation by stebler, SwareJonge and 1superchip diff --git a/src/include/racedata.h b/src/include/racedata.h index 9d0fad1..893cdc3 100644 --- a/src/include/racedata.h +++ b/src/include/racedata.h @@ -1,5 +1,5 @@ #pragma once -#include +#include "common.h" // Documentation by Seeky, TheLordScruffy, WhatIsLoaf and riidefi diff --git a/src/include/raceinfo.h b/src/include/raceinfo.h index aadca47..d3d1b78 100644 --- a/src/include/raceinfo.h +++ b/src/include/raceinfo.h @@ -1,5 +1,5 @@ #pragma once -#include +#include "common.h" // Documentation by Seeky, _tZ, Kevin, Leseratte, stebler and Melg diff --git a/src/include/racemodeonline.h b/src/include/racemodeonline.h new file mode 100644 index 0000000..6aad2db --- /dev/null +++ b/src/include/racemodeonline.h @@ -0,0 +1,33 @@ +#pragma once +#include "common.h" +#include "raceinfo.h" + +typedef struct { + u8 packedBits[15]; + u8 _F; + u8 localPlayerId[2]; + u8 _12; + u8 localPlayerCount; + u32 timeSinceLeaderFinish; + u32 minimumRaceFinishTime; + bool disconnecting; + u8 _1D; + u16 idleTimers[2]; + u16 idleCountdowns[2]; + u16 _26; +} RaceHeader2VS; + +typedef struct { + void* vtable; + _Raceinfo *raceinfo; +} RaceMode; + +typedef struct { + RaceMode inherit; + u8 unk[0xF0]; + RaceHeader2VS outPacket; + u8 unk2[0x54]; +} RaceModeOnlineVs; // Total size 0x174 + +RaceHeader2VS* GetRaceHeader2Buffer(u32 param_1, u32 playerId); +void unk80653d78(u32 param_1) __attribute__((noreturn)); diff --git a/src/include/racepacket.h b/src/include/racepacket.h index 853da02..89e181f 100644 --- a/src/include/racepacket.h +++ b/src/include/racepacket.h @@ -1,5 +1,5 @@ #pragma once -#include +#include "common.h" typedef struct { u32 checksum[2]; diff --git a/src/include/rknetcontroller.h b/src/include/rknetcontroller.h index 7140de1..b88f523 100644 --- a/src/include/rknetcontroller.h +++ b/src/include/rknetcontroller.h @@ -1,5 +1,5 @@ #pragma once -#include +#include "common.h" // Documentation by Seeky diff --git a/src/include/screentext.h b/src/include/screentext.h index 54dbd7f..98cb80e 100644 --- a/src/include/screentext.h +++ b/src/include/screentext.h @@ -1,5 +1,5 @@ #pragma once -#include +#include "common.h" // Documentation by Kevin diff --git a/src/include/selecthandler.h b/src/include/selecthandler.h index f2f619c..7cff0c6 100644 --- a/src/include/selecthandler.h +++ b/src/include/selecthandler.h @@ -1,5 +1,5 @@ #pragma once -#include +#include "common.h" // Documentation by Seeky diff --git a/src/include/utils.h b/src/include/utils.h index 8574a45..911c34b 100644 --- a/src/include/utils.h +++ b/src/include/utils.h @@ -1,7 +1,7 @@ #pragma once -#include -#include -#include +#include "common.h" +#include "player.h" +#include "raceinfo.h" int UtilRandint(int lo, int hi); void UtilRandomSeed(int seed); diff --git a/src/include/vec.h b/src/include/vec.h index e488998..08f0873 100644 --- a/src/include/vec.h +++ b/src/include/vec.h @@ -1,5 +1,5 @@ #pragma once -#include +#include "common.h" typedef struct { float x, y, z; diff --git a/src/make.py b/src/make.py index 99074eb..5ffd167 100644 --- a/src/make.py +++ b/src/make.py @@ -4,8 +4,8 @@ from elftools.elf.elffile import ELFFile as elf # Locate various things -gcc = 'powerpc-eabi-gcc' -objcopy = 'powerpc-eabi-objcopy' +gcc = os.path.join("..", "devkitPPC", "bin", "powerpc-eabi-gcc") +objcopy = os.path.join("..", "devkitPPC", "bin", "powerpc-eabi-objcopy") destdir = 'bin' # Initialize variables @@ -73,6 +73,7 @@ def build(isBootStrap: bool): print('Insert', hex(instruction), 'at', hex(startHook)) # Convert to binary + print(f'Converting {region} to binary...') c = call([objcopy, '-O', 'binary', '-R', '.eh_frame', '-R', '.eh_frame_hdr', outputfile + 'o', outputfile + 'bin']) if c != 0: print('Build failed!') diff --git a/src/payload/main.c b/src/payload/main.c index 7cd3af2..de0e122 100644 --- a/src/payload/main.c +++ b/src/payload/main.c @@ -1,5 +1,4 @@ #include "common.h" - // Forward declarations void CupScreenPatch(); void BattleCupScreenPatch(); @@ -143,7 +142,7 @@ void loadCodes() { directWriteBranch(GuestSendHook, GuestSend, false); directWriteBranch(HostCheckHook, HostCheck, false); directWriteBranch(HostCheckHelperHook, HostCheckHelper, true); - directWrite8(Version, 7); + directWrite8(Version, 8); // Improved Position Interpolation (by stebler) directWrite32(NoInterpolation, 0x3F800000); @@ -345,6 +344,10 @@ void loadCodes() { directWriteBranch(TagDistanceHook2, TagDistanceFunc, true); directWriteBranch(TagShowHook, HandleTags, true); + // Track Check (by CLF78 and Lami) + directWriteBranch(InsertTrackIdentHook, InsertTrackIdent, false); + directWriteBranch(CheckTrackIdentHook, CheckTrackIdent, false); + // Disable Track Music (by CosmoCourtney) if (NoMusic == 1) { directWrite32(NoMusicHook, 0x38600000); diff --git a/src/payload/main/battlefixes.c b/src/payload/main/battlefixes.c index 8fb9a52..bfe957c 100644 --- a/src/payload/main/battlefixes.c +++ b/src/payload/main/battlefixes.c @@ -1,9 +1,9 @@ -#include -#include -#include -#include -#include -#include +#include "common.h" +#include "hidenseek.h" +#include "jgpt.h" +#include "raceinfo.h" +#include "player.h" +#include "vec.h" #define DELFINOPIERCRC 0x72836BEE diff --git a/src/payload/main/hnsdata.c b/src/payload/main/hnsdata.c index c36c8f4..1226ce8 100644 --- a/src/payload/main/hnsdata.c +++ b/src/payload/main/hnsdata.c @@ -1,8 +1,8 @@ -#include -#include -#include -#include -#include +#include "common.h" +#include "hidenseek.h" +#include "racedata.h" +#include "rknetcontroller.h" +#include "utils.h" int pidHelper(char currentpid, char prevaid1, char prevaid2, int index) { diff --git a/src/payload/main/hudedits.c b/src/payload/main/hudedits.c index b58bc5d..6285492 100644 --- a/src/payload/main/hudedits.c +++ b/src/payload/main/hudedits.c @@ -1,7 +1,7 @@ -#include -#include -#include -#include +#include "common.h" +#include "hidenseek.h" +#include "racedata.h" +#include "raceinfo.h" int ScoreSound(int score) { diff --git a/src/payload/main/invisibility.c b/src/payload/main/invisibility.c index 93fa50a..8b0058c 100644 --- a/src/payload/main/invisibility.c +++ b/src/payload/main/invisibility.c @@ -1,9 +1,9 @@ -#include -#include -#include -#include -#include -#include +#include "common.h" +#include "hidenseek.h" +#include "racedata.h" +#include "racepacket.h" +#include "rknetcontroller.h" +#include "utils.h" void InvisibilityFunc(RacePacket* packet, int length, int aid) { diff --git a/src/payload/main/itemhit.c b/src/payload/main/itemhit.c index 9eda34b..89ed878 100644 --- a/src/payload/main/itemhit.c +++ b/src/payload/main/itemhit.c @@ -1,12 +1,12 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "common.h" +#include "hidenseek.h" +#include "killdata.h" +#include "musichandler.h" +#include "player.h" +#include "racedata.h" +#include "racepacket.h" +#include "rknetcontroller.h" +#include "utils.h" void PlayerKiller(char pid) { diff --git a/src/payload/main/killdata.c b/src/payload/main/killdata.c index 61513b2..da689b3 100644 --- a/src/payload/main/killdata.c +++ b/src/payload/main/killdata.c @@ -1,6 +1,6 @@ -#include -#include -#include +#include "common.h" +#include "killdata.h" +#include "screentext.h" void AddNewKillData(u16 type, u16 int1, u16 int2) { diff --git a/src/payload/main/noclip.c b/src/payload/main/noclip.c index 525d515..f3d1a7a 100644 --- a/src/payload/main/noclip.c +++ b/src/payload/main/noclip.c @@ -1,5 +1,5 @@ -#include -#include +#include "hidenseek.h" +#include "player.h" bool NoClip(PlayerPointers** player1) { register PlayerSub18* player2 asm("r30"); diff --git a/src/payload/main/spectator.c b/src/payload/main/spectator.c index 0b80087..e54cdac 100644 --- a/src/payload/main/spectator.c +++ b/src/payload/main/spectator.c @@ -1,8 +1,8 @@ -#include -#include -#include -#include -#include +#include "common.h" +#include "hidenseek.h" +#include "inputdata.h" +#include "menudata.h" +#include "raceinfo.h" // Main func int SpectatorModeMain(char ogpid) { diff --git a/src/payload/main/tag.c b/src/payload/main/tag.c index 959f274..7b646c0 100644 --- a/src/payload/main/tag.c +++ b/src/payload/main/tag.c @@ -1,7 +1,7 @@ -#include -#include -#include -#include +#include "common.h" +#include "hidenseek.h" +#include "racedata.h" +#include "utils.h" void HandleTags(void* something, int pid) { diff --git a/src/payload/main/timer.c b/src/payload/main/timer.c index e4fb4c1..1bba8ff 100644 --- a/src/payload/main/timer.c +++ b/src/payload/main/timer.c @@ -1,11 +1,11 @@ -#include -#include -#include -#include -#include -#include -#include -#include +#include "common.h" +#include "hidenseek.h" +#include "killdata.h" +#include "musichandler.h" +#include "player.h" +#include "racedata.h" +#include "raceinfo.h" +#include "utils.h" // External timer values extern u32 TimerVals[3]; diff --git a/src/payload/main/trackcheck.S b/src/payload/main/trackcheck.S new file mode 100644 index 0000000..ceb04de --- /dev/null +++ b/src/payload/main/trackcheck.S @@ -0,0 +1,12 @@ +.include "asm_setup.S" + +.extern DoInsertTrackIdent, unk80653d78 +.global InsertTrackIdent + +InsertTrackIdent: +mflr r9 +stw r0, 0x110(r3) # Original instruction +b DoInsertTrackIdent +mtlr r9 +b unk80653d78 + diff --git a/src/payload/main/trackcheck.c b/src/payload/main/trackcheck.c new file mode 100644 index 0000000..ede31e1 --- /dev/null +++ b/src/payload/main/trackcheck.c @@ -0,0 +1,52 @@ +#include "common.h" +#include "dwc.h" +#include "hidenseek.h" +#include "os.h" +#include "racedata.h" +#include "racemodeonline.h" +#include "rknetcontroller.h" + +extern u32 ptr_miscPacketHandler; // if this is a pointer shouldn't i be defining it as such? +bool finishedTrackCheck; + +void DoInsertTrackIdent(RaceModeOnlineVs *RaceModeOnlineVs) { + if(!DWC_IsServerMyself()){ + OSReport("ENPTCRC: %x\n", ENPTCRC); + RaceModeOnlineVs->outPacket.minimumRaceFinishTime = ENPTCRC; // Replace unused field with CRC32 of the ENPT section for the current track + } + return; +} + +void CheckTrackIdent() { + if(DWC_IsServerMyself()){ + u8 playerId; + OSReport("Racedata->main.scenarios[0].playerCount: %x\n", Racedata->main.scenarios[0].playerCount); + for (playerId = 0; playerId < Racedata->main.scenarios[0].playerCount; playerId++) { + if (HideNSeekData.players[RKNetController->aidsToPids[playerId]].doneTrackCheck) { + OSReport("Player %x has already checked track ident\n", playerId); + continue; + } + OSReport("Checking Track Ident for %x\n", playerId); + OSReport("Player Type: %x\n", Racedata->main.scenarios->players[playerId].playerType); + if (Racedata->main.scenarios->players[playerId].playerType == PLAYER_REAL_LOCAL) { + OSReport("Player %x is local\n", playerId); + continue; + } + RaceHeader2VS* RH2 = GetRaceHeader2Buffer(ptr_miscPacketHandler, playerId); + OSReport("Player returned %x, expecting %x\n", RH2->minimumRaceFinishTime, ENPTCRC); + if (RH2->minimumRaceFinishTime == 0) { + OSReport("Player %x has not sent track ident\n", playerId); + continue; + } + if (RH2->minimumRaceFinishTime != ENPTCRC) { + OSReport("Player %x has a different track\n", playerId); + bool ret = OSDisableInterrupts(); + DWC_CloseConnectionHard(RKNetController->aidsToPids[playerId]); + OSRestoreInterrupts(ret); + } + HideNSeekData.players[RKNetController->aidsToPids[playerId]].doneTrackCheck = 1; + } + + } + return; +} \ No newline at end of file diff --git a/src/rmce.ld b/src/rmce.ld index 96900d4..2d8cca6 100644 --- a/src/rmce.ld +++ b/src/rmce.ld @@ -13,6 +13,13 @@ SECTIONS { PSVECSquareDistance = 0x8019AD40; + DWC_IsServerMyself = 0x800d26c0; + DWC_CloseConnectionHard = 0x800D1F60; + GetRaceHeader2Buffer = 0x8064f830; + OSDisableInterrupts = 0x801a650c; + OSRestoreInterrupts = 0x801a6534; + ptr_miscPacketHandler = 0x809bd790; + NETSHA1Init = 0x801D2454; NETSHA1Update = 0x801D24A4; NETSHA1GetDigest = 0x801D2558; @@ -347,4 +354,9 @@ SECTIONS { PlayAnim = 0x8060B4FC; TeamLineColors = 0x808A44CC; ZeroFloat = 0x808A4410; + + /* Track Check */ + InsertTrackIdentHook = 0x80538f34; + CheckTrackIdentHook = 0x80539f60; + unk80653d78 = 0x8064f8f0; } diff --git a/src/rmcj.ld b/src/rmcj.ld index f507303..d1d14f3 100644 --- a/src/rmcj.ld +++ b/src/rmcj.ld @@ -13,6 +13,13 @@ SECTIONS { PSVECSquareDistance = 0x8019AD00; + DWC_IsServerMyself = 0x800d2680; + DWC_CloseConnectionHard = 0x800D1F20; + GetRaceHeader2Buffer = 0x80653324; + OSDisableInterrupts = 0x801a64cc; + OSRestoreInterrupts = 0x801a64f4; + ptr_miscPacketHandler = 0x809c0fb0; + NETSHA1Init = 0x801D2414; NETSHA1Update = 0x801D2464; NETSHA1GetDigest = 0x801D2518; @@ -347,4 +354,9 @@ SECTIONS { PlayAnim = 0x8063BF88; TeamLineColors = 0x808A8F54; ZeroFloat = 0x808A8E98; + + /* Track Check */ + InsertTrackIdentHook = 0x8053ddf0; + CheckTrackIdentHook = 0x8053ee1c; + unk80653d78 = 0x806533e4; } diff --git a/src/rmck.ld b/src/rmck.ld index aced253..9839b09 100644 --- a/src/rmck.ld +++ b/src/rmck.ld @@ -13,6 +13,13 @@ SECTIONS { PSVECSquareDistance = 0x8019B13C; + DWC_IsServerMyself = 0x800d27c0; + DWC_CloseConnectionHard = 0x800d2060; + GetRaceHeader2Buffer = 0x80641fd0; + OSDisableInterrupts = 0x801a6908; + OSRestoreInterrupts = 0x801a6930; + ptr_miscPacketHandler = 0x809b0590; + NETSHA1Init = 0x801D2850; NETSHA1Update = 0x801D28A0; NETSHA1GetDigest = 0x801D2954; @@ -347,4 +354,9 @@ SECTIONS { PlayAnim = 0x8062AC34; TeamLineColors = 0x80898254; ZeroFloat = 0x80898198; + + /* Track Check */ + InsertTrackIdentHook = 0x8052c4c8; + CheckTrackIdentHook = 0x8052d4f4; + unk80653d78 = 0x80642090; } diff --git a/src/rmcp.ld b/src/rmcp.ld index a785268..45e671e 100644 --- a/src/rmcp.ld +++ b/src/rmcp.ld @@ -13,6 +13,13 @@ SECTIONS { PSVECSquareDistance = 0x8019ADE0; + DWC_IsServerMyself = 0x800d2760; + DWC_CloseConnectionHard = 0x800D2000; + GetRaceHeader2Buffer = 0x80653cb8; + OSDisableInterrupts = 0x801a65ac; + OSRestoreInterrupts = 0x801a65d4; + ptr_miscPacketHandler = 0x809c1f50; + NETSHA1Init = 0x801D24F4; NETSHA1Update = 0x801D2544; NETSHA1GetDigest = 0x801D25F8; @@ -347,4 +354,9 @@ SECTIONS { PlayAnim = 0x8063C91C; TeamLineColors = 0x808A9DF4; ZeroFloat = 0x808A9D38; + + /* Track Check */ + InsertTrackIdentHook = 0x8053e470; + CheckTrackIdentHook = 0x8053f49c; + unk80653d78 = 0x80653d78; } From dbf7e74eaa544263b8e8f6da265ad9a0101fbad3 Mon Sep 17 00:00:00 2001 From: Lilia <58743698+lilousky@users.noreply.github.com> Date: Sat, 16 Nov 2024 02:33:43 -0500 Subject: [PATCH 2/4] Cleanup Actually names symbol, removes debug logging, updates actions --- .github/workflows/main.yml | 4 ++-- src/include/racemodeonline.h | 1 - src/payload/main/trackcheck.S | 4 ++-- src/payload/main/trackcheck.c | 9 --------- src/rmce.ld | 2 +- src/rmcj.ld | 2 +- src/rmck.ld | 2 +- src/rmcp.ld | 2 +- 8 files changed, 8 insertions(+), 18 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a03cf00..a8aa7d0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,11 +7,11 @@ jobs: runs-on: ubuntu-20.04 timeout-minutes: 20 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Cache id: cache-1 - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: cache key: ${{ runner.os }}-cache-33 diff --git a/src/include/racemodeonline.h b/src/include/racemodeonline.h index 6aad2db..812b2cf 100644 --- a/src/include/racemodeonline.h +++ b/src/include/racemodeonline.h @@ -30,4 +30,3 @@ typedef struct { } RaceModeOnlineVs; // Total size 0x174 RaceHeader2VS* GetRaceHeader2Buffer(u32 param_1, u32 playerId); -void unk80653d78(u32 param_1) __attribute__((noreturn)); diff --git a/src/payload/main/trackcheck.S b/src/payload/main/trackcheck.S index ceb04de..2e6aef7 100644 --- a/src/payload/main/trackcheck.S +++ b/src/payload/main/trackcheck.S @@ -1,6 +1,6 @@ .include "asm_setup.S" -.extern DoInsertTrackIdent, unk80653d78 +.extern DoInsertTrackIdent, clearSendRH2 .global InsertTrackIdent InsertTrackIdent: @@ -8,5 +8,5 @@ mflr r9 stw r0, 0x110(r3) # Original instruction b DoInsertTrackIdent mtlr r9 -b unk80653d78 +b clearSendRH2 diff --git a/src/payload/main/trackcheck.c b/src/payload/main/trackcheck.c index ede31e1..b946fd2 100644 --- a/src/payload/main/trackcheck.c +++ b/src/payload/main/trackcheck.c @@ -11,7 +11,6 @@ bool finishedTrackCheck; void DoInsertTrackIdent(RaceModeOnlineVs *RaceModeOnlineVs) { if(!DWC_IsServerMyself()){ - OSReport("ENPTCRC: %x\n", ENPTCRC); RaceModeOnlineVs->outPacket.minimumRaceFinishTime = ENPTCRC; // Replace unused field with CRC32 of the ENPT section for the current track } return; @@ -20,26 +19,18 @@ void DoInsertTrackIdent(RaceModeOnlineVs *RaceModeOnlineVs) { void CheckTrackIdent() { if(DWC_IsServerMyself()){ u8 playerId; - OSReport("Racedata->main.scenarios[0].playerCount: %x\n", Racedata->main.scenarios[0].playerCount); for (playerId = 0; playerId < Racedata->main.scenarios[0].playerCount; playerId++) { if (HideNSeekData.players[RKNetController->aidsToPids[playerId]].doneTrackCheck) { - OSReport("Player %x has already checked track ident\n", playerId); continue; } - OSReport("Checking Track Ident for %x\n", playerId); - OSReport("Player Type: %x\n", Racedata->main.scenarios->players[playerId].playerType); if (Racedata->main.scenarios->players[playerId].playerType == PLAYER_REAL_LOCAL) { - OSReport("Player %x is local\n", playerId); continue; } RaceHeader2VS* RH2 = GetRaceHeader2Buffer(ptr_miscPacketHandler, playerId); - OSReport("Player returned %x, expecting %x\n", RH2->minimumRaceFinishTime, ENPTCRC); if (RH2->minimumRaceFinishTime == 0) { - OSReport("Player %x has not sent track ident\n", playerId); continue; } if (RH2->minimumRaceFinishTime != ENPTCRC) { - OSReport("Player %x has a different track\n", playerId); bool ret = OSDisableInterrupts(); DWC_CloseConnectionHard(RKNetController->aidsToPids[playerId]); OSRestoreInterrupts(ret); diff --git a/src/rmce.ld b/src/rmce.ld index 2d8cca6..9b4c669 100644 --- a/src/rmce.ld +++ b/src/rmce.ld @@ -358,5 +358,5 @@ SECTIONS { /* Track Check */ InsertTrackIdentHook = 0x80538f34; CheckTrackIdentHook = 0x80539f60; - unk80653d78 = 0x8064f8f0; + clearSendRH2 = 0x8064f8f0; } diff --git a/src/rmcj.ld b/src/rmcj.ld index d1d14f3..ced9581 100644 --- a/src/rmcj.ld +++ b/src/rmcj.ld @@ -358,5 +358,5 @@ SECTIONS { /* Track Check */ InsertTrackIdentHook = 0x8053ddf0; CheckTrackIdentHook = 0x8053ee1c; - unk80653d78 = 0x806533e4; + clearSendRH2 = 0x806533e4; } diff --git a/src/rmck.ld b/src/rmck.ld index 9839b09..0ea0e39 100644 --- a/src/rmck.ld +++ b/src/rmck.ld @@ -358,5 +358,5 @@ SECTIONS { /* Track Check */ InsertTrackIdentHook = 0x8052c4c8; CheckTrackIdentHook = 0x8052d4f4; - unk80653d78 = 0x80642090; + clearSendRH2 = 0x80642090; } diff --git a/src/rmcp.ld b/src/rmcp.ld index 45e671e..9d0cf60 100644 --- a/src/rmcp.ld +++ b/src/rmcp.ld @@ -358,5 +358,5 @@ SECTIONS { /* Track Check */ InsertTrackIdentHook = 0x8053e470; CheckTrackIdentHook = 0x8053f49c; - unk80653d78 = 0x80653d78; + clearSendRH2 = 0x80653d78; } From eeb2da1a0f0b11e2b611a3cc45b766abe521a19e Mon Sep 17 00:00:00 2001 From: Lilia <58743698+lilousky@users.noreply.github.com> Date: Sat, 16 Nov 2024 21:16:34 -0500 Subject: [PATCH 3/4] Update assets --- files/UIPatches/Global/message/Manu.bmg | Bin 91392 -> 91392 bytes files/UIPatches/Global/message/StaffRole.bmg | Bin 5536 -> 5536 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/files/UIPatches/Global/message/Manu.bmg b/files/UIPatches/Global/message/Manu.bmg index 366c4638fb3647745924f5fdffd76dfcf91284eb..becfc509acb7726c121383c3f3d0d61b06927ef8 100644 GIT binary patch delta 19 ZcmZoT#o7QwTNvY=8BMk)I5RF#1OQ7?2FCyZ delta 19 ZcmZoT#o7QwTNvY=8I89mI5RF#1OQ7*2F3sY diff --git a/files/UIPatches/Global/message/StaffRole.bmg b/files/UIPatches/Global/message/StaffRole.bmg index 597155073f36c4450e4e49ea5b5e1b326dd7bbf5..fe5103905f89e7de1e9a5ceb64651b92139e84ac 100644 GIT binary patch delta 329 zcmZ3Wy+C`zXU6(xj0_;a#Q>$%ptKW|PJ+^PPlVPI1 zJzoJ>UYmh$8C2mB2+c17rEQ?}1PCn4dt00@&E AMgRZ+ delta 327 zcmZ3Wy+C`zXU6&)j0_;a`3XXENkC~6C>;W&3!rotl%4~n??CAv5SkmRpBt*5I}0j4 z2}+-U(jOpnJr5s*!D9xcW1w^klwJd+uR!Tv5SmvBO1nVm94HNS81E4%AF7@Y>M%a2 xdcGvEyfy>h42VL$Z4jED4NB`l=_Uv*5U^Q>`7`HcS>DHNETACU{7rZjBLIpI9{2zN From 4b1642b9d677192c2112ef5cf5544000ad234d40 Mon Sep 17 00:00:00 2001 From: Lilia <58743698+lilousky@users.noreply.github.com> Date: Sun, 17 Nov 2024 20:15:13 -0500 Subject: [PATCH 4/4] Hook better, start checking after the countdown --- build/ISO/Build.bat | 2 +- build/Riivo/riivolution/hns.xml | 2 +- src/include/raceinfo.h | 18 ++++++++++-------- src/include/racemodeonline.h | 1 + src/payload/main/trackcheck.S | 12 ------------ src/payload/main/trackcheck.c | 12 +++++++----- 6 files changed, 20 insertions(+), 27 deletions(-) delete mode 100644 src/payload/main/trackcheck.S diff --git a/build/ISO/Build.bat b/build/ISO/Build.bat index 0040d9f..c50f6a8 100644 --- a/build/ISO/Build.bat +++ b/build/ISO/Build.bat @@ -107,7 +107,7 @@ echo. SET /P FRAMERATE=Force 30 FPS? (Y/N): IF /i %FRAMERATE%==Y (wit\wit.exe dolpatch mkw.d/sys/main.dol 8000400F=01 -q) ELSE (wit\wit.exe dolpatch mkw.d/sys/main.dol 8000400F=00 -q) -wit\wit.exe dolpatch mkw.d/sys/main.dol 8000629C=4BFFDF4C load=80004010,hns/Loader.bin -q +wit\wit.exe dolpatch mkw.d/sys/main.dol 8000629C=4BFFDF58 load=80004010,hns/Loader.bin -q echo. echo Format Selection: diff --git a/build/Riivo/riivolution/hns.xml b/build/Riivo/riivolution/hns.xml index 7e4c2e7..e39ae87 100644 --- a/build/Riivo/riivolution/hns.xml +++ b/build/Riivo/riivolution/hns.xml @@ -38,7 +38,7 @@ - + diff --git a/src/include/raceinfo.h b/src/include/raceinfo.h index d3d1b78..65b7a42 100644 --- a/src/include/raceinfo.h +++ b/src/include/raceinfo.h @@ -60,14 +60,16 @@ typedef struct { } RaceinfoPlayer; // Total size 0x54 typedef struct { - void* vtable; - void* random1; - void* random2; - RaceinfoPlayer **players; - void* gamemodeData; - TimerManager* timerManager; - u8 unk[0x10]; - u32 raceState; + void* vtable; + void* random1; + void* random2; + RaceinfoPlayer **players; + void* gamemodeData; + TimerManager* timerManager; + u8 unk[8]; + u32 timer; + u8 unk2[4]; + u32 raceState; } _Raceinfo; extern _Raceinfo* Raceinfo; diff --git a/src/include/racemodeonline.h b/src/include/racemodeonline.h index 812b2cf..0d8d61a 100644 --- a/src/include/racemodeonline.h +++ b/src/include/racemodeonline.h @@ -30,3 +30,4 @@ typedef struct { } RaceModeOnlineVs; // Total size 0x174 RaceHeader2VS* GetRaceHeader2Buffer(u32 param_1, u32 playerId); +void clearSendRH2(u32 ptr_miscPacketHandler); diff --git a/src/payload/main/trackcheck.S b/src/payload/main/trackcheck.S deleted file mode 100644 index 2e6aef7..0000000 --- a/src/payload/main/trackcheck.S +++ /dev/null @@ -1,12 +0,0 @@ -.include "asm_setup.S" - -.extern DoInsertTrackIdent, clearSendRH2 -.global InsertTrackIdent - -InsertTrackIdent: -mflr r9 -stw r0, 0x110(r3) # Original instruction -b DoInsertTrackIdent -mtlr r9 -b clearSendRH2 - diff --git a/src/payload/main/trackcheck.c b/src/payload/main/trackcheck.c index b946fd2..f1b369b 100644 --- a/src/payload/main/trackcheck.c +++ b/src/payload/main/trackcheck.c @@ -3,21 +3,25 @@ #include "hidenseek.h" #include "os.h" #include "racedata.h" +#include "raceinfo.h" #include "racemodeonline.h" #include "rknetcontroller.h" extern u32 ptr_miscPacketHandler; // if this is a pointer shouldn't i be defining it as such? bool finishedTrackCheck; -void DoInsertTrackIdent(RaceModeOnlineVs *RaceModeOnlineVs) { +void InsertTrackIdent(RaceModeOnlineVs *RaceModeOnlineVs) { if(!DWC_IsServerMyself()){ RaceModeOnlineVs->outPacket.minimumRaceFinishTime = ENPTCRC; // Replace unused field with CRC32 of the ENPT section for the current track } - return; + clearSendRH2(ptr_miscPacketHandler); } void CheckTrackIdent() { if(DWC_IsServerMyself()){ + if (Raceinfo->timer != 240) { + return; + } u8 playerId; for (playerId = 0; playerId < Racedata->main.scenarios[0].playerCount; playerId++) { if (HideNSeekData.players[RKNetController->aidsToPids[playerId]].doneTrackCheck) { @@ -27,9 +31,7 @@ void CheckTrackIdent() { continue; } RaceHeader2VS* RH2 = GetRaceHeader2Buffer(ptr_miscPacketHandler, playerId); - if (RH2->minimumRaceFinishTime == 0) { - continue; - } + if (RH2->minimumRaceFinishTime != ENPTCRC) { bool ret = OSDisableInterrupts(); DWC_CloseConnectionHard(RKNetController->aidsToPids[playerId]);