diff options
Diffstat (limited to 'src/lottery_corner.c')
-rw-r--r-- | src/lottery_corner.c | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/src/lottery_corner.c b/src/lottery_corner.c index c18aeef48..66e1238ef 100644 --- a/src/lottery_corner.c +++ b/src/lottery_corner.c @@ -1,10 +1,11 @@ #include "global.h" #include "lottery_corner.h" -#include "rng.h" -#include "string_util.h" #include "event_data.h" -#include "species.h" #include "items.h" +#include "rng.h" +#include "species.h" +#include "string_util.h" +#include "text.h" extern u16 gScriptResult; extern u16 gSpecialVar_0x8004; @@ -36,11 +37,11 @@ void ResetLotteryCorner(void) void SetRandomLotteryNumber(u16 i) { u32 var = Random(); - - while(--i != 0xFFFF) + + while (--i != 0xFFFF) var = var * 1103515245 + 12345; - SetLotteryNumber(var); + SetLotteryNumber(var); } void RetrieveLotteryNumber(void) @@ -55,24 +56,24 @@ void PickLotteryCornerTicket(void) u16 j; u32 box; u32 slot; - + gSpecialVar_0x8004 = 0; slot = 0; box = 0; - for(i = 0; i < 6; i++) + for (i = 0; i < 6; i++) { struct Pokemon *pkmn = &gPlayerParty[i]; - + // UB: Too few arguments for function GetMonData - if(GetMonData(pkmn, MON_DATA_SPECIES) != SPECIES_NONE) + if (GetMonData(pkmn, MON_DATA_SPECIES) != SPECIES_NONE) { // do not calculate ticket values for eggs. - if(!GetMonData(pkmn, MON_DATA_IS_EGG)) + if (!GetMonData(pkmn, MON_DATA_IS_EGG)) { u32 otId = GetMonData(pkmn, MON_DATA_OT_ID); u8 numMatchingDigits = GetMatchingDigits(gScriptResult, otId); - - if(numMatchingDigits > gSpecialVar_0x8004 && numMatchingDigits > 1) + + if (numMatchingDigits > gSpecialVar_0x8004 && numMatchingDigits > 1) { gSpecialVar_0x8004 = numMatchingDigits - 1; box = 14; @@ -83,23 +84,23 @@ void PickLotteryCornerTicket(void) else // pokemon are always arranged from populated spots first to unpopulated, so the moment a NONE species is found, that's the end of the list. break; } - + // player has 14 boxes. - for(i = 0; i < 14; i++) + for (i = 0; i < 14; i++) { // player has 30 slots per box. - for(j = 0; j < 30; j++) + for (j = 0; j < 30; j++) { struct BoxPokemon *pkmn = &gPokemonStorage.boxes[i][j]; - + // UB: Too few arguments for function GetMonData - if(GetBoxMonData(pkmn, MON_DATA_SPECIES) != SPECIES_NONE && + if (GetBoxMonData(pkmn, MON_DATA_SPECIES) != SPECIES_NONE && !GetBoxMonData(pkmn, MON_DATA_IS_EGG)) { u32 otId = GetBoxMonData(pkmn, MON_DATA_OT_ID); u8 numMatchingDigits = GetMatchingDigits(gScriptResult, otId); - - if(numMatchingDigits > gSpecialVar_0x8004 && numMatchingDigits > 1) + + if (numMatchingDigits > gSpecialVar_0x8004 && numMatchingDigits > 1) { gSpecialVar_0x8004 = numMatchingDigits - 1; box = i; @@ -108,12 +109,12 @@ void PickLotteryCornerTicket(void) } } } - - if(gSpecialVar_0x8004 != 0) + + if (gSpecialVar_0x8004 != 0) { gSpecialVar_0x8005 = sLotteryPrizes[gSpecialVar_0x8004 - 1]; - - if(box == 14) + + if (box == 14) { gSpecialVar_0x8006 = 0; GetMonData(&gPlayerParty[slot], MON_DATA_NICKNAME, gStringVar1); @@ -131,13 +132,13 @@ static u8 GetMatchingDigits(u16 winNumber, u16 otId) { u8 i; u8 matchingDigits = 0; - - for(i = 0; i < 5; i++) + + for (i = 0; i < 5; i++) { sWinNumberDigit = winNumber % 10; sOtIdDigit = otId % 10; - - if(sWinNumberDigit == sOtIdDigit) + + if (sWinNumberDigit == sOtIdDigit) { winNumber = winNumber / 10; otId = otId / 10; @@ -163,7 +164,7 @@ u32 GetLotteryNumber(void) { u16 highNum = VarGet(VAR_POKELOT_RND1); u16 lowNum = VarGet(VAR_POKELOT_RND2); - + return (lowNum << 16) | highNum; } |