From e9b2419ac4393988f1cb4148117eb3bda4b77232 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sun, 3 Jan 2021 13:13:04 +1000 Subject: [PATCH] Decompile mpApplyLimits --- src/game/core.c | 2 +- src/game/mplayer/mplayer.c | 74 ++++++++---------------------- src/include/game/mplayer/mplayer.h | 2 +- 3 files changed, 22 insertions(+), 56 deletions(-) diff --git a/src/game/core.c b/src/game/core.c index 00ec3244e..54b823ceb 100644 --- a/src/game/core.c +++ b/src/game/core.c @@ -322,7 +322,7 @@ void coreLoadStage(s32 stagenum) } if (g_Vars.normmplayerisrunning) { - func0f188530(); + mpApplyLimits(); } if (g_Vars.mplayerisrunning == false) { diff --git a/src/game/mplayer/mplayer.c b/src/game/mplayer/mplayer.c index b7a7e6776..fbb45e277 100644 --- a/src/game/mplayer/mplayer.c +++ b/src/game/mplayer/mplayer.c @@ -905,60 +905,26 @@ glabel func0f18844c /* f18852c: 00601025 */ or $v0,$v1,$zero ); -GLOBAL_ASM( -glabel func0f188530 -/* f188530: 3c02800b */ lui $v0,%hi(g_MpSetup+0x12) -/* f188534: 9042cb9a */ lbu $v0,%lo(g_MpSetup+0x12)($v0) -/* f188538: 27bdffe8 */ addiu $sp,$sp,-24 -/* f18853c: afbf0014 */ sw $ra,0x14($sp) -/* f188540: 2841003c */ slti $at,$v0,0x3c -/* f188544: 14200005 */ bnez $at,.L0f18855c -/* f188548: 000220c0 */ sll $a0,$v0,0x3 -/* f18854c: 0fc5b372 */ jal coreSetMpTimeLimit60 -/* f188550: 00002025 */ or $a0,$zero,$zero -/* f188554: 10000007 */ b .L0f188574 -/* f188558: 00000000 */ nop -.L0f18855c: -/* f18855c: 00822023 */ subu $a0,$a0,$v0 -/* f188560: 00042140 */ sll $a0,$a0,0x5 -/* f188564: 00822021 */ addu $a0,$a0,$v0 -/* f188568: 00042100 */ sll $a0,$a0,0x4 -/* f18856c: 0fc5b372 */ jal coreSetMpTimeLimit60 -/* f188570: 24840e10 */ addiu $a0,$a0,0xe10 -.L0f188574: -/* f188574: 3c02800b */ lui $v0,%hi(g_MpSetup+0x13) -/* f188578: 9042cb9b */ lbu $v0,%lo(g_MpSetup+0x13)($v0) -/* f18857c: 28410064 */ slti $at,$v0,0x64 -/* f188580: 14200005 */ bnez $at,.L0f188598 -/* f188584: 00000000 */ nop -/* f188588: 0fc5b375 */ jal coreSetMpScoreLimit -/* f18858c: 00002025 */ or $a0,$zero,$zero -/* f188590: 10000003 */ b .L0f1885a0 -/* f188594: 00000000 */ nop -.L0f188598: -/* f188598: 0fc5b375 */ jal coreSetMpScoreLimit -/* f18859c: 24440001 */ addiu $a0,$v0,0x1 -.L0f1885a0: -/* f1885a0: 3c0e800b */ lui $t6,%hi(g_MpSetup+0x14) -/* f1885a4: 95cecb9c */ lhu $t6,%lo(g_MpSetup+0x14)($t6) -/* f1885a8: 29c10190 */ slti $at,$t6,0x190 -/* f1885ac: 14200005 */ bnez $at,.L0f1885c4 -/* f1885b0: 00000000 */ nop -/* f1885b4: 0fc5b378 */ jal coreSetMpTeamScoreLimit -/* f1885b8: 00002025 */ or $a0,$zero,$zero -/* f1885bc: 10000006 */ b .L0f1885d8 -/* f1885c0: 8fbf0014 */ lw $ra,0x14($sp) -.L0f1885c4: -/* f1885c4: 0fc62113 */ jal func0f18844c -/* f1885c8: 00000000 */ nop -/* f1885cc: 0fc5b378 */ jal coreSetMpTeamScoreLimit -/* f1885d0: 24440001 */ addiu $a0,$v0,0x1 -/* f1885d4: 8fbf0014 */ lw $ra,0x14($sp) -.L0f1885d8: -/* f1885d8: 27bd0018 */ addiu $sp,$sp,0x18 -/* f1885dc: 03e00008 */ jr $ra -/* f1885e0: 00000000 */ nop -); +void mpApplyLimits(void) +{ + if (g_MpSetup.timelimit >= 60) { + coreSetMpTimeLimit60(0); + } else { + coreSetMpTimeLimit60(SECSTOTIME60((g_MpSetup.timelimit + 1) * 60)); + } + + if (g_MpSetup.scorelimit >= 100) { + coreSetMpScoreLimit(0); + } else { + coreSetMpScoreLimit(g_MpSetup.scorelimit + 1); + } + + if (g_MpSetup.teamscorelimit >= 400) { + coreSetMpTeamScoreLimit(0); + } else { + coreSetMpTeamScoreLimit(func0f18844c() + 1); + } +} GLOBAL_ASM( glabel mpGetPlayerRankings diff --git a/src/include/game/mplayer/mplayer.h b/src/include/game/mplayer/mplayer.h index 86c064ec2..aeb9d8193 100644 --- a/src/include/game/mplayer/mplayer.h +++ b/src/include/game/mplayer/mplayer.h @@ -15,7 +15,7 @@ void func0f1881d4(s32 index); void mpSetDefaultSetup(void); void mpSetDefaultNamesIfEmpty(void); u32 func0f18844c(void); -void func0f188530(void); +void mpApplyLimits(void); s32 mpGetPlayerRankings(struct mpteaminfo *info); u32 func0f188930(void); s32 mpGetTeamRankings(struct mpteaminfo *info);