Skip to content

fix(config): clear the item bins before rebuilding them on reload - #38

Merged
icemansparks merged 1 commit into
merkerhoodfrom
fix/reload-stale-bins
Aug 25, 2026
Merged

fix(config): clear the item bins before rebuilding them on reload#38
icemansparks merged 1 commit into
merkerhoodfrom
fix/reload-stale-bins

Conversation

@icemansparks

Copy link
Copy Markdown
Collaborator

Found by the pre-build review over 38e6a83..merkerhood, and verified against the code before writing this.

Problem

AHBConfig::Initialize() is InitializeFromFile() + InitializeFromSql() + InitializeBins(). It does not call Reset(), and .reload config goes through Initialize() (AuctionHouseBotWorldScript.cpp:127-129). InitializeBins() only ever inserts into the bins — the clear() calls live in Reset() and in the copy constructor, neither of which is on the reload path.

Two consequences:

  1. Stale entries survive a reload. An admin adds an item to mod_auctionhousebot_disabled_items, runs .reload config, and the item stays in the bins and in SellableItems — so it keeps being listed until a full server restart. SellableItems is precisely what now gates the price-override path against the blacklist, so this blunts that fix on the one operational path an admin would reach for to fix a bad item on a running realm.
  2. The *Vec vectors are never cleared anywhere at all — not even in Reset(). Every reload appends a full second copy of every item. They feed getElement(config->GreyItemsVec, urand(0, size - 1), ...) in the rarity-tier fallback, so duplicates skew the random pick, and the vectors grow without bound across reloads.

Fix

Clear the 14 bin sets, the 14 vectors and SellableItems at the top of InitializeBins(), before the scan. NpcItems, LootItems, DisableItemStore and SellerWhiteList are deliberately untouched — they are filled elsewhere and are not this function's to reset.

Scope note

The stale-bin half is pre-existing and shared by all the legacy bins; it is included because the new SellableItems set inherits the same gap and because fixing only the new set would leave the bins it is derived from inconsistent with it.

Verification

  • Traced Initialize() and the .reload config path directly; confirmed no Reset() call and no clear() anywhere in InitializeBins(). Confirmed by grep that the *Vec containers have no clear() in the entire file.
  • Full module compile: the core-build workflow on this PR.
  • Behavioural check on a live realm is .reload config after blacklisting an item, then confirming the bot stops listing it without a restart.

Initialize() runs InitializeFromFile(), InitializeFromSql() and
InitializeBins() and never calls Reset(), and ".reload config" goes through
Initialize(). InitializeBins() only ever inserts, so on a reload:

- items the reloaded configuration or an updated
  mod_auctionhousebot_disabled_items now excludes stay in the bins and in
  SellableItems, so an admin who blacklists an item and reloads sees no effect
  until a full restart - and SellableItems is what gates the price override
  path against exactly that blacklist;
- the *Vec vectors, which are never cleared anywhere, gain a second copy of
  every item on each reload, skewing the random pick in the rarity tier
  fallback and growing without bound.

Clear all of them at the top of the rebuild.
@icemansparks
icemansparks merged commit 87facaf into merkerhood Aug 25, 2026
1 check passed
@icemansparks
icemansparks deleted the fix/reload-stale-bins branch August 25, 2026 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant