Skip to content
  • Igor Kushnir's avatar
    ItemRepository::index: fix off-by-one error · 849a54a7
    Igor Kushnir authored
    Several member functions of ItemRepository access elements of m_buckets
    at indices up to and including m_currentBucket. Presumably
    m_currentBucket < m_buckets.size() is an invariant.
    needMonsterExtent + 1 is added to m_currentBucket a few lines below the
    modified line. So when
    m_currentBucket + needMonsterExtent + 1 == m_buckets.size(), the size of
    m_buckets must be increased.
    
    The bug fixed in this commit caused frequent assertion failures in
    ItemRepository when TestItemRepository::testItemRepository() randomly
    picked a large item size - `if (itemDecision < largeItemsFraction)`.
    849a54a7