diff options
Diffstat (limited to 'src/lottery_corner.c')
-rw-r--r-- | src/lottery_corner.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/lottery_corner.c b/src/lottery_corner.c index c18aeef48..3d456f372 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) var = var * 1103515245 + 12345; - SetLotteryNumber(var); + SetLotteryNumber(var); } void RetrieveLotteryNumber(void) @@ -55,14 +56,14 @@ void PickLotteryCornerTicket(void) u16 j; u32 box; u32 slot; - + gSpecialVar_0x8004 = 0; slot = 0; box = 0; 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) { @@ -71,7 +72,7 @@ void PickLotteryCornerTicket(void) { u32 otId = GetMonData(pkmn, MON_DATA_OT_ID); u8 numMatchingDigits = GetMatchingDigits(gScriptResult, otId); - + if(numMatchingDigits > gSpecialVar_0x8004 && numMatchingDigits > 1) { gSpecialVar_0x8004 = numMatchingDigits - 1; @@ -83,7 +84,7 @@ 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++) { @@ -91,14 +92,14 @@ void PickLotteryCornerTicket(void) 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 && !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) { gSpecialVar_0x8004 = numMatchingDigits - 1; @@ -108,11 +109,11 @@ void PickLotteryCornerTicket(void) } } } - + if(gSpecialVar_0x8004 != 0) { gSpecialVar_0x8005 = sLotteryPrizes[gSpecialVar_0x8004 - 1]; - + if(box == 14) { gSpecialVar_0x8006 = 0; @@ -131,12 +132,12 @@ static u8 GetMatchingDigits(u16 winNumber, u16 otId) { u8 i; u8 matchingDigits = 0; - + for(i = 0; i < 5; i++) { sWinNumberDigit = winNumber % 10; sOtIdDigit = otId % 10; - + if(sWinNumberDigit == sOtIdDigit) { winNumber = winNumber / 10; @@ -163,7 +164,7 @@ u32 GetLotteryNumber(void) { u16 highNum = VarGet(VAR_POKELOT_RND1); u16 lowNum = VarGet(VAR_POKELOT_RND2); - + return (lowNum << 16) | highNum; } |