Skip to content

Commit 063dcf8

Browse files
committed
Refactor throws of FatalProgramException. Cleanup unused headers.
1 parent 3913469 commit 063dcf8

37 files changed

+64
-303
lines changed

SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_DateReader.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@ void DateReader::set_hours(
169169
{
170170
auto snapshot = console.video().snapshot();
171171
if (!detect(snapshot)){
172-
throw FatalProgramException(
173-
ErrorReport::SEND_ERROR_REPORT, console,
172+
throw_and_log<FatalProgramException>(
173+
console, ErrorReport::SEND_ERROR_REPORT,
174174
"Expected date change menu.",
175-
true
175+
console
176176
);
177177
}
178178
}
@@ -189,10 +189,10 @@ void DateReader::set_hours(
189189
VideoSnapshot snapshot = console.video().snapshot();
190190
int8_t current_hour = read_hours(console.logger(), snapshot);
191191
if (current_hour < 0){
192-
throw FatalProgramException(
193-
ErrorReport::SEND_ERROR_REPORT, console,
192+
throw_and_log<FatalProgramException>(
193+
console, ErrorReport::SEND_ERROR_REPORT,
194194
"Unable to read the hour.",
195-
true
195+
console
196196
);
197197
}
198198

@@ -244,10 +244,10 @@ void DateReader::set_hours(
244244
}
245245

246246
// auto snapshot = console.video().snapshot();
247-
throw FatalProgramException(
248-
ErrorReport::SEND_ERROR_REPORT, console,
247+
throw_and_log<FatalProgramException>(
248+
console, ErrorReport::SEND_ERROR_REPORT,
249249
"Failed to set the hour after 10 attempts.",
250-
true
250+
console
251251
);
252252
}
253253

@@ -574,10 +574,10 @@ void DateReader::set_date(
574574
}
575575

576576
ssf_flush_pipeline(context);
577-
throw FatalProgramException(
578-
ErrorReport::SEND_ERROR_REPORT, console,
577+
throw_and_log<FatalProgramException>(
578+
console, ErrorReport::SEND_ERROR_REPORT,
579579
"Failed to set the hour after 10 attempts.",
580-
true
580+
console
581581
);
582582
}
583583

SerialPrograms/Source/PokemonBDSP/Programs/PokemonBDSP_EncounterDetection.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,10 @@ bool StandardEncounterDetection::run_overrides(
179179
ShinyType shiny = side_shiny;
180180
if (shiny == ShinyType::MAYBE_SHINY){
181181
// actions.emplace_back(EncounterAction::StopProgram, "");
182-
throw FatalProgramException(
183-
ErrorReport::SEND_ERROR_REPORT, m_console,
182+
throw_and_log<FatalProgramException>(
183+
m_console, ErrorReport::SEND_ERROR_REPORT,
184184
"Cannot run encounter actions due to low confidence shiny detection.",
185-
false
185+
m_console
186186
);
187187
}
188188

@@ -242,10 +242,10 @@ EncounterActionFull StandardEncounterDetection::get_action_doubles(){
242242
m_console.log(str_right);
243243

244244
if (action_left != action_right){
245-
throw FatalProgramException(
246-
ErrorReport::NO_ERROR_REPORT, m_console,
245+
throw_and_log<FatalProgramException>(
246+
m_console, ErrorReport::NO_ERROR_REPORT,
247247
"Conflicting actions requested.\n" + str_left + "\n" + str_right,
248-
false
248+
m_console
249249
);
250250
}
251251

@@ -257,10 +257,10 @@ EncounterActionFull StandardEncounterDetection::get_action_doubles(){
257257

258258
// Double battle and someone is set to auto-catch.
259259
if (auto_catch && m_double_battle){
260-
throw FatalProgramException(
261-
ErrorReport::NO_ERROR_REPORT, m_console,
260+
throw_and_log<FatalProgramException>(
261+
m_console, ErrorReport::NO_ERROR_REPORT,
262262
"Cannot auto-catch in a double battle.",
263-
false
263+
m_console
264264
);
265265
}
266266

SerialPrograms/Source/PokemonBDSP/Programs/PokemonBDSP_EncounterHandler.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,10 @@ bool StandardEncounterHandler::handle_standard_encounter_end_battle(
283283
pbf_mash_button(m_context, BUTTON_B, 2 * TICKS_PER_SECOND);
284284
break;
285285
default:
286-
throw FatalProgramException(
287-
ErrorReport::NO_ERROR_REPORT, m_console,
286+
throw_and_log<FatalProgramException>(
287+
m_console, ErrorReport::NO_ERROR_REPORT,
288288
"Unable to recover from failed catch.",
289-
true
289+
m_console
290290
);
291291
}
292292
return false;

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
#ifndef PokemonAutomation_PokemonSV_AutoStoryTools_H
88
#define PokemonAutomation_PokemonSV_AutoStoryTools_H
99

10-
#include "Common/Cpp/DateTime.h"
11-
#include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h"
12-
#include "CommonFramework/Tools/StatsTracking.h"
10+
#include <functional>
1311
#include "CommonFramework/Language.h"
12+
#include "CommonFramework/ImageTools/ImageBoxes.h"
13+
#include "CommonFramework/Tools/StatsTracking.h"
14+
#include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h"
1415
// #include "PokemonSV/Programs/PokemonSV_Navigation.h"
16+
1517
namespace PokemonAutomation{
1618
namespace NintendoSwitch{
1719
namespace PokemonSV{

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_00.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,9 @@
44
*
55
*/
66

7-
#include "CommonFramework/GlobalSettingsPanel.h"
8-
#include "CommonFramework/Exceptions/FatalProgramException.h"
9-
#include "CommonFramework/Exceptions/OperationFailedException.h"
107
#include "CommonFramework/InferenceInfra/InferenceRoutines.h"
11-
#include "CommonFramework/Notifications/ProgramNotifications.h"
12-
#include "CommonFramework/Tools/StatsTracking.h"
138
#include "CommonFramework/Tools/VideoResolutionCheck.h"
149
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
15-
#include "Pokemon/Pokemon_Strings.h"
16-
#include "PokemonSwSh/Inference/PokemonSwSh_IvJudgeReader.h"
1710
#include "PokemonSV/Programs/PokemonSV_GameEntry.h"
1811
#include "PokemonSV/Programs/PokemonSV_SaveGame.h"
1912
#include "PokemonSV/Inference/PokemonSV_TutorialDetector.h"
@@ -31,8 +24,6 @@ namespace PokemonAutomation{
3124
namespace NintendoSwitch{
3225
namespace PokemonSV{
3326

34-
using namespace Pokemon;
35-
3627

3728
std::string AutoStory_Segment_00::name() const{
3829
return "00: Intro Cutscene";

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_01.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,11 @@
44
*
55
*/
66

7-
#include "CommonFramework/GlobalSettingsPanel.h"
8-
#include "CommonFramework/Exceptions/FatalProgramException.h"
97
#include "CommonFramework/Exceptions/OperationFailedException.h"
108
#include "CommonFramework/InferenceInfra/InferenceRoutines.h"
119
#include "CommonFramework/Notifications/ProgramNotifications.h"
12-
#include "CommonFramework/Tools/StatsTracking.h"
1310
#include "CommonFramework/Tools/VideoResolutionCheck.h"
1411
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
15-
#include "Pokemon/Pokemon_Strings.h"
16-
#include "PokemonSwSh/Inference/PokemonSwSh_IvJudgeReader.h"
1712
#include "PokemonSV/Programs/PokemonSV_GameEntry.h"
1813
#include "PokemonSV/Programs/PokemonSV_SaveGame.h"
1914
#include "PokemonSV/Inference/PokemonSV_TutorialDetector.h"
@@ -31,7 +26,6 @@ namespace PokemonAutomation{
3126
namespace NintendoSwitch{
3227
namespace PokemonSV{
3328

34-
using namespace Pokemon;
3529

3630

3731

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_02.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,9 @@
44
*
55
*/
66

7-
#include "CommonFramework/GlobalSettingsPanel.h"
8-
#include "CommonFramework/Exceptions/FatalProgramException.h"
9-
#include "CommonFramework/Exceptions/OperationFailedException.h"
107
#include "CommonFramework/InferenceInfra/InferenceRoutines.h"
11-
#include "CommonFramework/Notifications/ProgramNotifications.h"
12-
#include "CommonFramework/Tools/StatsTracking.h"
138
#include "CommonFramework/Tools/VideoResolutionCheck.h"
149
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
15-
#include "Pokemon/Pokemon_Strings.h"
16-
#include "PokemonSwSh/Inference/PokemonSwSh_IvJudgeReader.h"
1710
#include "PokemonSV/Programs/PokemonSV_GameEntry.h"
1811
#include "PokemonSV/Programs/PokemonSV_SaveGame.h"
1912
#include "PokemonSV/Inference/PokemonSV_TutorialDetector.h"
@@ -31,7 +24,6 @@ namespace PokemonAutomation{
3124
namespace NintendoSwitch{
3225
namespace PokemonSV{
3326

34-
using namespace Pokemon;
3527

3628

3729

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_03.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,9 @@
44
*
55
*/
66

7-
#include "CommonFramework/GlobalSettingsPanel.h"
8-
#include "CommonFramework/Exceptions/FatalProgramException.h"
9-
#include "CommonFramework/Exceptions/OperationFailedException.h"
107
#include "CommonFramework/InferenceInfra/InferenceRoutines.h"
11-
#include "CommonFramework/Notifications/ProgramNotifications.h"
12-
#include "CommonFramework/Tools/StatsTracking.h"
138
#include "CommonFramework/Tools/VideoResolutionCheck.h"
149
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
15-
#include "Pokemon/Pokemon_Strings.h"
16-
#include "PokemonSwSh/Inference/PokemonSwSh_IvJudgeReader.h"
1710
#include "PokemonSV/Programs/PokemonSV_GameEntry.h"
1811
#include "PokemonSV/Programs/PokemonSV_SaveGame.h"
1912
#include "PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.h"
@@ -30,7 +23,6 @@ namespace PokemonAutomation{
3023
namespace NintendoSwitch{
3124
namespace PokemonSV{
3225

33-
using namespace Pokemon;
3426

3527

3628

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,10 @@
44
*
55
*/
66

7-
#include "CommonFramework/GlobalSettingsPanel.h"
8-
#include "CommonFramework/Exceptions/FatalProgramException.h"
97
#include "CommonFramework/Exceptions/OperationFailedException.h"
108
#include "CommonFramework/InferenceInfra/InferenceRoutines.h"
11-
#include "CommonFramework/Notifications/ProgramNotifications.h"
12-
#include "CommonFramework/Tools/StatsTracking.h"
139
#include "CommonFramework/Tools/VideoResolutionCheck.h"
1410
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
15-
#include "Pokemon/Pokemon_Strings.h"
16-
#include "PokemonSwSh/Inference/PokemonSwSh_IvJudgeReader.h"
1711
#include "PokemonSV/Programs/PokemonSV_GameEntry.h"
1812
#include "PokemonSV/Programs/PokemonSV_SaveGame.h"
1913
#include "PokemonSV/Inference/PokemonSV_TutorialDetector.h"
@@ -30,7 +24,6 @@ namespace PokemonAutomation{
3024
namespace NintendoSwitch{
3125
namespace PokemonSV{
3226

33-
using namespace Pokemon;
3427

3528

3629

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,9 @@
44
*
55
*/
66

7-
#include "CommonFramework/GlobalSettingsPanel.h"
8-
#include "CommonFramework/Exceptions/FatalProgramException.h"
9-
#include "CommonFramework/Exceptions/OperationFailedException.h"
107
#include "CommonFramework/InferenceInfra/InferenceRoutines.h"
11-
#include "CommonFramework/Notifications/ProgramNotifications.h"
12-
#include "CommonFramework/Tools/StatsTracking.h"
138
#include "CommonFramework/Tools/VideoResolutionCheck.h"
149
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
15-
#include "Pokemon/Pokemon_Strings.h"
16-
#include "PokemonSwSh/Inference/PokemonSwSh_IvJudgeReader.h"
1710
#include "PokemonSV/Programs/PokemonSV_GameEntry.h"
1811
#include "PokemonSV/Programs/PokemonSV_SaveGame.h"
1912
#include "PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.h"
@@ -30,7 +23,6 @@ namespace PokemonAutomation{
3023
namespace NintendoSwitch{
3124
namespace PokemonSV{
3225

33-
using namespace Pokemon;
3426

3527

3628

0 commit comments

Comments
 (0)