fix incorrect ItemPT meseta ranges giving 65535 meseta
This commit is contained in:
+9
-8
@@ -285,16 +285,17 @@ uint32_t ItemCreator::choose_meseta_amount(
|
|||||||
uint16_t min = ranges[table_index].min;
|
uint16_t min = ranges[table_index].min;
|
||||||
uint16_t max = ranges[table_index].max;
|
uint16_t max = ranges[table_index].max;
|
||||||
|
|
||||||
// Note: The original code seems like it has a bug here: it compares to 0xFF
|
// Note: The original code returns 0xFF here if either limit is equal to 0xFF
|
||||||
// instead of 0xFFFF (and returns 0xFF if either limit matches 0xFF).
|
// (despite them being 16-bit integers!)
|
||||||
uint32_t ret = 0;
|
uint16_t ret;
|
||||||
if (((min == 0xFFFF) || (max == 0xFFFF)) || (max < min)) {
|
if (min == max) {
|
||||||
ret = 0xFFFF;
|
|
||||||
} else if (min != max) {
|
|
||||||
ret = this->rand_int((max - min) + 1) + min;
|
|
||||||
} else {
|
|
||||||
ret = min;
|
ret = min;
|
||||||
|
} else if (max < min) {
|
||||||
|
ret = this->rand_int((min - max) + 1) + max;
|
||||||
|
} else {
|
||||||
|
ret = this->rand_int((max - min) + 1) + min;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->log.info("Chose %" PRIu32 " Meseta from range [%hu, %hu]", ret, min, max);
|
this->log.info("Chose %" PRIu32 " Meseta from range [%hu, %hu]", ret, min, max);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user