Changed item name/pluralName to a compound string (#7359)

This commit is contained in:
Nephrite 2025-08-08 19:51:16 +01:00 committed by GitHub
parent 070a4f1dfa
commit 38eb3461b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 1050 additions and 1033 deletions

View File

@ -93,8 +93,8 @@ struct Item
ItemUseFunc fieldUseFunc;
const u8 *description;
const u8 *effect;
u8 name[ITEM_NAME_LENGTH];
u8 pluralName[ITEM_NAME_PLURAL_LENGTH];
const u8 *name;
const u8 *pluralName;
u8 holdEffect;
u8 holdEffectParam;
u8 importance:2;
@ -121,6 +121,7 @@ struct TmHmIndexKey
u16 moveId;
};
extern const u8 gQuestionMarksItemName[];
extern const struct Item gItemsInfo[];
extern struct BagPocket gBagPockets[];
extern const struct TmHmIndexKey gTMHMItemMoveIds[];

View File

@ -32,6 +32,12 @@
/* Converts a string to a compound literal, essentially making it a pointer to const u8 */
#define COMPOUND_STRING(str) (const u8[]) _(str)
#define COMPOUND_STRING_SIZE_LIMIT(str, limit) (const u8[COMPOUND_STRING_CHECK_SIZE(str, limit)]) _(str)
/* Used for COMPOUND_STRING_SIZE_LIMIT. Stupid, but makes sure we only get
* one error message regardless of how many characters over the limit we are.
* Otherwise, GCC gives an error for each and every character (which is annoying). */
#define COMPOUND_STRING_CHECK_SIZE(str, limit) (sizeof(COMPOUND_STRING(str)) > limit ? sizeof(COMPOUND_STRING(str)) - 1 : sizeof(COMPOUND_STRING(str)))
/* Expands to the first/second/third/fourth argument. */
#define FIRST(a, ...) a

File diff suppressed because it is too large Load Diff

View File

@ -776,7 +776,9 @@ static u16 SanitizeItemId(u16 itemId)
const u8 *GetItemName(u16 itemId)
{
return gItemsInfo[SanitizeItemId(itemId)].name;
const u8 *name = gItemsInfo[SanitizeItemId(itemId)].name;
return name == NULL ? gQuestionMarksItemName : name;
}
u32 GetItemPrice(u16 itemId)
@ -786,7 +788,7 @@ u32 GetItemPrice(u16 itemId)
static bool32 DoesItemHavePluralName(u16 itemId)
{
return (gItemsInfo[SanitizeItemId(itemId)].pluralName[0] != '\0');
return gItemsInfo[SanitizeItemId(itemId)].pluralName != NULL;
}
static const u8 *GetItemPluralName(u16 itemId)