Skip to content

Commit 392f7e2

Browse files
committed
Living Dex Data Validation
1 parent 29754ce commit 392f7e2

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

SerialPrograms/Source/PokemonHome/Programs/PokemonHome_BoxSorterLivingDex.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,28 @@ void BoxSorterLivingDex::program(SingleSwitchProgramEnvironment& env, ProControl
381381
BoxCursor nav_cursor((LIVING_DEX_START_BOX - 1), 0, 0);
382382

383383
size_t living_dex_box_count = (size_t)std::ceil((double)living_dex_order.size() / 30);
384+
size_t living_dex_end = LIVING_DEX_START_BOX + living_dex_box_count - 1;
385+
386+
if (REJECT_BOX_START > REJECT_BOX_END){
387+
throw UserSetupError(
388+
env.logger(),
389+
"ERROR: Reject box range is invalid, please ensure start is less than or equal to end."
390+
);
391+
}
392+
393+
if (living_dex_end > MAX_HOME_BOXES){
394+
throw UserSetupError(
395+
env.logger(),
396+
"ERROR: Living dex boxes exceed max box count, please adjust box settings."
397+
);
398+
}
399+
400+
if (LIVING_DEX_START_BOX <= REJECT_BOX_END && REJECT_BOX_START <= living_dex_end){
401+
throw UserSetupError(
402+
env.logger(),
403+
"ERROR: Living dex boxes overlap with reject boxes, please adjust box settings."
404+
);
405+
}
384406

385407
nav_cursor = populate_box_data(env, context, sort_preferences, living_dex_boxes_data, living_dex_box_count, nav_cursor, OT_NAME_LANGUAGE);
386408

0 commit comments

Comments
 (0)