Skip to content

Commit fef06bc

Browse files
committed
Fix Music changers & Re-fight Trainer cheat for UM
Previously, the music changers were not getting applied nor reverted back to original properly.
1 parent 79172e8 commit fef06bc

File tree

3 files changed

+32
-31
lines changed

3 files changed

+32
-31
lines changed

Includes/Folders/Battle.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ namespace Battle {
4848
void CatchTrainersPokemon(MenuEntry *entry);
4949
}
5050

51+
void ApplyMusic(MenuEntry *entry);
5152
void MusicKB(MenuEntry *entry);
52-
void Music(MenuEntry *entry);
5353
}
5454

5555
#endif

Sources/Folders/Battle.cpp

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ namespace Battle {
858858
}
859859

860860
void RefightTrainer(MenuEntry *entry) {
861-
static const u32 address = Helpers::GetVersion<u32>(0x49EFC8, Helpers::PickGame<u32>(0x4BB03C, 0x4BB034));
861+
static const u32 address = Helpers::GetVersion<u32>(0x49EFC8, 0x4BB03C);
862862
static vector<u32> original(2);
863863
static bool saved = false;
864864

@@ -957,39 +957,15 @@ namespace Battle {
957957
static vector<string> getMusicFiles;
958958
static bool musicSelected = false;
959959

960-
void MusicKB(MenuEntry *entry) {
961-
static const vector<string> options = {"Wild Encounter", "Trainer"};
962-
KeyboardPlus keyboard;
963-
964-
if (keyboard.SetKeyboard(entry->Name() + ":", true, options, musicType) != -1) {
965-
static const vector<Music> fromGame = Helpers::AutoRegion(Helpers::GetVersion(XY::musicFiles, ORAS::musicFiles), Helpers::GetVersion(SM::musicFiles, USUM::musicFiles));
966-
967-
if (getMusicFiles.empty()) {
968-
for (const Music &nickname : fromGame)
969-
getMusicFiles.push_back(nickname.name);
970-
}
971-
972-
if (keyboard.SetKeyboard(entry->Name() + ":\n\nSelect the music file you would like to use.", true, getMusicFiles, music) != -1) {
973-
musicSelected = true;
974-
Message::Completed();
975-
return;
976-
}
977-
978-
else musicSelected = false;
979-
}
980-
981-
else musicSelected = false;
982-
}
983-
984-
void Music(MenuEntry *entry) {
960+
void ApplyMusic(MenuEntry *entry) {
985961
static const vector<u32> address = {
986962
Helpers::AutoRegion<u32>(Helpers::GetVersion<u32>(0x1615FDA4, 0x16127D6C), Helpers::GetVersion<u32>(0x32F99D88, 0x32EDD178)),
987963
Helpers::AutoRegion<u32>(Helpers::GetVersion<u32>(0x1615FDC8, 0x16127DA0), Helpers::GetVersion<u32>(0x32F99DEC, 0x32EDD8A0))
988964
};
989965

990966
static const vector<string> original = {
991-
Helpers::GetVersion("bgm_xy_vs_norapoke.aac", "bgm_sg_vs_norapoke_sg.dspadpcm.bcstm"), Helpers::GetVersion("bgm_nj_vs_norapoke.dspadpcm.bcstm", "bgm_mj_vs_norapoke.dspadpcm.bcstm"),
992-
Helpers::GetVersion("bgm_xy_vs_trainer.aac", "bgm_sg_vs_trainer_sg.dspadpcm.bcstm"), Helpers::GetVersion("bgm_nj_vs_trainer.dspadpcm.bcstm", "bgm_mj_vs_norapoke.dspadpcm.bcstm")
967+
Helpers::AutoRegion<string>(Helpers::GetVersion("bgm_xy_vs_norapoke.aac", "bgm_sg_vs_norapoke_sg.dspadpcm.bcstm"), Helpers::GetVersion("bgm_nj_vs_norapoke.dspadpcm.bcstm", "bgm_mj_vs_norapoke.dspadpcm.bcstm")),
968+
Helpers::AutoRegion<string>(Helpers::GetVersion("bgm_xy_vs_trainer.aac", "bgm_sg_vs_trainer_sg.dspadpcm.bcstm"), Helpers::GetVersion("bgm_nj_vs_trainer.dspadpcm.bcstm", "bgm_mj_vs_norapoke.dspadpcm.bcstm"))
993969
};
994970

995971
static const string extension = Helpers::AutoRegion(Helpers::GetVersion(".aac", ".dspadpcm.bcstm"), ".dspadpcm.bcstm");
@@ -1019,11 +995,36 @@ namespace Battle {
1019995
for (int j = 0; j < Helpers::AutoRegion(Helpers::GetVersion(0x24, 0x34), 0x30); j++)
1020996
Process::Write8(address[i] + j, 0);
1021997

1022-
Process::WriteString(address[i], original[i], original[i].size(), StringFormat::Utf8);
998+
Process::WriteString(address[i], original[i], original[i].size() + 1, StringFormat::Utf8);
1023999
}
10241000
}
10251001

10261002
return;
10271003
}
10281004
}
1005+
1006+
void MusicKB(MenuEntry *entry) {
1007+
static const vector<string> options = {"Wild Encounter", "Trainer"};
1008+
KeyboardPlus keyboard;
1009+
1010+
if (keyboard.SetKeyboard(entry->Name() + ":", true, options, musicType) != -1) {
1011+
static const vector<Music> fromGame = Helpers::AutoRegion(Helpers::GetVersion(XY::musicFiles, ORAS::musicFiles), Helpers::GetVersion(SM::musicFiles, USUM::musicFiles));
1012+
1013+
if (getMusicFiles.empty()) {
1014+
for (const Music &nickname : fromGame)
1015+
getMusicFiles.push_back(nickname.name);
1016+
}
1017+
1018+
if (keyboard.SetKeyboard(entry->Name() + ":\n\nSelect the music file you would like to use.", true, getMusicFiles, music) != -1) {
1019+
musicSelected = true;
1020+
entry->SetGameFunc(ApplyMusic);
1021+
Message::Completed();
1022+
return;
1023+
}
1024+
1025+
else musicSelected = false;
1026+
}
1027+
1028+
else musicSelected = false;
1029+
}
10291030
}

Sources/Menu.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ void InitMenu(PluginMenu &menu) {
103103

104104
*other += new MenuEntry("Catch Trainer's Pokémon", Helpers::ChooseEntry(Battle::Gen6::CatchTrainersPokemon, Battle::Gen7::CatchTrainersPokemon));
105105
*battle += other;
106-
*battle += new MenuEntry("Music", Battle::Music, Battle::MusicKB);
106+
*battle += new MenuEntry("Music", nullptr, Battle::MusicKB);
107107
menu += battle;
108108

109109
MenuFolder *trainer = new MenuFolder("Trainer");

0 commit comments

Comments
 (0)