From 16ae740b1919fd200464b0f71cf83cc45706025f Mon Sep 17 00:00:00 2001 From: Rachel Date: Mon, 18 May 2026 12:58:16 -0700 Subject: [PATCH 1/3] rom: Move version and language enums to constants/versions.h --- generated/meson.build | 1 - generated/versions.txt | 12 ---- include/constants/versions.h | 35 +++++++++++ include/global/pm_version.h | 10 +-- include/main_menu/main_menu_util.h | 4 +- meson.build | 2 +- res/field/scripts/scripts_pal_park_lobby.s | 2 +- res/field/scripts/scripts_spear_pillar.s | 2 +- src/applications/pokedex/infomain_foreign.c | 15 ++--- .../rowan_intro/rowan_intro_app.c | 1 + src/applications/trainer_case/main.c | 9 ++- src/cutscenes/hall_of_fame.c | 7 ++- src/game_version.c | 2 + src/main.c | 1 + src/main_menu/gba_convert_string.c | 30 ++++----- src/main_menu/main_menu_util.c | 3 +- src/main_menu/ov97_02235D18.c | 63 ++++++++++--------- src/main_menu/ranger_link.c | 4 +- src/map_header.c | 1 + src/map_header_data.c | 1 + src/overlay005/honey_tree.c | 2 +- src/overlay006/dual_slot_encounters.c | 3 +- src/overlay006/ov6_0223E140.c | 1 + src/overlay066/ov66_0222DDF0.c | 17 +++-- src/overlay069/ov69_0225C700.c | 4 +- src/overlay092/ov92_021D0D80.c | 3 +- src/overlay104/ov104_0222DCE0.c | 2 - src/pokedex_language.c | 15 +++-- src/unk_02014D38.c | 15 ++--- src/unk_0205B33C.c | 17 +++-- src/unk_0205DFC4.c | 1 + src/unk_02092494.c | 5 +- tools/devtools/gen_compile_commands.py | 2 +- 33 files changed, 158 insertions(+), 134 deletions(-) delete mode 100644 generated/versions.txt create mode 100644 include/constants/versions.h diff --git a/generated/meson.build b/generated/meson.build index 32a41c092e..64bd6a11fc 100644 --- a/generated/meson.build +++ b/generated/meson.build @@ -115,7 +115,6 @@ metang_generators = { 'traps': { 'type': 'enum', 'tag': 'Trap' }, 'tutor_locations': {'type': 'enum', 'tag': 'TutorLocation'}, 'vars_flags': {'type': 'enum', 'tag': 'VarFlag'}, - 'versions': {'type': 'enum', 'tag': 'Version'}, 'villa_furniture_type': {'type': 'enum', 'tag': 'VillaFurnitureType'}, 'mart_specialties_id': {'type': 'enum', 'tag': 'MartSpecialtiesID'}, 'mart_decor_id': {'type': 'enum', 'tag': 'MartDecorID'}, diff --git a/generated/versions.txt b/generated/versions.txt deleted file mode 100644 index b2781716ac..0000000000 --- a/generated/versions.txt +++ /dev/null @@ -1,12 +0,0 @@ -VERSION_NONE -VERSION_SAPPHIRE -VERSION_RUBY -VERSION_EMERALD -VERSION_FIRERED -VERSION_LEAFGREEN -VERSION_HEARTGOLD = 7 -VERSION_SOULSILVER -VERSION_DIAMOND = 10 -VERSION_PEARL -VERSION_PLATINUM -VERSION_GAMECUBE = 15 # Both Colosseum and XD use the same ID diff --git a/include/constants/versions.h b/include/constants/versions.h new file mode 100644 index 0000000000..a4180489e5 --- /dev/null +++ b/include/constants/versions.h @@ -0,0 +1,35 @@ +#ifndef POKEPLATINUM_CONSTANTS_VERSIONS_H +#define POKEPLATINUM_CONSTANTS_VERSIONS_H + +enum Version { + VERSION_NONE = 0, + VERSION_SAPPHIRE, + VERSION_RUBY, + VERSION_EMERALD, + VERSION_FIRERED, + VERSION_LEAFGREEN, + VERSION_UNUSED_6, + VERSION_HEARTGOLD, + VERSION_SOULSILVER, + VERSION_UNUSED_9, + VERSION_DIAMOND, + VERSION_PEARL, + VERSION_PLATINUM, + VERSION_UNUSED_13, + VERSION_UNUSED_14, + VERSION_GAMECUBE, // Both Colosseum and XD use the same ID +}; + +enum Language { + LANGUAGE_NONE = 0, + LANGUAGE_JAPANESE, + LANGUAGE_ENGLISH, + LANGUAGE_FRENCH, + LANGUAGE_ITALIAN, + LANGUAGE_GERMAN, + LANGUAGE_UNUSED_6, + LANGUAGE_SPANISH, + LANGUAGE_KOREAN, +}; + +#endif // POKEPLATINUM_CONSTANTS_VERSIONS_H diff --git a/include/global/pm_version.h b/include/global/pm_version.h index 0ebc6dd311..39cec3d75d 100644 --- a/include/global/pm_version.h +++ b/include/global/pm_version.h @@ -1,15 +1,7 @@ #ifndef POKEPLATINUM_PM_VERSION_H #define POKEPLATINUM_PM_VERSION_H -#include "generated/versions.h" - -#define JAPANESE 1 -#define ENGLISH 2 -#define FRENCH 3 -#define ITALIAN 4 -#define GERMAN 5 -#define SPANISH 7 -#define KOREAN 8 +#include "constants/versions.h" extern const u8 gGameVersion; extern const u8 gGameLanguage; diff --git a/include/main_menu/main_menu_util.h b/include/main_menu/main_menu_util.h index e313411044..d81321091c 100644 --- a/include/main_menu/main_menu_util.h +++ b/include/main_menu/main_menu_util.h @@ -1,6 +1,9 @@ #ifndef POKEPLATINUM_MAIN_MENU_MAIN_MENU_UTIL_H #define POKEPLATINUM_MAIN_MENU_MAIN_MENU_UTIL_H +#include "constants/versions.h" +#include "generated/fade_types.h" + #include "main_menu/mystery_gift_app.h" #include "bg_window.h" @@ -9,7 +12,6 @@ #include "overlay_manager.h" #include "palette.h" #include "savedata.h" -#include "screen_fade.h" #include "sprite.h" #include "sprite_resource.h" #include "sprite_util.h" diff --git a/meson.build b/meson.build index a17124a045..1a922b66ea 100644 --- a/meson.build +++ b/meson.build @@ -64,7 +64,7 @@ add_global_arguments(c_args, pokeplatinum_args = [ '-DPM_KEEP_ASSERTS', '-DGAME_VERSION=VERSION_PLATINUM', - '-DGAME_LANGUAGE=ENGLISH' + '-DGAME_LANGUAGE=LANGUAGE_ENGLISH' ] if get_option('gdb_debugging') diff --git a/res/field/scripts/scripts_pal_park_lobby.s b/res/field/scripts/scripts_pal_park_lobby.s index 425b6894d1..e3f65390a4 100644 --- a/res/field/scripts/scripts_pal_park_lobby.s +++ b/res/field/scripts/scripts_pal_park_lobby.s @@ -2,8 +2,8 @@ #include "res/text/bank/menu_entries.h" #include "res/text/bank/pal_park_lobby.h" #include "res/field/events/events_pal_park_lobby.h" -#include "generated/versions.h" #include "constants/pokemon.h" +#include "constants/versions.h" ScriptEntry PalParkLobby_OnTransition diff --git a/res/field/scripts/scripts_spear_pillar.s b/res/field/scripts/scripts_spear_pillar.s index a199230463..ed6105291f 100644 --- a/res/field/scripts/scripts_spear_pillar.s +++ b/res/field/scripts/scripts_spear_pillar.s @@ -2,7 +2,7 @@ #include "generated/distribution_events.h" #include "res/text/bank/spear_pillar.h" #include "res/field/events/events_spear_pillar.h" -#include "generated/versions.h" +#include "constants/versions.h" ScriptEntry SpearPillar_OnTransition diff --git a/src/applications/pokedex/infomain_foreign.c b/src/applications/pokedex/infomain_foreign.c index 471ce233ea..0282e50301 100644 --- a/src/applications/pokedex/infomain_foreign.c +++ b/src/applications/pokedex/infomain_foreign.c @@ -3,6 +3,8 @@ #include #include +#include "constants/versions.h" + #include "applications/pokedex/ov21_021E29DC.h" #include "applications/pokedex/pokedex_app.h" #include "applications/pokedex/pokedex_data_manager.h" @@ -21,7 +23,6 @@ #include "heap.h" #include "message.h" #include "narc.h" -#include "pokemon.h" #include "pokemon_sprite.h" #include "sprite.h" #include "sprite_resource.h" @@ -772,22 +773,22 @@ static int LanguageMessage(int languageID) int entryID; switch (languageID) { - case JAPANESE: + case LANGUAGE_JAPANESE: entryID = pl_msg_pokedex_japanese; break; - case ENGLISH: + case LANGUAGE_ENGLISH: entryID = pl_msg_pokedex_english; break; - case FRENCH: + case LANGUAGE_FRENCH: entryID = pl_msg_pokedex_french; break; - case ITALIAN: + case LANGUAGE_ITALIAN: entryID = pl_msg_pokedex_italian; break; - case GERMAN: + case LANGUAGE_GERMAN: entryID = pl_msg_pokedex_german; break; - case SPANISH: + case LANGUAGE_SPANISH: entryID = pl_msg_pokedex_spanish; break; default: diff --git a/src/applications/rowan_intro/rowan_intro_app.c b/src/applications/rowan_intro/rowan_intro_app.c index ec8eb617b8..5ad5d76907 100644 --- a/src/applications/rowan_intro/rowan_intro_app.c +++ b/src/applications/rowan_intro/rowan_intro_app.c @@ -3,6 +3,7 @@ #include "constants/heap.h" #include "constants/string.h" +#include "constants/versions.h" #include "generated/genders.h" #include "applications/naming_screen.h" diff --git a/src/applications/trainer_case/main.c b/src/applications/trainer_case/main.c index 5d377d396b..67133382a2 100644 --- a/src/applications/trainer_case/main.c +++ b/src/applications/trainer_case/main.c @@ -3,8 +3,10 @@ #include #include "constants/trainer_card_levels.h" +#include "constants/versions.h" #include "generated/genders.h" +#include "applications/trainer_case/badge_chimes.h" #include "applications/trainer_case/card_text.h" #include "applications/trainer_case/defs.h" #include "applications/trainer_case/sprites.h" @@ -124,7 +126,7 @@ static void TrainerCase_ResetBadgePolishingDirection(BadgePolishingState *badgeP static void TrainerCase_ResetBadgePolishingState(BadgePolishingState *badgePolishingState); static void TrainerCase_PlayPolishingSoundEffects(BadgePolishingState *badgePolishingState); static void TrainerCase_ConvertSignature1BppTo8Bpp(const u8 *signature1Bpp, u8 *signature8BppOut); -static void TrainerCase_DisplaySignature(BgConfig *bgConfig, enum BgLayer bgLayer, const u8 *signature); +static void TrainerCase_DisplaySignature(BgConfig *bgConfig, enum BgLayer bgLayer, u8 *signature); static void TrainerCase_PlayOpenCloseBadgeCaseSoundEffect(int unused); static void TrainerCase_UpdatePlayTime(TrainerCaseApp *trainerCaseApp, u8 liveTimeDisplay); static int TrainerCase_CheckBadgeOrButtonTouched(BgConfig *bgConfig, const TouchScreenRect rects[]); @@ -312,7 +314,7 @@ BOOL TrainerCaseApp_Main(ApplicationManager *appMan, int *state) break; - case TRAINER_CASE_STATE_MAIN: + case TRAINER_CASE_STATE_MAIN: { int input = TrainerCase_GetPlayerInput(trainerCaseApp); if (input == INPUT_TOUCH_SCREEN_TAP) { @@ -367,6 +369,7 @@ BOOL TrainerCaseApp_Main(ApplicationManager *appMan, int *state) TrainerCase_UpdatePlayTime(trainerCaseApp, trainerCaseApp->trainerCase->liveTimeDisplay); break; + } case TRAINER_CASE_STATE_EXIT: if (IsScreenFadeDone()) { return TRUE; @@ -1240,7 +1243,7 @@ static void TrainerCase_ConvertSignature1BppTo8Bpp(const u8 *signature1Bpp, u8 * } } -static void TrainerCase_DisplaySignature(BgConfig *bgConfig, enum BgLayer bgLayer, const u8 *signature) +static void TrainerCase_DisplaySignature(BgConfig *bgConfig, enum BgLayer bgLayer, u8 *signature) { Bg_LoadTiles(bgConfig, bgLayer, signature, SIGNATURE_WIDTH * SIGNATURE_HEIGHT * TILE_SIZE_8BPP, 1); diff --git a/src/cutscenes/hall_of_fame.c b/src/cutscenes/hall_of_fame.c index f6b1caa42a..e8c2961f28 100644 --- a/src/cutscenes/hall_of_fame.c +++ b/src/cutscenes/hall_of_fame.c @@ -1,7 +1,8 @@ #include "cutscenes/hall_of_fame.h" #include -#include + +#include "constants/versions.h" #include "struct_defs/hall_of_fame_display_data.h" #include "struct_defs/sprite_animation_frame.h" @@ -14,7 +15,6 @@ #include "graphics.h" #include "gx_layers.h" #include "heap.h" -#include "inlines.h" #include "math_util.h" #include "message.h" #include "narc.h" @@ -352,7 +352,7 @@ BOOL HallOfFameManager_Init(ApplicationManager *appMan, int *state) BOOL HallOfFameManager_Exit(ApplicationManager *appMan, int *state) { switch (*state) { - case 0: + case 0: { HallOfFameMan *hallOfFameMan = ApplicationManager_Data(appMan); SysTask_Done(hallOfFameMan->task_1C28); @@ -372,6 +372,7 @@ BOOL HallOfFameManager_Exit(ApplicationManager *appMan, int *state) Heap_Destroy(HEAP_ID_HALL_OF_FAME); (*state)++; break; + } case 1: if (ov86_0223CD80()) { return TRUE; diff --git a/src/game_version.c b/src/game_version.c index feea1295c5..c83140e68c 100644 --- a/src/game_version.c +++ b/src/game_version.c @@ -1,2 +1,4 @@ +#include "constants/versions.h" + const u8 gGameVersion = GAME_VERSION; const u8 gGameLanguage = GAME_LANGUAGE; diff --git a/src/main.c b/src/main.c index 6c8405d22e..2f86d6b47a 100644 --- a/src/main.c +++ b/src/main.c @@ -4,6 +4,7 @@ #include "constants/graphics.h" #include "constants/heap.h" +#include "constants/versions.h" #include "assert.h" #include "brightness_controller.h" diff --git a/src/main_menu/gba_convert_string.c b/src/main_menu/gba_convert_string.c index 859ab8c6e3..876720df46 100644 --- a/src/main_menu/gba_convert_string.c +++ b/src/main_menu/gba_convert_string.c @@ -1,9 +1,9 @@ #include "main_menu/gba_convert_string.h" #include -#include #include "constants/charcode.h" +#include "constants/versions.h" #include "charcode.h" @@ -262,22 +262,22 @@ static const charcode_t sGBACharToDSChars[][2] = { static u16 GetSpaceChar(u32 language) { - return (language == JAPANESE) ? CHAR_WIDE_SPACE : CHAR_SPACE; + return (language == LANGUAGE_JAPANESE) ? CHAR_WIDE_SPACE : CHAR_SPACE; } static u16 GetDoubleQuoteOpenChar(u32 language) { switch (language) { - case JAPANESE: + case LANGUAGE_JAPANESE: default: return CHAR_JP_DOUBLE_QUOTE_OPEN; - case ENGLISH: - case ITALIAN: - case SPANISH: + case LANGUAGE_ENGLISH: + case LANGUAGE_ITALIAN: + case LANGUAGE_SPANISH: return CHAR_DOUBLE_QUOTE_OPEN; - case FRENCH: + case LANGUAGE_FRENCH: return CHAR_DOUBLE_PAREN_OPEN; - case GERMAN: + case LANGUAGE_GERMAN: return CHAR_DOUBLE_QUOTE_CLOSE_INVERTED; } } @@ -285,23 +285,23 @@ static u16 GetDoubleQuoteOpenChar(u32 language) static u16 GetDoubleQuoteCloseChar(u32 language) { switch (language) { - case JAPANESE: + case LANGUAGE_JAPANESE: default: return CHAR_JP_DOUBLE_QUOTE_CLOSE; - case ENGLISH: - case ITALIAN: - case SPANISH: + case LANGUAGE_ENGLISH: + case LANGUAGE_ITALIAN: + case LANGUAGE_SPANISH: return CHAR_DOUBLE_QUOTE_CLOSE; - case FRENCH: + case LANGUAGE_FRENCH: return CHAR_DOUBLE_PAREN_CLOSE; - case GERMAN: + case LANGUAGE_GERMAN: return CHAR_DOUBLE_QUOTE_OPEN; } } BOOL GBA_ConvertStringToDS(const u8 *src, charcode_t *dst, u32 length, u32 language) { - BOOL nonJa = (language != JAPANESE); + BOOL nonJa = (language != LANGUAGE_JAPANESE); u32 i; for (i = 0; i < (length - 1); i++) { diff --git a/src/main_menu/main_menu_util.c b/src/main_menu/main_menu_util.c index af800a2467..eadc679992 100644 --- a/src/main_menu/main_menu_util.c +++ b/src/main_menu/main_menu_util.c @@ -7,7 +7,7 @@ #include "constants/forms.h" #include "constants/graphics.h" #include "constants/narc.h" -#include "constants/species.h" +#include "constants/versions.h" #include "generated/items.h" #include "main_menu/mystery_gift_app.h" @@ -42,7 +42,6 @@ #include "system.h" #include "text.h" #include "unk_02033200.h" -#include "versions.h" #include "vram_transfer.h" #include "res/graphics/main_menu/main_menu_graphics.naix" diff --git a/src/main_menu/ov97_02235D18.c b/src/main_menu/ov97_02235D18.c index 24cbc0e630..3a3b23c744 100644 --- a/src/main_menu/ov97_02235D18.c +++ b/src/main_menu/ov97_02235D18.c @@ -1,7 +1,8 @@ #include "main_menu/ov97_02235D18.h" #include -#include + +#include "constants/versions.h" #include "main_menu/gba_save.h" @@ -579,40 +580,40 @@ GBASaveBlock2 *GetGBASaveBlock2(void) static const GBAPokemonCartInfo sGBAPokemonCartInfo[30] = { // Ruby - { 'JVXA', AGB_SET_RUBYSAPP, AGB_TYPE_RUBY, JAPANESE }, - { 'EVXA', AGB_SET_RUBYSAPP, AGB_TYPE_RUBY, ENGLISH }, - { 'FVXA', AGB_SET_RUBYSAPP, AGB_TYPE_RUBY, FRENCH }, - { 'DVXA', AGB_SET_RUBYSAPP, AGB_TYPE_RUBY, GERMAN }, - { 'SVXA', AGB_SET_RUBYSAPP, AGB_TYPE_RUBY, SPANISH }, - { 'IVXA', AGB_SET_RUBYSAPP, AGB_TYPE_RUBY, ITALIAN }, + { 'JVXA', AGB_SET_RUBYSAPP, AGB_TYPE_RUBY, LANGUAGE_JAPANESE }, + { 'EVXA', AGB_SET_RUBYSAPP, AGB_TYPE_RUBY, LANGUAGE_ENGLISH }, + { 'FVXA', AGB_SET_RUBYSAPP, AGB_TYPE_RUBY, LANGUAGE_FRENCH }, + { 'DVXA', AGB_SET_RUBYSAPP, AGB_TYPE_RUBY, LANGUAGE_GERMAN }, + { 'SVXA', AGB_SET_RUBYSAPP, AGB_TYPE_RUBY, LANGUAGE_SPANISH }, + { 'IVXA', AGB_SET_RUBYSAPP, AGB_TYPE_RUBY, LANGUAGE_ITALIAN }, // Sapphire - { 'JPXA', AGB_SET_RUBYSAPP, AGB_TYPE_SAPPHIRE, JAPANESE }, - { 'EPXA', AGB_SET_RUBYSAPP, AGB_TYPE_SAPPHIRE, ENGLISH }, - { 'FPXA', AGB_SET_RUBYSAPP, AGB_TYPE_SAPPHIRE, FRENCH }, - { 'DPXA', AGB_SET_RUBYSAPP, AGB_TYPE_SAPPHIRE, GERMAN }, - { 'SPXA', AGB_SET_RUBYSAPP, AGB_TYPE_SAPPHIRE, SPANISH }, - { 'IPXA', AGB_SET_RUBYSAPP, AGB_TYPE_SAPPHIRE, ITALIAN }, + { 'JPXA', AGB_SET_RUBYSAPP, AGB_TYPE_SAPPHIRE, LANGUAGE_JAPANESE }, + { 'EPXA', AGB_SET_RUBYSAPP, AGB_TYPE_SAPPHIRE, LANGUAGE_ENGLISH }, + { 'FPXA', AGB_SET_RUBYSAPP, AGB_TYPE_SAPPHIRE, LANGUAGE_FRENCH }, + { 'DPXA', AGB_SET_RUBYSAPP, AGB_TYPE_SAPPHIRE, LANGUAGE_GERMAN }, + { 'SPXA', AGB_SET_RUBYSAPP, AGB_TYPE_SAPPHIRE, LANGUAGE_SPANISH }, + { 'IPXA', AGB_SET_RUBYSAPP, AGB_TYPE_SAPPHIRE, LANGUAGE_ITALIAN }, // FireRed - { 'JRPB', AGB_SET_FIRELEAF, AGB_TYPE_FIRERED, JAPANESE }, - { 'ERPB', AGB_SET_FIRELEAF, AGB_TYPE_FIRERED, ENGLISH }, - { 'FRPB', AGB_SET_FIRELEAF, AGB_TYPE_FIRERED, FRENCH }, - { 'DRPB', AGB_SET_FIRELEAF, AGB_TYPE_FIRERED, GERMAN }, - { 'SRPB', AGB_SET_FIRELEAF, AGB_TYPE_FIRERED, SPANISH }, - { 'IRPB', AGB_SET_FIRELEAF, AGB_TYPE_FIRERED, ITALIAN }, + { 'JRPB', AGB_SET_FIRELEAF, AGB_TYPE_FIRERED, LANGUAGE_JAPANESE }, + { 'ERPB', AGB_SET_FIRELEAF, AGB_TYPE_FIRERED, LANGUAGE_ENGLISH }, + { 'FRPB', AGB_SET_FIRELEAF, AGB_TYPE_FIRERED, LANGUAGE_FRENCH }, + { 'DRPB', AGB_SET_FIRELEAF, AGB_TYPE_FIRERED, LANGUAGE_GERMAN }, + { 'SRPB', AGB_SET_FIRELEAF, AGB_TYPE_FIRERED, LANGUAGE_SPANISH }, + { 'IRPB', AGB_SET_FIRELEAF, AGB_TYPE_FIRERED, LANGUAGE_ITALIAN }, // LeafGreen - { 'JGPB', AGB_SET_FIRELEAF, AGB_TYPE_LEAFGREEN, JAPANESE }, - { 'EGPB', AGB_SET_FIRELEAF, AGB_TYPE_LEAFGREEN, ENGLISH }, - { 'FGPB', AGB_SET_FIRELEAF, AGB_TYPE_LEAFGREEN, FRENCH }, - { 'DGPB', AGB_SET_FIRELEAF, AGB_TYPE_LEAFGREEN, GERMAN }, - { 'SGPB', AGB_SET_FIRELEAF, AGB_TYPE_LEAFGREEN, SPANISH }, - { 'IGPB', AGB_SET_FIRELEAF, AGB_TYPE_LEAFGREEN, ITALIAN }, + { 'JGPB', AGB_SET_FIRELEAF, AGB_TYPE_LEAFGREEN, LANGUAGE_JAPANESE }, + { 'EGPB', AGB_SET_FIRELEAF, AGB_TYPE_LEAFGREEN, LANGUAGE_ENGLISH }, + { 'FGPB', AGB_SET_FIRELEAF, AGB_TYPE_LEAFGREEN, LANGUAGE_FRENCH }, + { 'DGPB', AGB_SET_FIRELEAF, AGB_TYPE_LEAFGREEN, LANGUAGE_GERMAN }, + { 'SGPB', AGB_SET_FIRELEAF, AGB_TYPE_LEAFGREEN, LANGUAGE_SPANISH }, + { 'IGPB', AGB_SET_FIRELEAF, AGB_TYPE_LEAFGREEN, LANGUAGE_ITALIAN }, // Emerald - { 'JEPB', AGB_SET_EMERALD, AGB_TYPE_EMERALD, JAPANESE }, - { 'EEPB', AGB_SET_EMERALD, AGB_TYPE_EMERALD, ENGLISH }, - { 'FEPB', AGB_SET_EMERALD, AGB_TYPE_EMERALD, FRENCH }, - { 'DEPB', AGB_SET_EMERALD, AGB_TYPE_EMERALD, GERMAN }, - { 'SEPB', AGB_SET_EMERALD, AGB_TYPE_EMERALD, SPANISH }, - { 'IEPB', AGB_SET_EMERALD, AGB_TYPE_EMERALD, ITALIAN } + { 'JEPB', AGB_SET_EMERALD, AGB_TYPE_EMERALD, LANGUAGE_JAPANESE }, + { 'EEPB', AGB_SET_EMERALD, AGB_TYPE_EMERALD, LANGUAGE_ENGLISH }, + { 'FEPB', AGB_SET_EMERALD, AGB_TYPE_EMERALD, LANGUAGE_FRENCH }, + { 'DEPB', AGB_SET_EMERALD, AGB_TYPE_EMERALD, LANGUAGE_GERMAN }, + { 'SEPB', AGB_SET_EMERALD, AGB_TYPE_EMERALD, LANGUAGE_SPANISH }, + { 'IEPB', AGB_SET_EMERALD, AGB_TYPE_EMERALD, LANGUAGE_ITALIAN }, }; static u8 Unk_ov97_0223EC04[] = { diff --git a/src/main_menu/ranger_link.c b/src/main_menu/ranger_link.c index e261fe9d4c..4b135ddced 100644 --- a/src/main_menu/ranger_link.c +++ b/src/main_menu/ranger_link.c @@ -1,10 +1,10 @@ #include "main_menu/ranger_link.h" #include -#include #include "constants/charcode.h" #include "constants/graphics.h" +#include "constants/versions.h" #include "game_opening/const_ov77_021D742C.h" #include "main_menu/main_menu_util.h" @@ -17,7 +17,6 @@ #include "savedata/save_table.h" #include "bg_window.h" -#include "enums.h" #include "font.h" #include "game_options.h" #include "graphics.h" @@ -44,7 +43,6 @@ #include "text_banks.h" #include "trainer_info.h" #include "unk_02033200.h" -#include "versions.h" #include "res/graphics/main_menu/main_menu_graphics.naix" #include "res/text/bank/main_menu_alerts.h" diff --git a/src/map_header.c b/src/map_header.c index ded01ff5a0..8c20a79c09 100644 --- a/src/map_header.c +++ b/src/map_header.c @@ -1,5 +1,6 @@ #include "map_header.h" +#include "constants/versions.h" #include "generated/map_headers.h" #include "data/map_headers.h" diff --git a/src/map_header_data.c b/src/map_header_data.c index 03d0514380..3429886dc4 100644 --- a/src/map_header_data.c +++ b/src/map_header_data.c @@ -4,6 +4,7 @@ #include #include "constants/heap.h" +#include "constants/versions.h" #include "field/field_system.h" #include "overlay006/wild_encounters.h" diff --git a/src/overlay005/honey_tree.c b/src/overlay005/honey_tree.c index 4412b103c8..3f09c91a64 100644 --- a/src/overlay005/honey_tree.c +++ b/src/overlay005/honey_tree.c @@ -1,9 +1,9 @@ #include "overlay005/honey_tree.h" #include -#include #include "constants/map_object.h" +#include "constants/versions.h" #include "generated/map_headers.h" #include "field/field_system.h" diff --git a/src/overlay006/dual_slot_encounters.c b/src/overlay006/dual_slot_encounters.c index 496da20134..9836771335 100644 --- a/src/overlay006/dual_slot_encounters.c +++ b/src/overlay006/dual_slot_encounters.c @@ -1,7 +1,8 @@ #include "overlay006/dual_slot_encounters.h" #include -#include + +#include "constants/versions.h" #include "overlay006/wild_encounters.h" diff --git a/src/overlay006/ov6_0223E140.c b/src/overlay006/ov6_0223E140.c index 2b9167e650..6edd9b8558 100644 --- a/src/overlay006/ov6_0223E140.c +++ b/src/overlay006/ov6_0223E140.c @@ -4,6 +4,7 @@ #include #include "constants/species.h" +#include "constants/versions.h" #include "generated/movement_actions.h" #include "struct_decls/map_object.h" diff --git a/src/overlay066/ov66_0222DDF0.c b/src/overlay066/ov66_0222DDF0.c index 47439a57d3..9f5dae707a 100644 --- a/src/overlay066/ov66_0222DDF0.c +++ b/src/overlay066/ov66_0222DDF0.c @@ -5,6 +5,7 @@ #include #include +#include "constants/versions.h" #include "generated/game_records.h" #include "generated/journal_online_events.h" #include "generated/species.h" @@ -13,7 +14,6 @@ #include "struct_decls/struct_0207E060_decl.h" #include "struct_defs/wi_fi_history.h" -#include "global/pm_version.h" #include "overlay066/ov66_02231428.h" #include "overlay066/ov66_0223177C.h" #include "overlay066/ov66_022324F0.h" @@ -44,7 +44,6 @@ #include "font.h" #include "game_records.h" #include "heap.h" -#include "inlines.h" #include "journal.h" #include "math_util.h" #include "message.h" @@ -1144,7 +1143,7 @@ u32 ov66_0222E80C(const UnkStruct_ov66_0222E71C *param0) if (ov66_0222E824(param0) == TRUE) { language = param0->language; } else { - language = ENGLISH; + language = LANGUAGE_ENGLISH; } return language; @@ -1154,12 +1153,12 @@ u32 ov66_0222E80C(const UnkStruct_ov66_0222E71C *param0) BOOL ov66_0222E824(const UnkStruct_ov66_0222E71C *param0) { switch (param0->language) { - case JAPANESE: - case ENGLISH: - case FRENCH: - case ITALIAN: - case GERMAN: - case SPANISH: + case LANGUAGE_JAPANESE: + case LANGUAGE_ENGLISH: + case LANGUAGE_FRENCH: + case LANGUAGE_ITALIAN: + case LANGUAGE_GERMAN: + case LANGUAGE_SPANISH: return TRUE; default: break; diff --git a/src/overlay069/ov69_0225C700.c b/src/overlay069/ov69_0225C700.c index c2e0aca74a..e6e4e49d5e 100644 --- a/src/overlay069/ov69_0225C700.c +++ b/src/overlay069/ov69_0225C700.c @@ -4,10 +4,10 @@ #include #include "constants/graphics.h" +#include "constants/versions.h" #include "struct_defs/wi_fi_history.h" -#include "global/pm_version.h" #include "overlay066/ov66_0222DDF0.h" #include "overlay066/ov66_02231428.h" #include "overlay066/struct_ov66_02230F50.h" @@ -1329,7 +1329,7 @@ static void ov69_0225D2A8(UnkStruct_ov69_0225CE64 *param0, const UnkStruct_ov66_ param0->unk_04.unk_00_1 = 0; param0->unk_04.unk_00_0 = 0; - if (gGameLanguage == JAPANESE) { + if (gGameLanguage == LANGUAGE_JAPANESE) { param0->unk_04.unk_00_1 = 1; } else { param0->unk_04.unk_00_1 = 0; diff --git a/src/overlay092/ov92_021D0D80.c b/src/overlay092/ov92_021D0D80.c index a0446936c7..44f52395bd 100644 --- a/src/overlay092/ov92_021D0D80.c +++ b/src/overlay092/ov92_021D0D80.c @@ -4,6 +4,7 @@ #include #include "constants/graphics.h" +#include "constants/versions.h" #include "struct_defs/wi_fi_history.h" @@ -314,7 +315,7 @@ int ov92_021D0D80(ApplicationManager *appMan, int *unused) memset(v0, 0, sizeof(UnkStruct_ov92_021D1B24)); v0->heapID = heapID; - v0->unk_BAF0 = gGameLanguage == JAPANESE; + v0->unk_BAF0 = gGameLanguage == LANGUAGE_JAPANESE; SaveData *saveData = ApplicationManager_Args(appMan); diff --git a/src/overlay104/ov104_0222DCE0.c b/src/overlay104/ov104_0222DCE0.c index 178c9685fb..3857fbe8ed 100644 --- a/src/overlay104/ov104_0222DCE0.c +++ b/src/overlay104/ov104_0222DCE0.c @@ -1,7 +1,6 @@ #include "overlay104/ov104_0222DCE0.h" #include -#include #include "constants/heap.h" #include "constants/narc.h" @@ -34,7 +33,6 @@ #include "unk_02038F8C.h" #include "unk_0208C098.h" #include "unk_02092494.h" -#include "versions.h" #include "wifi_history_save_data.h" static const u16 sTrainerClassToObjectID[][2] = { diff --git a/src/pokedex_language.c b/src/pokedex_language.c index 1e7d313733..89a814a660 100644 --- a/src/pokedex_language.c +++ b/src/pokedex_language.c @@ -1,17 +1,16 @@ #include "pokedex_language.h" #include -#include -#include "global/pm_version.h" +#include "constants/versions.h" static const u8 languageArray[NUM_LANGUAGES] = { - JAPANESE, - ENGLISH, - FRENCH, - GERMAN, - ITALIAN, - SPANISH + LANGUAGE_JAPANESE, + LANGUAGE_ENGLISH, + LANGUAGE_FRENCH, + LANGUAGE_GERMAN, + LANGUAGE_ITALIAN, + LANGUAGE_SPANISH }; int PokedexLanguage_LanguageToIndex(int language) diff --git a/src/unk_02014D38.c b/src/unk_02014D38.c index 4f08142da8..8bf6e7fde6 100644 --- a/src/unk_02014D38.c +++ b/src/unk_02014D38.c @@ -3,11 +3,12 @@ #include #include +#include "constants/versions.h" + #include "graphics.h" #include "heap.h" #include "math_util.h" #include "message.h" -#include "narc.h" #include "savedata.h" #include "string_gf.h" @@ -237,12 +238,12 @@ void SentenceSaveData_Init(void *param0) u8 language; u8 unk_01; } v0[] = { - { JAPANESE, 0x0 }, - { ENGLISH, 0x1 }, - { FRENCH, 0x2 }, - { ITALIAN, 0x3 }, - { GERMAN, 0x4 }, - { SPANISH, 0x5 } + { LANGUAGE_JAPANESE, 0x0 }, + { LANGUAGE_ENGLISH, 0x1 }, + { LANGUAGE_FRENCH, 0x2 }, + { LANGUAGE_ITALIAN, 0x3 }, + { LANGUAGE_GERMAN, 0x4 }, + { LANGUAGE_SPANISH, 0x5 } }; UnkStruct_02014EC4 *v1 = param0; int i; diff --git a/src/unk_0205B33C.c b/src/unk_0205B33C.c index 558d09eee5..ff89688815 100644 --- a/src/unk_0205B33C.c +++ b/src/unk_0205B33C.c @@ -1,9 +1,9 @@ #include "unk_0205B33C.h" #include -#include #include "constants/union_room_message_types.h" +#include "constants/versions.h" #include "struct_decls/struct_02014EC4_decl.h" #include "struct_decls/struct_0205B43C_decl.h" @@ -12,7 +12,6 @@ #include "struct_defs/struct_0205B4F8.h" #include "field/field_system.h" -#include "global/pm_version.h" #include "appearance.h" #include "communication_information.h" @@ -1280,7 +1279,7 @@ void UnionRoom_DoGreeting(StringTemplate *strTemplate, int param1, int param2, T int language = TrainerInfo_Language(commTrainerInfo); - if (language >= JAPANESE && language <= SPANISH) { + if (language >= LANGUAGE_JAPANESE && language <= LANGUAGE_SPANISH) { static const int v5[] = { 0, 1, @@ -1298,22 +1297,22 @@ void UnionRoom_DoGreeting(StringTemplate *strTemplate, int param1, int param2, T } switch (language) { - case JAPANESE: + case LANGUAGE_JAPANESE: entryID = UnionRoom_Text_GreetingJapanese; break; - case ENGLISH: + case LANGUAGE_ENGLISH: entryID = UnionRoom_Text_GreetingEnglish; break; - case FRENCH: + case LANGUAGE_FRENCH: entryID = UnionRoom_Text_GreetingFrench; break; - case ITALIAN: + case LANGUAGE_ITALIAN: entryID = UnionRoom_Text_GreetingItalian; break; - case GERMAN: + case LANGUAGE_GERMAN: entryID = UnionRoom_Text_GreetingGerman; break; - case SPANISH: + case LANGUAGE_SPANISH: entryID = UnionRoom_Text_GreetingSpanish; break; default: diff --git a/src/unk_0205DFC4.c b/src/unk_0205DFC4.c index 21f7656db4..d19627e537 100644 --- a/src/unk_0205DFC4.c +++ b/src/unk_0205DFC4.c @@ -4,6 +4,7 @@ #include "constants/battle_frontier.h" #include "constants/battle_frontier_stats.h" +#include "constants/versions.h" #include "struct_decls/map_object.h" diff --git a/src/unk_02092494.c b/src/unk_02092494.c index cedb9d9f57..1cf606eadf 100644 --- a/src/unk_02092494.c +++ b/src/unk_02092494.c @@ -1,12 +1,11 @@ #include "unk_02092494.h" #include -#include + +#include "constants/versions.h" #include "struct_defs/struct_02090800.h" -#include "global/pm_version.h" - #include "heap.h" #include "message.h" #include "pokemon.h" diff --git a/tools/devtools/gen_compile_commands.py b/tools/devtools/gen_compile_commands.py index 1a5ec7a110..7be37ec2a4 100755 --- a/tools/devtools/gen_compile_commands.py +++ b/tools/devtools/gen_compile_commands.py @@ -55,7 +55,7 @@ arm9_c_flags = [ "-DPOKEPLATINUM_GENERATED_ENUM", "-DPM_KEEP_ASSERTS", "-DGAME_VERSION=VERSION_PLATINUM", - "-DGAME_LANGUAGE=ENGLISH", + "-DGAME_LANGUAGE=LANGUAGE_ENGLISH", "-DEXPLICIT_WCHAR_TYPEDEF", ] From 19a9b59ddc1d553454cf8202cb9a20ad7f2fbe92 Mon Sep 17 00:00:00 2001 From: Rachel Date: Mon, 18 May 2026 14:45:25 -0700 Subject: [PATCH 2/3] rom: Move NPCTradeID definition to constants/npc_trades.h --- asm/macros/scrcmd.inc | 1 - generated/meson.build | 1 - include/constants/npc_trades.h | 12 ++++++++++++ include/overlay006/npc_trade.h | 10 ++++++---- .../scripts/scripts_eterna_city_condominiums_1f.s | 1 + .../scripts/scripts_oreburgh_city_north_house_1f.s | 1 + res/field/scripts/scripts_route_226_house.s | 1 + .../scripts/scripts_snowpoint_city_west_house.s | 1 + src/overlay006/npc_trade.c | 2 +- 9 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 include/constants/npc_trades.h diff --git a/asm/macros/scrcmd.inc b/asm/macros/scrcmd.inc index 27d3fdc557..57e04f1035 100644 --- a/asm/macros/scrcmd.inc +++ b/asm/macros/scrcmd.inc @@ -18,7 +18,6 @@ #include "generated/movement_types.h" #include "generated/moves.h" #include "generated/mystery_gift_delivery_stages.h" -#include "generated/npc_trades.h" #include "generated/object_events_gfx.h" #include "generated/player_transitions.h" #include "generated/poketch_apps.h" diff --git a/generated/meson.build b/generated/meson.build index 64bd6a11fc..6a9ad2745b 100644 --- a/generated/meson.build +++ b/generated/meson.build @@ -76,7 +76,6 @@ metang_generators = { 'movement_types': { 'type': 'enum', 'tag': 'MovementType' }, 'moves': { 'type': 'enum', 'tag': 'Move' }, 'natures': { 'type': 'enum', 'tag': 'Nature' }, - 'npc_trades': { 'type': 'enum', 'tag': 'NPCTradeID' }, 'object_events_gfx': { 'type': 'enum', 'tag': 'ObjectEventGfx' }, 'pal_park_land_area': { 'type': 'enum', 'tag': 'PalParkLandArea' }, 'pal_park_water_area': { 'type': 'enum', 'tag': 'PalParkWaterArea' }, diff --git a/include/constants/npc_trades.h b/include/constants/npc_trades.h new file mode 100644 index 0000000000..747708b276 --- /dev/null +++ b/include/constants/npc_trades.h @@ -0,0 +1,12 @@ +#ifndef POKEPLATINUM_CONSTANTS_NPC_TRADES_H +#define POKEPLATINUM_CONSTANTS_NPC_TRADES_H + +enum NPCTradeID { + NPC_TRADE_KAZZA_ABRA = 0, + NPC_TRADE_CHARAP_CHATOT, + NPC_TRADE_GASPAR_HAUNTER, + NPC_TRADE_FOPPA_MAGIKARP, + MAX_NPC_TRADES, +}; + +#endif // POKEPLATINUM_CONSTANTS_NPC_TRADES_H diff --git a/include/overlay006/npc_trade.h b/include/overlay006/npc_trade.h index 1d12f15b06..f8912176dc 100644 --- a/include/overlay006/npc_trade.h +++ b/include/overlay006/npc_trade.h @@ -1,11 +1,13 @@ #ifndef POKEPLATINUM_NPC_TRADE_H #define POKEPLATINUM_NPC_TRADE_H +#include "constants/npc_trades.h" + +#include "struct_defs/pokemon.h" + #include "field/field_system_decl.h" #include "overlay006/struct_npc_trade_animation_template.h" -#include "pokemon.h" - typedef struct NPCTradeMon { u32 species; u32 hpIV; @@ -33,7 +35,7 @@ typedef struct NPCTradeData { NPCTradeMon *npcTradeMon; Pokemon *mon; TrainerInfo *trainerInfo; - u32 npcTradeID; + enum NPCTradeID npcTradeID; enum HeapID heapID; } NPCTradeData; @@ -42,6 +44,6 @@ void NPCTrade_Free(NPCTradeData *data); u32 NPCTrade_GetSpecies(const NPCTradeData *data); u32 NPCTrade_GetRequestedSpecies(const NPCTradeData *data); void NPCTrade_ReceiveMon(FieldSystem *fieldSystem, NPCTradeData *data, int slot); -void NPCTrade_FillAnimationTemplate(FieldSystem *fieldSystem, NPCTradeData *data, int slot, TradeAnimationTemplate *param3, Pokemon *givingMon, Pokemon *receivingMon); +void NPCTrade_FillAnimationTemplate(FieldSystem *fieldSystem, NPCTradeData *data, int slot, TradeAnimationTemplate *animationConfig, Pokemon *givingMon, Pokemon *receivingMon); #endif // POKEPLATINUM_NPC_TRADE_H diff --git a/res/field/scripts/scripts_eterna_city_condominiums_1f.s b/res/field/scripts/scripts_eterna_city_condominiums_1f.s index 6e608a5590..1df6f84f77 100644 --- a/res/field/scripts/scripts_eterna_city_condominiums_1f.s +++ b/res/field/scripts/scripts_eterna_city_condominiums_1f.s @@ -1,4 +1,5 @@ #include "macros/scrcmd.inc" +#include "constants/npc_trades.h" #include "res/text/bank/eterna_city_condominiums_1f.h" diff --git a/res/field/scripts/scripts_oreburgh_city_north_house_1f.s b/res/field/scripts/scripts_oreburgh_city_north_house_1f.s index af0aca0b2a..a302537d1f 100644 --- a/res/field/scripts/scripts_oreburgh_city_north_house_1f.s +++ b/res/field/scripts/scripts_oreburgh_city_north_house_1f.s @@ -1,4 +1,5 @@ #include "macros/scrcmd.inc" +#include "constants/npc_trades.h" #include "res/text/bank/oreburgh_city_north_house_1f.h" diff --git a/res/field/scripts/scripts_route_226_house.s b/res/field/scripts/scripts_route_226_house.s index b08fa184d9..c62e3acab5 100644 --- a/res/field/scripts/scripts_route_226_house.s +++ b/res/field/scripts/scripts_route_226_house.s @@ -1,4 +1,5 @@ #include "macros/scrcmd.inc" +#include "constants/npc_trades.h" #include "res/text/bank/route_226_house.h" diff --git a/res/field/scripts/scripts_snowpoint_city_west_house.s b/res/field/scripts/scripts_snowpoint_city_west_house.s index 356fad5548..ed4001796e 100644 --- a/res/field/scripts/scripts_snowpoint_city_west_house.s +++ b/res/field/scripts/scripts_snowpoint_city_west_house.s @@ -1,4 +1,5 @@ #include "macros/scrcmd.inc" +#include "constants/npc_trades.h" #include "res/text/bank/snowpoint_city_west_house.h" diff --git a/src/overlay006/npc_trade.c b/src/overlay006/npc_trade.c index b6d6f12c0c..be45d4fb16 100644 --- a/src/overlay006/npc_trade.c +++ b/src/overlay006/npc_trade.c @@ -3,7 +3,7 @@ #include #include -#include "generated/npc_trades.h" +#include "constants/npc_trades.h" #include "field/field_system.h" #include "overlay006/struct_npc_trade_animation_template.h" From f8e1826b32806a842e535aa5ec88ef334f06f1f5 Mon Sep 17 00:00:00 2001 From: Rachel Date: Mon, 18 May 2026 15:14:49 -0700 Subject: [PATCH 3/3] tools: Implement npctradeproc to replace tools/jsoncnv/npc_trades.py --- generated/meson.build | 1 - generated/npc_trades.txt | 5 - include/overlay006/npc_trade.h | 3 + .../struct_npc_trade_animation_template.h | 3 +- include/trainer_info.h | 2 +- platinum.us/filesys.csv | 2 +- platinum.us/filesys.sha1 | 2 +- res/field/meson.build | 1 - res/field/trades/meson.build | 29 --- res/field/trades/npc_trades.order | 4 - res/meson.build | 20 ++ .../charap_chatot.json} | 4 +- .../foppa_magikarp.json} | 4 +- .../gaspar_haunter.json} | 4 +- .../kazza_abra.json} | 4 +- res/text/meson.build | 10 +- res/text/npc_trade_names.json | 37 --- tools/dataproc/meson.build | 9 + tools/dataproc/src/common.c | 7 +- tools/dataproc/src/common.h | 1 + tools/dataproc/src/npctradeproc.c | 226 ++++++++++++++++++ tools/jsoncnv/meson.build | 1 - tools/jsoncnv/npc_trades.py | 58 ----- 23 files changed, 286 insertions(+), 151 deletions(-) delete mode 100644 generated/npc_trades.txt delete mode 100644 res/field/trades/meson.build delete mode 100644 res/field/trades/npc_trades.order rename res/{field/trades/npc_trade_charap_chatot.json => npc_trades/charap_chatot.json} (83%) rename res/{field/trades/npc_trade_foppa_magikarp.json => npc_trades/foppa_magikarp.json} (83%) rename res/{field/trades/npc_trade_gaspar_haunter.json => npc_trades/gaspar_haunter.json} (83%) rename res/{field/trades/npc_trade_kazza_abra.json => npc_trades/kazza_abra.json} (83%) delete mode 100644 res/text/npc_trade_names.json create mode 100644 tools/dataproc/src/npctradeproc.c delete mode 100755 tools/jsoncnv/npc_trades.py diff --git a/generated/meson.build b/generated/meson.build index 6a9ad2745b..17ecb688d4 100644 --- a/generated/meson.build +++ b/generated/meson.build @@ -160,7 +160,6 @@ foreach gen_key : metang_generators.keys() endforeach moves_txt = files('moves.txt') -npc_trades_txt = files('npc_trades.txt') species_txt = files('species.txt') text_banks_txt = files('text_banks.txt') trainer_classes_txt = files('trainer_classes.txt') diff --git a/generated/npc_trades.txt b/generated/npc_trades.txt deleted file mode 100644 index 7e49199c02..0000000000 --- a/generated/npc_trades.txt +++ /dev/null @@ -1,5 +0,0 @@ -NPC_TRADE_KAZZA_ABRA -NPC_TRADE_CHARAP_CHATOT -NPC_TRADE_GASPAR_HAUNTER -NPC_TRADE_FOPPA_MAGIKARP -MAX_NPC_TRADES diff --git a/include/overlay006/npc_trade.h b/include/overlay006/npc_trade.h index f8912176dc..21bf887307 100644 --- a/include/overlay006/npc_trade.h +++ b/include/overlay006/npc_trade.h @@ -1,6 +1,7 @@ #ifndef POKEPLATINUM_NPC_TRADE_H #define POKEPLATINUM_NPC_TRADE_H +#include "constants/heap.h" #include "constants/npc_trades.h" #include "struct_defs/pokemon.h" @@ -8,6 +9,8 @@ #include "field/field_system_decl.h" #include "overlay006/struct_npc_trade_animation_template.h" +#include "trainer_info.h" + typedef struct NPCTradeMon { u32 species; u32 hpIV; diff --git a/include/overlay006/struct_npc_trade_animation_template.h b/include/overlay006/struct_npc_trade_animation_template.h index a499a039c0..1fbbb111e9 100644 --- a/include/overlay006/struct_npc_trade_animation_template.h +++ b/include/overlay006/struct_npc_trade_animation_template.h @@ -1,8 +1,9 @@ #ifndef POKEPLATINUM_STRUCT_NPC_TRADE_ANIMATION_TEMPLATE_H #define POKEPLATINUM_STRUCT_NPC_TRADE_ANIMATION_TEMPLATE_H +#include "struct_defs/pokemon.h" + #include "game_options.h" -#include "pokemon.h" #include "trainer_info.h" enum TradeType { diff --git a/include/trainer_info.h b/include/trainer_info.h index 31442827d4..7c0d7777ee 100644 --- a/include/trainer_info.h +++ b/include/trainer_info.h @@ -1,9 +1,9 @@ #ifndef POKEPLATINUM_TRAINER_INFO_H #define POKEPLATINUM_TRAINER_INFO_H +#include "constants/heap.h" #include "constants/string.h" -#include "heap.h" #include "string_gf.h" typedef struct TrainerInfo { diff --git a/platinum.us/filesys.csv b/platinum.us/filesys.csv index ae02a26ac8..71806daede 100644 --- a/platinum.us/filesys.csv +++ b/platinum.us/filesys.csv @@ -330,7 +330,7 @@ res/prebuilt/contest/graphic/contest_bg.narc,/contest/graphic/contest_bg.narc res/prebuilt/contest/graphic/contest_obj.narc,/contest/graphic/contest_obj.narc res/prebuilt/demo/title/op_demo.narc,/demo/title/op_demo.narc res/graphics/title_screen/titledemo.narc,/demo/title/titledemo.narc -res/field/trades/fld_trade.narc,/fielddata/pokemon_trade/fld_trade.narc +res/npc_trades.narc,/fielddata/pokemon_trade/fld_trade.narc res/graphics/pokedex/zukan.narc,/resource/eng/zukan/zukan.narc res/prebuilt/resource/eng/batt_rec/batt_rec_gra.narc,/resource/eng/batt_rec/batt_rec_gra.narc res/prebuilt/resource/eng/wifi_lobby_minigame/wlmngm_tool.narc,/resource/eng/wifi_lobby_minigame/wlmngm_tool.narc diff --git a/platinum.us/filesys.sha1 b/platinum.us/filesys.sha1 index 842161f9a9..afaae3b3dd 100644 --- a/platinum.us/filesys.sha1 +++ b/platinum.us/filesys.sha1 @@ -329,7 +329,7 @@ ecdb14e0bc6619f114549e6126c8b6934cfc3aeb *res/prebuilt/battle/b_pl_stage/pl_bsdp cec363028fa6bc6240f9c8da7ab8f9e8bb1b1465 *res/prebuilt/contest/graphic/contest_obj.narc 7fa87d90ba039f67221a43782bf6a1a1107d5947 *res/prebuilt/demo/title/op_demo.narc d7e86fadf59a54f922fc7cf65ae65fa326b8429e *res/graphics/title_screen/titledemo.narc -32a0989a18cc7f3eb17c5949adecb3f057a84eea *res/field/trades/fld_trade.narc +32a0989a18cc7f3eb17c5949adecb3f057a84eea *res/npc_trades.narc d4b6f9731b808a613338005f59959325ce1e3ac9 *res/graphics/pokedex/zukan.narc 7e85af57b27fa4a0829b24550fc6c0dd275cf994 *res/prebuilt/resource/eng/batt_rec/batt_rec_gra.narc 2994f2955035001a22a1f225c68bfa809e4c85bf *res/prebuilt/resource/eng/wifi_lobby_minigame/wlmngm_tool.narc diff --git a/res/field/meson.build b/res/field/meson.build index dad78e7e89..4fce976b3c 100644 --- a/res/field/meson.build +++ b/res/field/meson.build @@ -7,4 +7,3 @@ subdir('matrices') subdir('props') subdir('area_data') subdir('scripts') -subdir('trades') diff --git a/res/field/trades/meson.build b/res/field/trades/meson.build deleted file mode 100644 index f397e22fe8..0000000000 --- a/res/field/trades/meson.build +++ /dev/null @@ -1,29 +0,0 @@ -npc_trades_bin_gen = generator( - npc_trades_py, - arguments: [ '@INPUT@', '@OUTPUT@', ], - output: '@BASENAME@', - depends: [ py_consts_generators ], -) - -npc_trades_consts = fs.read(npc_trades_txt).splitlines() -npc_trades_files = [] -foreach npc_trade: npc_trades_consts - if npc_trade.startswith('MAX_') - continue - endif - npc_trades_files += files(npc_trade.to_lower() + '.json') -endforeach - -npc_trades_narc = custom_target('fld_trade.narc', - output: 'fld_trade.narc', - input: npc_trades_bin_gen.process(npc_trades_files, env: jsoncnv_env), - command: [ - nitroarc_exe, - '--create', - '--files-from', files('npc_trades.order'), - '--file', '@OUTPUT0@', - '@PRIVATE_DIR@', - ], -) - -nitrofs_files += npc_trades_narc diff --git a/res/field/trades/npc_trades.order b/res/field/trades/npc_trades.order deleted file mode 100644 index dfb78964e6..0000000000 --- a/res/field/trades/npc_trades.order +++ /dev/null @@ -1,4 +0,0 @@ -npc_trade_kazza_abra -npc_trade_charap_chatot -npc_trade_gaspar_haunter -npc_trade_foppa_magikarp diff --git a/res/meson.build b/res/meson.build index 15216011f1..0b7cc16ccc 100644 --- a/res/meson.build +++ b/res/meson.build @@ -71,6 +71,26 @@ copy_gen = generator(copy_exe, output: '@PLAINNAME@' ) +npctrade_data = custom_target('npctrade_data', + output: [ + 'npc_trades.narc', + 'npc_trade_names.json', + ], + + command: [ + npctradeproc_exe, + '-M', '@DEPFILE@', + '-o', meson.current_build_dir(), + meson.global_source_root() / 'include' / 'constants' / 'npc_trades.h', + meson.current_source_dir() / 'npc_trades', + ], + + depfile: 'npctrade_data.d' +) + +nitrofs_files += npctrade_data +npctrade_text_banks = npctrade_data[1] + ### DECOMPILED DATA DIRECTORIES ### # These subpaths are listed because the result of some build-rule inside them # is a dependency of some later build-rule. diff --git a/res/field/trades/npc_trade_charap_chatot.json b/res/npc_trades/charap_chatot.json similarity index 83% rename from res/field/trades/npc_trade_charap_chatot.json rename to res/npc_trades/charap_chatot.json index 94c41c58c4..497016db86 100644 --- a/res/field/trades/npc_trade_charap_chatot.json +++ b/res/npc_trades/charap_chatot.json @@ -1,4 +1,6 @@ { + "name": "Charap", + "otName": "Norton", "species": "SPECIES_CHATOT", "hpIV": 15, "atkIV": 20, @@ -17,6 +19,6 @@ "heldItem": "ITEM_LEPPA_BERRY", "otGender": "GENDER_MALE", "unused2": 50, - "language": 2, + "language": "LANGUAGE_ENGLISH", "requestedSpecies": "SPECIES_BUIZEL" } diff --git a/res/field/trades/npc_trade_foppa_magikarp.json b/res/npc_trades/foppa_magikarp.json similarity index 83% rename from res/field/trades/npc_trade_foppa_magikarp.json rename to res/npc_trades/foppa_magikarp.json index c7a147b87b..81fc043c17 100644 --- a/res/field/trades/npc_trade_foppa_magikarp.json +++ b/res/npc_trades/foppa_magikarp.json @@ -1,4 +1,6 @@ { + "name": "Foppa", + "otName": "Meister", "species": "SPECIES_MAGIKARP", "hpIV": 15, "atkIV": 25, @@ -17,6 +19,6 @@ "heldItem": "ITEM_LUM_BERRY", "otGender": "GENDER_MALE", "unused2": 0, - "language": 5, + "language": "LANGUAGE_GERMAN", "requestedSpecies": "SPECIES_FINNEON" } diff --git a/res/field/trades/npc_trade_gaspar_haunter.json b/res/npc_trades/gaspar_haunter.json similarity index 83% rename from res/field/trades/npc_trade_gaspar_haunter.json rename to res/npc_trades/gaspar_haunter.json index 64aa415597..e2e5bdda32 100644 --- a/res/field/trades/npc_trade_gaspar_haunter.json +++ b/res/npc_trades/gaspar_haunter.json @@ -1,4 +1,6 @@ { + "name": "Gaspar", + "otName": "Mindy", "species": "SPECIES_HAUNTER", "hpIV": 20, "atkIV": 25, @@ -17,6 +19,6 @@ "heldItem": "ITEM_EVERSTONE", "otGender": "GENDER_FEMALE", "unused2": 0, - "language": 2, + "language": "LANGUAGE_ENGLISH", "requestedSpecies": "SPECIES_MEDICHAM" } diff --git a/res/field/trades/npc_trade_kazza_abra.json b/res/npc_trades/kazza_abra.json similarity index 83% rename from res/field/trades/npc_trade_kazza_abra.json rename to res/npc_trades/kazza_abra.json index fe8b5a7c25..0e1023de43 100644 --- a/res/field/trades/npc_trade_kazza_abra.json +++ b/res/npc_trades/kazza_abra.json @@ -1,4 +1,6 @@ { + "name": "Kazza", + "otName": "Hilary", "species": "SPECIES_ABRA", "hpIV": 15, "atkIV": 15, @@ -17,6 +19,6 @@ "heldItem": "ITEM_ORAN_BERRY", "otGender": "GENDER_FEMALE", "unused2": 0, - "language": 2, + "language": "LANGUAGE_ENGLISH", "requestedSpecies": "SPECIES_MACHOP" } diff --git a/res/text/meson.build b/res/text/meson.build index 7677da550f..22d7f4b356 100644 --- a/res/text/meson.build +++ b/res/text/meson.build @@ -55,17 +55,14 @@ item_text_bank_names = [ 'item_descriptions.json', ] -town_map_text_bank_name = [ - 'town_map.json' -] - # This list will be what's used hereafter when referring to any-and-all generated banks. generated_text_banks = [ species_text_bank_names, trainer_text_bank_names, frontier_text_bank_names, item_text_bank_names, - town_map_text_bank_name, + 'town_map.json', + 'npc_trade_names.json', ] # 2. All other files must be static. Pull these from `generated/text_banks.txt`. This allows us @@ -113,9 +110,10 @@ text_bank_files += species_text_banks text_bank_files += trainer_text_banks text_bank_files += frontier_text_banks text_bank_files += item_text_banks +text_bank_files += npctrade_text_banks town_map_text_bank = custom_target('town_map_text_bank', - output: town_map_text_bank_name, + output: 'town_map.json', command: [ 'cp', '@OUTDIR@/../town_map/town_map.json', diff --git a/res/text/npc_trade_names.json b/res/text/npc_trade_names.json deleted file mode 100644 index a62b010a2c..0000000000 --- a/res/text/npc_trade_names.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "key": 4839, - "messages": [ - { - "id": "NPCTradeNames_Text_Kazza", - "en_US": "Kazza" - }, - { - "id": "NPCTradeNames_Text_Charap", - "en_US": "Charap" - }, - { - "id": "NPCTradeNames_Text_Gaspar", - "en_US": "Gaspar" - }, - { - "id": "NPCTradeNames_Text_Foppa", - "en_US": "Foppa" - }, - { - "id": "NPCTradeNames_Text_Hilary", - "en_US": "Hilary" - }, - { - "id": "NPCTradeNames_Text_Norton", - "en_US": "Norton" - }, - { - "id": "NPCTradeNames_Text_Mindy", - "en_US": "Mindy" - }, - { - "id": "NPCTradeNames_Text_Meister", - "en_US": "Meister" - } - ] -} diff --git a/tools/dataproc/meson.build b/tools/dataproc/meson.build index e5ccb7ecbd..eed4a29a4f 100644 --- a/tools/dataproc/meson.build +++ b/tools/dataproc/meson.build @@ -111,3 +111,12 @@ itemproc_exe = executable( dependencies: commonproc_dep, native: true, ) + +npctradeproc_exe = executable( + 'npctradeproc', + sources: [ files('src/npctradeproc.c'), c_consts_generators ], + c_args: dataproc_cflags, + include_directories: [ public_includes, toplevel_includes ], + dependencies: commonproc_dep, + native: true, +) diff --git a/tools/dataproc/src/common.c b/tools/dataproc/src/common.c index 90a3fee5e6..2081fda93d 100644 --- a/tools/dataproc/src/common.c +++ b/tools/dataproc/src/common.c @@ -88,12 +88,17 @@ enum_seq_t _common_initenum(initenum_params_t params) { char *data = fload(params.basefile, &size); char *endp = NULL; - enum_seq_t result = libenum_find(data, size, "Item", &endp); + enum_seq_t result = libenum_find(data, size, params.enumname, &endp); if (result.errc != LIBENUM_E_OK) { // handles the empty-case fprintf(stderr, "libenum error: %s\n", libenum_errs(result.errc)); exit(EXIT_FAILURE); } + if (result.members == NULL) { + fprintf(stderr, "could not find enum named '%s' in %s", params.enumname, params.basefile); + exit(EXIT_FAILURE); + } + if (result.size > UINT16_MAX) { fprintf(stderr, "count of enum members %zu exceeds maximum of %u\n", result.size, UINT16_MAX); diff --git a/tools/dataproc/src/common.h b/tools/dataproc/src/common.h index fe9fca9761..e21a745cb8 100644 --- a/tools/dataproc/src/common.h +++ b/tools/dataproc/src/common.h @@ -45,6 +45,7 @@ typedef uint64_t u64; #define boolean(path) (dp_bool(dp_get(df, path))) #define u8(path) (dp_u8(dp_get(df, path))) #define u16(path) (dp_u16(dp_get(df, path))) +#define u32(path) (dp_u32(dp_get(df, path))) #define s8(path) (dp_s8(dp_get(df, path))) #define u8_maxbits(path, bits) (u8)(dp_u8range(dp_get(df, path), 0, maxbit(bits)) & maxbit(bits)) #define enum_u8(path, type) (dp_u8(dp_lookup(dp_get(df, path), #type))) diff --git a/tools/dataproc/src/npctradeproc.c b/tools/dataproc/src/npctradeproc.c new file mode 100644 index 0000000000..7339d009c2 --- /dev/null +++ b/tools/dataproc/src/npctradeproc.c @@ -0,0 +1,226 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "common.h" +#include "dataproc.h" +#include "libenum.h" +#include "nitroarc.h" + +#include "constants/string.h" +#include "overlay006/npc_trade.h" + +static enum_template_t enums[] = { + include_enum("generated/species.h", "enum Species"), + include_enum("generated/items.h", "enum Item"), + include_enum("generated/genders.h", "enum Gender"), + include_enum("constants/versions.h", "enum Language"), + { .from_file = NULL }, +}; + +static archive_template_t archives[] = { + { .out_filename = "npc_trades.narc" }, + { .out_filename = NULL }, +}; + +static textbank_template_t textbanks[] = { + { .out_filename = "npc_trade_names.json", .key = 4839 }, + { .out_filename = NULL }, +}; + +static void parse_args(int *pargc, char ***pargv); +static void prep_trainernames(size_t count); +static void proc_trade(datafile_t *df); +static void proc_text(datafile_t *df, size_t i); +static void pack_trainernames(size_t count); + +static char *filename = NULL; +static char *base_dir = NULL; +static char *depfile_path = "npctrade_data.d"; +static char *output_dir = "."; + +int main(int argc, char **argv) { + int errc = EXIT_SUCCESS; + char buf[BUFSIZE] = { 0 }; + datafile_t df = { 0 }; + + parse_args(&argc, &argv); + enum_seq_t trades = common_initenum( + filename, "NPCTradeID", + .sourcefile = __FILE__, + .depfile = depfile_path, + .outdir = output_dir, + .format = DATAPROC_F_JSON, + .enums = enums, + .archives = archives, + .textbanks = textbanks, + ); + + prep_trainernames(trades.size); + for (size_t i = 0; i < trades.size; i++) { + const char *stem = trades.members[i].name + lengthof("NPC_TRADE_"); + + char *basename = strlower(strfmt("%s.json", stem)); + char *filepath = pathjoin(base_dir, NULL, basename); + declare_dep(filepath); + + if (dp_load(&df, filepath) == 0) { + proc_trade(&df); + proc_text(&df, i); + } + + if (dp_report(&df) == DIAG_ERROR) errc = EXIT_FAILURE; + + free(basename); + free(filepath); + dp_free(&df); + } + + pack_trainernames(trades.size); + return common_done(errc, NULL); +} + +static void proc_trade(datafile_t *df) { + NPCTradeMon mon = { + .species = enum_u16(".species", enum Species), + .hpIV = u8_maxbits(".hpIV", 5), + .atkIV = u8_maxbits(".atkIV", 5), + .defIV = u8_maxbits(".defIV", 5), + .speedIV = u8_maxbits(".speedIV", 5), + .spAtkIV = u8_maxbits(".spAtkIV", 5), + .spDefIV = u8_maxbits(".spDefIV", 5), + .unused1 = u32(".unused1"), + .otID = u32(".otID"), + .cool = u32(".cool"), + .beauty = u32(".beauty"), + .cute = u32(".cute"), + .smart = u32(".smart"), + .tough = u32(".tough"), + .personality = u32(".personality"), + .heldItem = enum_u16(".heldItem", enum Item), + .otGender = enum_u16(".otGender", enum Gender), + .unused2 = u32(".unused2"), + .language = enum_u16(".language", enum Language), + .requestedSpecies = enum_u16(".requestedSpecies", enum Species), + }; + + nitroarc_ppack(&archives[0].packer, &mon, sizeof(mon), NULL); +} + +static char **s_trainernames = NULL; + +static void prep_trainernames(size_t count) { + char *buf_trainernames = calloc(count * (TRAINER_NAME_LEN + 1), sizeof(*buf_trainernames)); + s_trainernames = calloc(count, sizeof(*s_trainernames)); + + for (size_t i = 0; i < count; i++) { + s_trainernames[i] = &buf_trainernames[i * (TRAINER_NAME_LEN + 1)]; + } +} + +static void check_name(datanode_t *node, const char *val, size_t len, size_t max, const char *domain) { + if (!val) return; + + if (len > max) { + dp_error(node, + "%s name '%s' exceeds maximum length of %zu", + domain, val, max); + return; + } + + if (len == 0) dp_warn(node, "%s name has length 0", domain); +} + +static void proc_text(datafile_t *df, size_t i) { + char buf[BUFSIZE] = { 0 }; + + datanode_t pk_name = dp_get(df, ".name"); + datanode_t tr_name = dp_get(df, ".otName"); + const char *pk_name_val = dp_string(pk_name); + const char *tr_name_val = dp_string(tr_name); + const size_t pk_name_len = pk_name_val ? strlen(pk_name_val) : 0; + const size_t tr_name_len = tr_name_val ? strlen(tr_name_val) : 0; + + check_name(&pk_name, pk_name_val, pk_name_len, MON_NAME_LEN, "traded Pokemon"); + check_name(&tr_name, tr_name_val, tr_name_len, TRAINER_NAME_LEN, "trading Trainer"); + + datanode_t entry = dp_arr_appobject(&textbanks[0].root); + dp_obj_putstring(&entry, "id", strfmt("NPCTradeNames_Text_Mon%zu", i)); + dp_obj_putstring(&entry, "en_US", pk_name_val); + + memcpy(s_trainernames[i], tr_name_val, tr_name_len); // store for later +} + +static void pack_trainernames(size_t count) { + char buf[BUFSIZE] = { 0 }; + + for (size_t i = 0; i < count; i++) { + datanode_t entry = dp_arr_appobject(&textbanks[0].root); + dp_obj_putstring(&entry, "id", strfmt("NPCTradeNames_Text_Trainer%zu", i)); + dp_obj_putstring(&entry, "en_US", s_trainernames[i]); + } + + free(s_trainernames[0]); + free(s_trainernames); +} + +static void usage(const char *fmt, ...); + +static char *program_name = NULL; + +static void parse_args(int *pargc, char ***pargv) { + program_name = (*pargv)[0]; + opterr = 0; + + int c = 0; + while ((c = getopt(*pargc, *pargv, ":o:M:h")) != -1) { + switch (c) { + case 'o': output_dir = optarg; break; + case 'M': depfile_path = optarg; break; + + case 'h': usage(NULL); break; + case ':': usage("missing argument for '-%c'", optopt); break; + default: usage("unknown option '-%c'", optopt); break; + } + } + + *pargc -= optind; + *pargv += optind; + if (*pargc < 1) usage("missing required argument ENUMFILE"); + if (*pargc < 2) usage("missing required argument BASEDIR"); + + filename = (*pargv)[0]; + base_dir = (*pargv)[1]; +} + +static void usage(const char *fmt, ...) { + FILE *f = stdout; + if (fmt != NULL) { + f = stderr; + + va_list args; + va_start(args, fmt); + fputs(program_name, f); + fputs(": ", f); + vfprintf(f, fmt, args); + fputc('\n', f); + va_end(args); + } + +#define fputf(fmt, ...) fprintf(f, fmt, __VA_ARGS__) + fputf("usage: %s [-M DEPFILE] [-o OUTDIR] ENUMFILE BASEDIR\n", program_name); + fputs("\n", f); + fputs("options:\n", f); + fputs(" -o OUTDIR Write output files to OUTDIR. Does not affect DEPFILE.\n", f); + fputs(" Defaults to the current working directory.\n", f); + fputs(" -M DEPFILE Specify the full path to an output dependency file.\n", f); + fputs(" Defaults to 'npctrade_data.d'.\n", f); +#undef fputf + + exit(f == stdout ? EXIT_SUCCESS : EXIT_FAILURE); +} diff --git a/tools/jsoncnv/meson.build b/tools/jsoncnv/meson.build index bd297afd99..e81cfe9b2f 100644 --- a/tools/jsoncnv/meson.build +++ b/tools/jsoncnv/meson.build @@ -14,5 +14,4 @@ encdata_ex_trophy_garden_py = find_program('encdata_ex_trophy_garden.py', native encdata_ex_great_marsh_py = find_program('encdata_ex_great_marsh.py', native: true) lighting_py = find_program('lighting.py', native: true) map_matrix_py = find_program('map_matrix.py', native: true) -npc_trades_py = find_program('npc_trades.py', native: true) prop_model_set_py = find_program('prop_model_set.py', native: true) diff --git a/tools/jsoncnv/npc_trades.py b/tools/jsoncnv/npc_trades.py deleted file mode 100755 index ce1b51f147..0000000000 --- a/tools/jsoncnv/npc_trades.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env python3 -import json -import pathlib -import sys - -from convert import from_item, from_gender, from_species, u32 - -ANSI_BOLD_WHITE = "\033[1;37m" -ANSI_BOLD_RED = "\033[1;31m" -ANSI_RED = "\033[31m" -ANSI_CLEAR = "\033[0m" - -def parse_npc_trade(data) -> bytes: - return b"".join([ - u32(from_species(data["species"])), - u32(data["hpIV"]), - u32(data["atkIV"]), - u32(data["defIV"]), - u32(data["speedIV"]), - u32(data["spAtkIV"]), - u32(data["spDefIV"]), - u32(data["unused1"]), - u32(data["otID"]), - u32(data["cool"]), - u32(data["beauty"]), - u32(data["cute"]), - u32(data["smart"]), - u32(data["tough"]), - u32(data["personality"]), - u32(from_item(data["heldItem"])), - u32(from_gender(data["otGender"])), - u32(data["unused2"]), - u32(data["language"]), - u32(from_species(data["requestedSpecies"])), - ]) - -input_path = pathlib.Path(sys.argv[1]) -output_path = pathlib.Path(sys.argv[2]) - -try: - data = {} - with open(input_path, 'r', encoding='utf-8') as input_file: - data = json.load(input_file) -except json.decoder.JSONDecodeError as e: - doc_lines = e.doc.splitlines() - start_line = max(e.lineno - 2, 0) - end_line = min(e.lineno + 1, len(doc_lines)) - - error_lines = [f"{line_num:>4} | {line}" for line_num, line in zip(list(range(start_line + 1, end_line + 1)), doc_lines[start_line : end_line])][ : end_line - start_line] - error_line_index = e.lineno - start_line - 1 - error_lines[error_line_index] = error_lines[error_line_index][ : 5] + f"{ANSI_RED}{error_lines[error_line_index][5 : ]}{ANSI_CLEAR}" - error_out = "\n".join(error_lines) - - print(f"{ANSI_BOLD_WHITE}{input_path}:{e.lineno}:{e.colno}: {ANSI_BOLD_RED}error: {ANSI_BOLD_WHITE}{e.msg}{ANSI_CLEAR}\n{error_out}", file=sys.stderr) - sys.exit(1) - -with open(output_path, "wb") as output_file: - output_file.write(parse_npc_trade(data))