From 64bf32738a690d2f15efead66c9c314ca6983d8d Mon Sep 17 00:00:00 2001 From: Marius Muja Date: Sun, 5 Nov 2023 17:01:27 -0800 Subject: [PATCH] Add limits on the range of client_id values --- components/ratgdo/number/ratgdo_number.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/components/ratgdo/number/ratgdo_number.cpp b/components/ratgdo/number/ratgdo_number.cpp index d5e6046..27b43fb 100644 --- a/components/ratgdo/number/ratgdo_number.cpp +++ b/components/ratgdo/number/ratgdo_number.cpp @@ -27,7 +27,7 @@ namespace ratgdo { this->pref_ = global_preferences->make_preference(this->get_object_id_hash()); if (!this->pref_.load(&value)) { if (this->number_type_ == RATGDO_CLIENT_ID) { - value = ((random_uint32() + 1) % 0xFFFF) << 12 | 0x539; + value = ((random_uint32() + 1) % 0x7FF) << 12 | 0x539; // max size limited to be precisely convertible to float } else { value = 0; } @@ -36,7 +36,7 @@ namespace ratgdo { if (this->number_type_ == RATGDO_CLIENT_ID) { uint32_t int_value = static_cast(value); if ((int_value & 0xFFF) != 0x539) { - value = ((random_uint32() + 1) % 0xFFFF) << 12 | 0x539; + value = ((random_uint32() + 1) % 0x7FF) << 12 | 0x539; // max size limited to be precisely convertible to float this->pref_.save(&value); } } @@ -69,7 +69,9 @@ namespace ratgdo { } else if (this->number_type_ == RATGDO_ROLLING_CODE_COUNTER) { this->traits.set_max_value(0xfffffff); } else if (this->number_type_ == RATGDO_CLIENT_ID) { - this->traits.set_max_value(0xFFFFFFFF); + this->traits.set_step(0x1000); + this->traits.set_min_value(0x539); + this->traits.set_max_value(0x7ff539); } }