mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-25 11:14:15 +01:00
Fix ModifyPersonalityForNature (#3452)
This commit is contained in:
parent
cd59e055c2
commit
5fd36a8e39
@ -1896,7 +1896,7 @@ static u32 GeneratePartyHash(const struct Trainer *trainer, u32 i)
|
||||
void ModifyPersonalityForNature(u32 *personality, u32 newNature)
|
||||
{
|
||||
u32 nature = GetNatureFromPersonality(*personality);
|
||||
s32 diff = abs(nature - newNature);
|
||||
s32 diff = abs((s32)nature - (s32)newNature);
|
||||
s32 sign = (nature > newNature) ? 1 : -1;
|
||||
if (diff > NUM_NATURES / 2)
|
||||
{
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "battle_main.h"
|
||||
#include "data.h"
|
||||
#include "malloc.h"
|
||||
#include "random.h"
|
||||
#include "string_util.h"
|
||||
#include "constants/item.h"
|
||||
#include "constants/abilities.h"
|
||||
@ -119,3 +120,17 @@ TEST("CreateNPCTrainerPartyForTrainer generates different personalities for diff
|
||||
EXPECT(testParty[0].box.personality != testParty[1].box.personality);
|
||||
Free(testParty);
|
||||
}
|
||||
|
||||
TEST("ModifyPersonalityForNature can set any nature")
|
||||
{
|
||||
u32 personality, nature, j, k;
|
||||
for (j = 0; j < 64; j++)
|
||||
{
|
||||
for (k = 0; k < NUM_NATURES; k++)
|
||||
{
|
||||
PARAMETRIZE { personality = Random32(); nature = k; }
|
||||
}
|
||||
}
|
||||
ModifyPersonalityForNature(&personality, nature);
|
||||
EXPECT_EQ(GetNatureFromPersonality(personality), nature);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user