From 84a92279c9133dfba085af05a0f2b6cce461d765 Mon Sep 17 00:00:00 2001 From: PokeCodec <67983839+PokeCodec@users.noreply.github.com> Date: Wed, 9 Sep 2020 15:23:52 -0400 Subject: [PATCH] Record mixing fakematch fixed! --- src/dewford_trend.c | 38 +++++++++++++++++++------------------- src/pokemon.c | 2 +- src/record_mixing.c | 29 ++++++++++++----------------- 3 files changed, 32 insertions(+), 37 deletions(-) diff --git a/src/dewford_trend.c b/src/dewford_trend.c index e3b98859ce..ff1b090419 100644 --- a/src/dewford_trend.c +++ b/src/dewford_trend.c @@ -245,46 +245,46 @@ static bool8 sub_8122A58(struct EasyChatPair *a, struct EasyChatPair *b, u8 c) { case 0: if (a->unk0_0 > b->unk0_0) - return 1; + return TRUE; if (a->unk0_0 < b->unk0_0) - return 0; + return FALSE; if (a->unk0_7 > b->unk0_7) - return 1; + return TRUE; if (a->unk0_7 < b->unk0_7) - return 0; + return FALSE; break; case 1: if (a->unk0_7 > b->unk0_7) - return 1; + return TRUE; if (a->unk0_7 < b->unk0_7) - return 0; + return FALSE; if (a->unk0_0 > b->unk0_0) - return 1; + return TRUE; if (a->unk0_0 < b->unk0_0) - return 0; + return FALSE; break; case 2: if (a->unk0_0 > b->unk0_0) - return 1; + return TRUE; if (a->unk0_0 < b->unk0_0) - return 0; + return FALSE; if (a->unk0_7 > b->unk0_7) - return 1; + return TRUE; if (a->unk0_7 < b->unk0_7) - return 0; + return FALSE; if (a->unk2 > b->unk2) - return 1; + return TRUE; if (a->unk2 < b->unk2) - return 0; + return FALSE; if (a->words[0] > b->words[0]) - return 1; + return TRUE; if (a->words[0] < b->words[0]) - return 0; + return FALSE; if (a->words[1] > b->words[1]) - return 1; + return TRUE; if (a->words[1] < b->words[1]) - return 0; - return 1; + return FALSE; + return TRUE; } return Random() & 1; } diff --git a/src/pokemon.c b/src/pokemon.c index 2440f183e2..29f0f6dfc7 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -70,7 +70,7 @@ EWRAM_DATA u8 gEnemyPartyCount = 0; EWRAM_DATA struct Pokemon gPlayerParty[PARTY_SIZE] = {0}; EWRAM_DATA struct Pokemon gEnemyParty[PARTY_SIZE] = {0}; EWRAM_DATA struct SpriteTemplate gMultiuseSpriteTemplate = {0}; -EWRAM_DATA struct Unknown_806F160_Struct *gUnknown_020249B4[2] = {NULL}; +EWRAM_DATA struct Unknown_806F160_Struct *gUnknown_020249B4[2] = {NULL, NULL}; // const rom data #include "data/battle_moves.h" diff --git a/src/record_mixing.c b/src/record_mixing.c index 88c49c0163..b12b716972 100644 --- a/src/record_mixing.c +++ b/src/record_mixing.c @@ -866,28 +866,23 @@ static void ReceiveDaycareMailData(struct RecordMixingDayCareMail *src, size_t r } else if (sp1c[i][0] == TRUE && sp1c[i][1] == TRUE) { - u32 var1, var2; + u8 mail1, mail2; sp24[j][0] = i; - var1 = sub_80E7A9C(&_src->mail[0]); - var2 = sub_80E7A9C(&_src->mail[1]); - if (!var1 && var2) + mail1 = sub_80E7A9C(&_src->mail[0]); + mail2 = sub_80E7A9C(&_src->mail[1]); + if (!(mail1 || mail2) || (mail1 && mail2)) //Logical (not bitwise) XOR. Should be ((mail1 || mail2) && !(mail1 && mail2)), but that doesn't match. { - #ifndef NONMATCHING - register u8 one asm("r0") = 1; // boo, a fakematch - sp24[j][1] = one; - #else - sp24[j][1] = 1; - #endif + sp24[j][1] = Random2() % 2; } - else if ((var1 && var2) || (!var1 && !var2)) - { - sp24[j][1] = Random2() % 2; - } - else if (var1 && !var2) + else if (mail1 && !mail2) { sp24[j][1] = 0; } + else if (!mail1 && mail2) + { + sp24[j][1] = 1; + } j++; } } @@ -921,8 +916,8 @@ static void ReceiveDaycareMailData(struct RecordMixingDayCareMail *src, size_t r } _src = (void *)src + which * recordSize; - memcpy(&gSaveBlock1Ptr->daycare.mons[0].mail, &_src->mail[0], sizeof(struct DayCareMail)); - memcpy(&gSaveBlock1Ptr->daycare.mons[1].mail, &_src->mail[1], sizeof(struct DayCareMail)); + gSaveBlock1Ptr->daycare.mons[0].mail = _src->mail[0]; + gSaveBlock1Ptr->daycare.mons[1].mail = _src->mail[1]; SeedRng(oldSeed); }