diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 64d6bd0..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 @@ -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/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/files/UIPatches/Global/message/Manu.bmg b/files/UIPatches/Global/message/Manu.bmg index 366c463..becfc50 100644 Binary files a/files/UIPatches/Global/message/Manu.bmg and b/files/UIPatches/Global/message/Manu.bmg differ diff --git a/files/UIPatches/Global/message/StaffRole.bmg b/files/UIPatches/Global/message/StaffRole.bmg index 5971550..fe51039 100644 Binary files a/files/UIPatches/Global/message/StaffRole.bmg and b/files/UIPatches/Global/message/StaffRole.bmg differ 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..65b7a42 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 @@ -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 new file mode 100644 index 0000000..0d8d61a --- /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 clearSendRH2(u32 ptr_miscPacketHandler); 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.c b/src/payload/main/trackcheck.c new file mode 100644 index 0000000..f1b369b --- /dev/null +++ b/src/payload/main/trackcheck.c @@ -0,0 +1,45 @@ +#include "common.h" +#include "dwc.h" +#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 InsertTrackIdent(RaceModeOnlineVs *RaceModeOnlineVs) { + if(!DWC_IsServerMyself()){ + RaceModeOnlineVs->outPacket.minimumRaceFinishTime = ENPTCRC; // Replace unused field with CRC32 of the ENPT section for the current track + } + 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) { + continue; + } + if (Racedata->main.scenarios->players[playerId].playerType == PLAYER_REAL_LOCAL) { + continue; + } + RaceHeader2VS* RH2 = GetRaceHeader2Buffer(ptr_miscPacketHandler, playerId); + + if (RH2->minimumRaceFinishTime != ENPTCRC) { + 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..9b4c669 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; + clearSendRH2 = 0x8064f8f0; } diff --git a/src/rmcj.ld b/src/rmcj.ld index f507303..ced9581 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; + clearSendRH2 = 0x806533e4; } diff --git a/src/rmck.ld b/src/rmck.ld index aced253..0ea0e39 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; + clearSendRH2 = 0x80642090; } diff --git a/src/rmcp.ld b/src/rmcp.ld index a785268..9d0cf60 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; + clearSendRH2 = 0x80653d78; }