Add limits on the range of client_id values (#95)
This commit is contained in:
parent
718237ae84
commit
7be33e1c20
|
@ -27,7 +27,7 @@ namespace ratgdo {
|
||||||
this->pref_ = global_preferences->make_preference<float>(this->get_object_id_hash());
|
this->pref_ = global_preferences->make_preference<float>(this->get_object_id_hash());
|
||||||
if (!this->pref_.load(&value)) {
|
if (!this->pref_.load(&value)) {
|
||||||
if (this->number_type_ == RATGDO_CLIENT_ID) {
|
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 {
|
} else {
|
||||||
value = 0;
|
value = 0;
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ namespace ratgdo {
|
||||||
if (this->number_type_ == RATGDO_CLIENT_ID) {
|
if (this->number_type_ == RATGDO_CLIENT_ID) {
|
||||||
uint32_t int_value = static_cast<uint32_t>(value);
|
uint32_t int_value = static_cast<uint32_t>(value);
|
||||||
if ((int_value & 0xFFF) != 0x539) {
|
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);
|
this->pref_.save(&value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,9 @@ namespace ratgdo {
|
||||||
} else if (this->number_type_ == RATGDO_ROLLING_CODE_COUNTER) {
|
} else if (this->number_type_ == RATGDO_ROLLING_CODE_COUNTER) {
|
||||||
this->traits.set_max_value(0xfffffff);
|
this->traits.set_max_value(0xfffffff);
|
||||||
} else if (this->number_type_ == RATGDO_CLIENT_ID) {
|
} 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue