From 1e10ad9f6599325af437e79a73b4b423e8e3760e Mon Sep 17 00:00:00 2001 From: Thomas Kolarik <65197733+tkolarik@users.noreply.github.com> Date: Sun, 8 Mar 2026 01:15:41 -0500 Subject: [PATCH] underground: add price table size asserts (#990) --- src/underground/trap_prices.c | 2 +- src/underground/treasure_prices.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/underground/trap_prices.c b/src/underground/trap_prices.c index 099ded3fd4..5c52ffa1e3 100644 --- a/src/underground/trap_prices.c +++ b/src/underground/trap_prices.c @@ -8,7 +8,6 @@ #include "underground/defs.h" -// TODO: make this error if it doesn't contain an entry for every trap static const SpherePrice sTrapPrices[] = { [TRAP_NONE] = { .sphereType = SPHERE_NONE, .minSize = 0, .maxSize = 0 }, [TRAP_MOVE_UP] = { .sphereType = SPHERE_BLUE, .minSize = 3, .maxSize = 6 }, @@ -45,6 +44,7 @@ static const SpherePrice sTrapPrices[] = { [TRAP_RADAR_DUMMY] = { .sphereType = SPHERE_NONE, .minSize = 0, .maxSize = 0 }, [TRAP_DIGGER_DRILL] = { .sphereType = RANDOM_SPHERE_TYPE, .minSize = 15, .maxSize = 20 } }; +SDK_COMPILER_ASSERT(NELEMS(sTrapPrices) == TRAP_MAX); // params need to be const to match const u8 Trap_GetSpherePriceType(const enum Trap trapID) diff --git a/src/underground/treasure_prices.c b/src/underground/treasure_prices.c index eb8caae3a2..1300100122 100644 --- a/src/underground/treasure_prices.c +++ b/src/underground/treasure_prices.c @@ -8,7 +8,6 @@ #include "underground/defs.h" #include "underground/mining.h" -// TODO: make this error if it doesn't contain an entry for every treasure static const SpherePrice sTreasurePrices[] = { [MINING_TREASURE_NONE] = { .sphereType = SPHERE_NONE, .minSize = 0, .maxSize = 0 }, [MINING_SMALL_PRISM_SPHERE] = { .sphereType = SPHERE_NONE, .minSize = 0, .maxSize = 0 }, @@ -71,6 +70,7 @@ static const SpherePrice sTreasurePrices[] = { [MINING_TREASURE_DREAD_PLATE] = { .sphereType = SPHERE_RED, .minSize = 70, .maxSize = 80 }, [MINING_TREASURE_IRON_PLATE] = { .sphereType = SPHERE_PRISM, .minSize = 70, .maxSize = 80 } }; +SDK_COMPILER_ASSERT(NELEMS(sTreasurePrices) == MINING_TREASURE_MAX); u8 Treasure_GetSpherePriceType(int treasureID) {