From 49246a60f366e0b309c78ee66db18d5f96651176 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Thu, 2 Feb 2023 23:57:52 -0800 Subject: [PATCH] properly cast for unsigned comparisons --- library/modules/Kitchen.cpp | 8 ++++---- plugins/seedwatch.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/library/modules/Kitchen.cpp b/library/modules/Kitchen.cpp index 4fedf0bab..7fed01b50 100644 --- a/library/modules/Kitchen.cpp +++ b/library/modules/Kitchen.cpp @@ -48,7 +48,7 @@ void Kitchen::debug_print(color_ostream &out) void Kitchen::allowPlantSeedCookery(int32_t plant_id) { - if (plant_id < 0 || plant_id >= world->raws.plants.all.size()) + if (plant_id < 0 || (size_t)plant_id >= world->raws.plants.all.size()) return; df::plant_raw *type = world->raws.plants.all[plant_id]; @@ -64,7 +64,7 @@ void Kitchen::allowPlantSeedCookery(int32_t plant_id) void Kitchen::denyPlantSeedCookery(int32_t plant_id) { - if (plant_id < 0 || plant_id >= world->raws.plants.all.size()) + if (plant_id < 0 || (size_t)plant_id >= world->raws.plants.all.size()) return; df::plant_raw *type = world->raws.plants.all[plant_id]; @@ -79,7 +79,7 @@ void Kitchen::denyPlantSeedCookery(int32_t plant_id) } bool Kitchen::isPlantCookeryAllowed(int32_t plant_id) { - if (plant_id < 0 || plant_id >= world->raws.plants.all.size()) + if (plant_id < 0 || (size_t)plant_id >= world->raws.plants.all.size()) return false; df::plant_raw *type = world->raws.plants.all[plant_id]; @@ -89,7 +89,7 @@ bool Kitchen::isPlantCookeryAllowed(int32_t plant_id) { } bool Kitchen::isSeedCookeryAllowed(int32_t plant_id) { - if (plant_id < 0 || plant_id >= world->raws.plants.all.size()) + if (plant_id < 0 || (size_t)plant_id >= world->raws.plants.all.size()) return false; df::plant_raw *type = world->raws.plants.all[plant_id]; diff --git a/plugins/seedwatch.cpp b/plugins/seedwatch.cpp index fed563a84..e88921653 100644 --- a/plugins/seedwatch.cpp +++ b/plugins/seedwatch.cpp @@ -329,7 +329,7 @@ static void do_cycle(color_ostream &out, int32_t *num_enabled_seed_types, int32_ for (auto &entry : watched_seeds) { int32_t id = entry.first; - if (id < 0 || id >= world->raws.plants.all.size()) + if (id < 0 || (size_t)id >= world->raws.plants.all.size()) continue; int32_t target = get_config_val(entry.second, SEED_CONFIG_TARGET); if (accessible_counts[id] <= target && @@ -359,7 +359,7 @@ static void set_target(color_ostream &out, int32_t id, int32_t target) { if (target == 0) remove_seed_config(out, id); else { - if (id < 0 || id >= world->raws.plants.all.size()) { + if (id < 0 || (size_t)id >= world->raws.plants.all.size()) { WARN(config,out).print( "cannot set target for unknown plant id: %d\n", id); return;