Skip to content

Commit

Permalink
Apply suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
edo9300 committed Mar 8, 2024
1 parent 0da2cdf commit a710fcc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions duel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,14 @@ void duel::set_response(const void* resp, size_t len) {
}
// uniform integer distribution
int32_t duel::get_next_integer(int32_t l, int32_t h) {
const uint32_t range = h - l + 1;
const uint32_t lim = random.max() % range;
assert(l <= h);
const uint64_t range = int64_t(h) - int64_t(l) + 1;
const uint64_t lim = random.max() % range;
uint64_t n;
do {
n = random();
} while(n <= lim);
return static_cast<int32_t>(n % range) + l;
return static_cast<int32_t>((n % range) + l);
}
duel::duel_message* duel::new_message(uint8_t message) {
return &(messages.emplace_back(message));
Expand Down

0 comments on commit a710fcc

Please sign in to comment.