Now returns SPECIES_NONE data when there's no data defined for a species
This commit is contained in:
parent
8a285ac830
commit
cbb36b02a1
11 changed files with 74 additions and 108 deletions
|
@ -605,5 +605,6 @@ u16 MonTryLearningNewMoveEvolution(struct Pokemon *mon, bool8 firstMove);
|
|||
bool32 SpeciesHasGenderDifferences(u16 species);
|
||||
void TryToSetBattleFormChangeMoves(struct Pokemon *mon);
|
||||
u32 GetMonFriendshipScore(struct Pokemon *pokemon);
|
||||
u16 SanitizeSpeciesId(u16 species);
|
||||
|
||||
#endif // GUARD_POKEMON_H
|
||||
|
|
|
@ -209,13 +209,9 @@ u8 GetBattlerYDelta(u8 battlerId, u16 species)
|
|||
{
|
||||
ret = sCastformBackSpriteYCoords[gBattleMonForms[battlerId]];
|
||||
}
|
||||
else if (species > NUM_SPECIES)
|
||||
{
|
||||
ret = gBaseStats[SPECIES_NONE].backPicYOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = gBaseStats[species].backPicYOffset;
|
||||
ret = gBaseStats[SanitizeSpeciesId(species)].backPicYOffset;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -235,13 +231,9 @@ u8 GetBattlerYDelta(u8 battlerId, u16 species)
|
|||
{
|
||||
ret = gCastformFrontSpriteCoords[gBattleMonForms[battlerId]].y_offset;
|
||||
}
|
||||
else if (species > NUM_SPECIES)
|
||||
{
|
||||
ret = gBaseStats[SPECIES_NONE].frontPicYOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = gBaseStats[species].frontPicYOffset;
|
||||
ret = gBaseStats[SanitizeSpeciesId(species)].frontPicYOffset;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
@ -256,10 +248,8 @@ u8 GetBattlerElevation(u8 battlerId, u16 species)
|
|||
{
|
||||
if (species == SPECIES_CASTFORM)
|
||||
ret = sCastformElevations[gBattleMonForms[battlerId]];
|
||||
else if (species > NUM_SPECIES)
|
||||
ret = gBaseStats[SPECIES_NONE].enemyMonElevation;
|
||||
else
|
||||
ret = gBaseStats[species].enemyMonElevation;
|
||||
ret = gBaseStats[SanitizeSpeciesId(species)].enemyMonElevation;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
@ -2250,15 +2240,10 @@ s16 GetBattlerSpriteCoordAttr(u8 battlerId, u8 attr)
|
|||
size = gBaseStats[species].backPicSize;
|
||||
y_offset = gBaseStats[species].backPicYOffset;
|
||||
}
|
||||
else if (species > NUM_SPECIES)
|
||||
{
|
||||
size = gBaseStats[SPECIES_NONE].backPicSize;
|
||||
y_offset = gBaseStats[SPECIES_NONE].backPicYOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
size = gBaseStats[species].backPicSize;
|
||||
y_offset = gBaseStats[species].backPicYOffset;
|
||||
size = gBaseStats[SanitizeSpeciesId(species)].backPicSize;
|
||||
y_offset = gBaseStats[SanitizeSpeciesId(species)].backPicYOffset;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -2286,15 +2271,10 @@ s16 GetBattlerSpriteCoordAttr(u8 battlerId, u8 attr)
|
|||
size = gCastformFrontSpriteCoords[gBattleMonForms[battlerId]].size;
|
||||
y_offset = gCastformFrontSpriteCoords[gBattleMonForms[battlerId]].y_offset;
|
||||
}
|
||||
else if (species > NUM_SPECIES)
|
||||
{
|
||||
size = gBaseStats[SPECIES_NONE].frontPicSize;
|
||||
y_offset = gBaseStats[SPECIES_NONE].frontPicYOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
size = gBaseStats[species].frontPicSize;
|
||||
y_offset = gBaseStats[species].frontPicYOffset;
|
||||
size = gBaseStats[SanitizeSpeciesId(species)].frontPicSize;
|
||||
y_offset = gBaseStats[SanitizeSpeciesId(species)].frontPicYOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2671,13 +2671,9 @@ void SpriteCB_FaintOpponentMon(struct Sprite *sprite)
|
|||
{
|
||||
yOffset = gCastformFrontSpriteCoords[gBattleMonForms[battler]].y_offset;
|
||||
}
|
||||
else if (species > NUM_SPECIES)
|
||||
{
|
||||
yOffset = gBaseStats[SPECIES_NONE].frontPicYOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
yOffset = gBaseStats[species].frontPicYOffset;
|
||||
yOffset = gBaseStats[SanitizeSpeciesId(species)].frontPicYOffset;
|
||||
}
|
||||
|
||||
sprite->data[3] = 8 - yOffset / 8;
|
||||
|
|
|
@ -298,10 +298,6 @@ const union AnimCmd *const gAnims_MonPic[] =
|
|||
sAnim_MonPic_3,
|
||||
};
|
||||
|
||||
#define SPECIES_SPRITE(species, sprite) [SPECIES_##species] = {sprite, MON_PIC_SIZE, SPECIES_##species}
|
||||
#define SPECIES_PAL(species, pal) [SPECIES_##species] = {pal, SPECIES_##species}
|
||||
#define SPECIES_SHINY_PAL(species, pal) [SPECIES_##species] = {pal, SPECIES_##species + SPECIES_SHINY_TAG}
|
||||
|
||||
#include "data/trainer_graphics/front_pic_anims.h"
|
||||
#include "data/trainer_graphics/front_pic_tables.h"
|
||||
#include "data/trainer_graphics/back_pic_anims.h"
|
||||
|
|
|
@ -78,6 +78,7 @@ const struct BaseStats gBaseStats[] =
|
|||
PALETTES(QuestionMark),
|
||||
ICON(QuestionMark, 0),
|
||||
FOOTPRINT(Bulbasaur),
|
||||
ANIMATIONS(NONE, 0, ANIM_V_SQUISH_AND_BOUNCE, BACK_ANIM_NONE),
|
||||
},
|
||||
|
||||
[SPECIES_BULBASAUR] =
|
||||
|
|
|
@ -77,9 +77,8 @@ void DecompressPicFromTable(const struct CompressedSpriteSheet *src, void *buffe
|
|||
|
||||
void DecompressPicFromTableGender(void* buffer, s32 species, u32 personality)
|
||||
{
|
||||
if (species > NUM_SPECIES)
|
||||
LZ77UnCompWram(gBaseStats[SPECIES_NONE].frontPic, buffer);
|
||||
else if (gBaseStats[species].frontPicFemale != NULL && IsPersonalityFemale(species, personality))
|
||||
species = SanitizeSpeciesId(species);
|
||||
if (gBaseStats[species].frontPicFemale != NULL && IsPersonalityFemale(species, personality))
|
||||
LZ77UnCompWram(gBaseStats[species].frontPicFemale, buffer);
|
||||
else if (gBaseStats[species].frontPic != NULL)
|
||||
LZ77UnCompWram(gBaseStats[species].frontPic, buffer);
|
||||
|
@ -89,41 +88,32 @@ void DecompressPicFromTableGender(void* buffer, s32 species, u32 personality)
|
|||
|
||||
void HandleLoadSpecialPokePic(bool32 isFrontPic, void *dest, s32 species, u32 personality)
|
||||
{
|
||||
LoadSpecialPokePic(dest, species, personality, isFrontPic);
|
||||
LoadSpecialPokePic(dest, SanitizeSpeciesId(species), personality, isFrontPic);
|
||||
}
|
||||
|
||||
void LoadSpecialPokePic(void *dest, s32 species, u32 personality, bool8 isFrontPic)
|
||||
{
|
||||
if (species == SPECIES_UNOWN)
|
||||
if (isFrontPic)
|
||||
{
|
||||
u32 id = GetUnownSpeciesId(personality);
|
||||
|
||||
if (!isFrontPic)
|
||||
LZ77UnCompWram(gBaseStats[id].backPic, dest);
|
||||
if (species == SPECIES_UNOWN)
|
||||
LZ77UnCompWram(gBaseStats[GetUnownSpeciesId(personality)].frontPic, dest);
|
||||
else if (gBaseStats[species].frontPicFemale != NULL && IsPersonalityFemale(species, personality))
|
||||
LZ77UnCompWram(gBaseStats[species].frontPicFemale, dest); // Is female with sprite differences
|
||||
else if (gBaseStats[species].frontPic != NULL)
|
||||
LZ77UnCompWram(gBaseStats[species].frontPic, dest);
|
||||
else
|
||||
LZ77UnCompWram(gBaseStats[id].frontPic, dest);
|
||||
}
|
||||
else if (species > NUM_SPECIES) // is species unknown? draw the ? icon
|
||||
{
|
||||
if (isFrontPic)
|
||||
LZ77UnCompWram(gBaseStats[SPECIES_NONE].frontPic, dest);
|
||||
else
|
||||
LZ77UnCompWram(gBaseStats[SPECIES_NONE].backPic, dest);
|
||||
}
|
||||
else if (isFrontPic && gBaseStats[species].frontPicFemale != NULL && IsPersonalityFemale(species, personality))
|
||||
{
|
||||
LZ77UnCompWram(gBaseStats[species].frontPicFemale, dest);
|
||||
}
|
||||
else if (!isFrontPic && gBaseStats[species].backPicFemale != NULL && IsPersonalityFemale(species, personality))
|
||||
{
|
||||
LZ77UnCompWram(gBaseStats[species].backPicFemale, dest);
|
||||
LZ77UnCompWram(gBaseStats[SPECIES_NONE].frontPic, dest); // No sprite defined, draw ? icon
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isFrontPic)
|
||||
LZ77UnCompWram(gBaseStats[species].frontPic, dest);
|
||||
else
|
||||
if (species == SPECIES_UNOWN)
|
||||
LZ77UnCompWram(gBaseStats[GetUnownSpeciesId(personality)].backPic, dest);
|
||||
else if (gBaseStats[species].backPicFemale != NULL && IsPersonalityFemale(species, personality))
|
||||
LZ77UnCompWram(gBaseStats[species].backPicFemale, dest); // Is female with sprite differences
|
||||
else if (gBaseStats[species].backPic != NULL)
|
||||
LZ77UnCompWram(gBaseStats[species].backPic, dest);
|
||||
else
|
||||
LZ77UnCompWram(gBaseStats[SPECIES_NONE].backPic, dest); // No sprite defined, draw ? icon
|
||||
}
|
||||
|
||||
DrawSpindaSpots(species, personality, dest, isFrontPic);
|
||||
|
|
|
@ -4232,7 +4232,7 @@ static void PrintMonInfo(u32 num, u32 value, u32 owned, u32 newEntry)
|
|||
PrintInfoScreenText(gText_UnkHeight, 0x81, 0x39);
|
||||
PrintInfoScreenText(gText_UnkWeight, 0x81, 0x49);
|
||||
}
|
||||
if (owned)
|
||||
if (owned && gBaseStats[num].description != NULL)
|
||||
description = gBaseStats[num].description;
|
||||
else
|
||||
description = sExpandedPlaceholder_PokedexDescription;
|
||||
|
|
|
@ -2000,9 +2000,19 @@ void SetMultiuseSpriteTemplateToPokemon(u16 speciesTag, u8 battlerPosition)
|
|||
if (battlerPosition == B_POSITION_PLAYER_LEFT || battlerPosition == B_POSITION_PLAYER_RIGHT)
|
||||
gMultiuseSpriteTemplate.anims = gAnims_MonPic;
|
||||
else if (speciesTag > SPECIES_SHINY_TAG)
|
||||
gMultiuseSpriteTemplate.anims = gBaseStats[speciesTag - SPECIES_SHINY_TAG].frontAnimFrames;
|
||||
{
|
||||
if (gBaseStats[speciesTag - SPECIES_SHINY_TAG].frontAnimFrames != NULL)
|
||||
gMultiuseSpriteTemplate.anims = gBaseStats[speciesTag - SPECIES_SHINY_TAG].frontAnimFrames;
|
||||
else
|
||||
gMultiuseSpriteTemplate.anims = gBaseStats[SPECIES_NONE].frontAnimFrames;
|
||||
}
|
||||
else
|
||||
gMultiuseSpriteTemplate.anims = gBaseStats[speciesTag].frontAnimFrames;
|
||||
{
|
||||
if (gBaseStats[speciesTag].frontAnimFrames != NULL)
|
||||
gMultiuseSpriteTemplate.anims = gBaseStats[speciesTag].frontAnimFrames;
|
||||
else
|
||||
gMultiuseSpriteTemplate.anims = gBaseStats[SPECIES_NONE].frontAnimFrames;
|
||||
}
|
||||
}
|
||||
|
||||
void SetMultiuseSpriteTemplateToTrainerBack(u16 trainerPicId, u8 battlerPosition)
|
||||
|
@ -3098,9 +3108,7 @@ bool8 IsPokemonStorageFull(void)
|
|||
|
||||
const u8 *GetSpeciesName(u16 species)
|
||||
{
|
||||
if (species > NUM_SPECIES)
|
||||
return gSpeciesNames[NATIONAL_DEX_NONE];
|
||||
return gSpeciesNames[gBaseStats[species].natDexNum];
|
||||
return gSpeciesNames[gBaseStats[SanitizeSpeciesId(species)].natDexNum];
|
||||
}
|
||||
|
||||
u8 CalculatePPWithBonus(u16 move, u8 ppBonuses, u8 moveIndex)
|
||||
|
@ -5260,9 +5268,7 @@ const u32 *GetMonFrontSpritePal(struct Pokemon *mon)
|
|||
const u32 *GetMonSpritePalFromSpeciesAndPersonality(u16 species, u32 otId, u32 personality)
|
||||
{
|
||||
u32 shinyValue;
|
||||
|
||||
if (species > NUM_SPECIES)
|
||||
return gBaseStats[SPECIES_NONE].palette;
|
||||
species = SanitizeSpeciesId(species);
|
||||
|
||||
shinyValue = GET_SHINY_VALUE(otId, personality);
|
||||
if (shinyValue < SHINY_ODDS)
|
||||
|
@ -5276,8 +5282,10 @@ const u32 *GetMonSpritePalFromSpeciesAndPersonality(u16 species, u32 otId, u32 p
|
|||
{
|
||||
if (gBaseStats[species].paletteFemale != NULL && IsPersonalityFemale(species, personality))
|
||||
return gBaseStats[species].paletteFemale;
|
||||
else
|
||||
else if (gBaseStats[species].palette != NULL)
|
||||
return gBaseStats[species].palette;
|
||||
else
|
||||
return gBaseStats[SPECIES_NONE].palette;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6179,3 +6187,11 @@ u32 GetMonFriendshipScore(struct Pokemon *pokemon)
|
|||
|
||||
return FRIENDSHIP_NONE;
|
||||
}
|
||||
|
||||
u16 SanitizeSpeciesId(u16 species)
|
||||
{
|
||||
if (species > NUM_SPECIES)
|
||||
return SPECIES_NONE;
|
||||
else
|
||||
return species;
|
||||
}
|
||||
|
|
|
@ -696,8 +696,10 @@ static const u32 *GetMonSpritePalStructCustom(u16 species, bool8 isFemale, bool8
|
|||
{
|
||||
if (gBaseStats[species].paletteFemale != NULL && isFemale)
|
||||
return gBaseStats[species].paletteFemale;
|
||||
else
|
||||
else if (gBaseStats[species].palette != NULL)
|
||||
return gBaseStats[species].palette;
|
||||
else
|
||||
return gBaseStats[SPECIES_NONE].palette;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -719,8 +721,10 @@ static void BattleLoadOpponentMonSpriteGfxCustom(u16 species, bool8 isFemale, bo
|
|||
{
|
||||
if (gBaseStats[species].paletteFemale != NULL && isFemale)
|
||||
lzPaletteData = gBaseStats[species].paletteFemale;
|
||||
else
|
||||
else if (gBaseStats[species].palette != NULL)
|
||||
lzPaletteData = gBaseStats[species].palette;
|
||||
else
|
||||
lzPaletteData = gBaseStats[SPECIES_NONE].palette;
|
||||
}
|
||||
|
||||
LZDecompressWram(lzPaletteData, gDecompressionBuffer);
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
|
||||
#define POKE_ICON_BASE_PAL_TAG 56000
|
||||
|
||||
#define INVALID_ICON_SPECIES SPECIES_NONE // Oddly specific, used when an icon should be a ?. Any of the 'old unown' would work
|
||||
|
||||
struct MonIconSpriteTemplate
|
||||
{
|
||||
const struct OamData *oam;
|
||||
|
@ -194,10 +192,7 @@ u16 GetIconSpecies(u16 species, u32 personality)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (species > NUM_SPECIES)
|
||||
result = INVALID_ICON_SPECIES;
|
||||
else
|
||||
result = species;
|
||||
result = SanitizeSpeciesId(species);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -222,10 +217,7 @@ u16 GetIconSpeciesNoPersonality(u16 species)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (species > NUM_SPECIES)
|
||||
species = INVALID_ICON_SPECIES;
|
||||
|
||||
return GetIconSpecies(species, 0);
|
||||
return GetIconSpecies(SanitizeSpeciesId(species), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -250,9 +242,7 @@ void LoadMonIconPalettes(void)
|
|||
void SafeLoadMonIconPalette(u16 species)
|
||||
{
|
||||
u8 palIndex;
|
||||
if (species > NUM_SPECIES)
|
||||
species = INVALID_ICON_SPECIES;
|
||||
palIndex = gBaseStats[species].iconPalIndex;
|
||||
palIndex = gBaseStats[SanitizeSpeciesId(species)].iconPalIndex;
|
||||
if (IndexOfSpritePaletteTag(gMonIconPaletteTable[palIndex].tag) == 0xFF)
|
||||
LoadSpritePalette(&gMonIconPaletteTable[palIndex]);
|
||||
}
|
||||
|
@ -286,9 +276,7 @@ void FreeMonIconPalettes(void)
|
|||
void SafeFreeMonIconPalette(u16 species)
|
||||
{
|
||||
u8 palIndex;
|
||||
if (species > NUM_SPECIES)
|
||||
species = INVALID_ICON_SPECIES;
|
||||
palIndex = gBaseStats[species].iconPalIndex;
|
||||
palIndex = gBaseStats[SanitizeSpeciesId(species)].iconPalIndex;
|
||||
FreeSpritePaletteByTag(gMonIconPaletteTable[palIndex].tag);
|
||||
}
|
||||
|
||||
|
@ -310,8 +298,10 @@ const u8 *GetMonIconTiles(u16 species, u32 personality)
|
|||
|
||||
if (gBaseStats[species].iconSpriteFemale != NULL && IsPersonalityFemale(species, personality))
|
||||
iconSprite = gBaseStats[species].iconSpriteFemale;
|
||||
else
|
||||
else if (gBaseStats[species].iconSprite != NULL)
|
||||
iconSprite = gBaseStats[species].iconSprite;
|
||||
else
|
||||
iconSprite = gBaseStats[SPECIES_NONE].iconSprite;
|
||||
|
||||
return iconSprite;
|
||||
}
|
||||
|
@ -335,9 +325,7 @@ void TryLoadAllMonIconPalettesAtOffset(u16 offset)
|
|||
|
||||
u8 GetValidMonIconPalIndex(u16 species)
|
||||
{
|
||||
if (species > NUM_SPECIES)
|
||||
species = INVALID_ICON_SPECIES;
|
||||
return gBaseStats[species].iconPalIndex;
|
||||
return gBaseStats[SanitizeSpeciesId(species)].iconPalIndex;
|
||||
}
|
||||
|
||||
u8 GetMonIconPaletteIndexFromSpecies(u16 species)
|
||||
|
@ -347,9 +335,7 @@ u8 GetMonIconPaletteIndexFromSpecies(u16 species)
|
|||
|
||||
const u16 *GetValidMonIconPalettePtr(u16 species)
|
||||
{
|
||||
if (species > NUM_SPECIES)
|
||||
species = INVALID_ICON_SPECIES;
|
||||
return gMonIconPaletteTable[gBaseStats[species].iconPalIndex].data;
|
||||
return gMonIconPaletteTable[gBaseStats[SanitizeSpeciesId(species)].iconPalIndex].data;
|
||||
}
|
||||
|
||||
u8 UpdateMonIconFrame(struct Sprite *sprite)
|
||||
|
|
|
@ -57,14 +57,7 @@ static bool16 DecompressPic(u16 species, u32 personality, bool8 isFrontPic, u8 *
|
|||
{
|
||||
if (!isTrainer)
|
||||
{
|
||||
if (isFrontPic)
|
||||
{
|
||||
LoadSpecialPokePic(dest, species, personality, isFrontPic);
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadSpecialPokePic(dest, species, personality, isFrontPic);
|
||||
}
|
||||
LoadSpecialPokePic(dest, species, personality, isFrontPic);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -223,7 +216,10 @@ u16 CreateMonPicSprite_Affine(u16 species, u32 otId, u32 personality, u8 flags,
|
|||
images[j].size = MON_PIC_SIZE;
|
||||
}
|
||||
sCreatingSpriteTemplate.tileTag = TAG_NONE;
|
||||
sCreatingSpriteTemplate.anims = gBaseStats[species].frontAnimFrames;
|
||||
if (gBaseStats[species].frontAnimFrames != NULL)
|
||||
sCreatingSpriteTemplate.anims = gBaseStats[species].frontAnimFrames;
|
||||
else
|
||||
sCreatingSpriteTemplate.anims = gBaseStats[SPECIES_NONE].frontAnimFrames;
|
||||
sCreatingSpriteTemplate.images = images;
|
||||
if (type == MON_PIC_AFFINE_FRONT)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue