fix: normalize cross-section duplicate ids in furnidata reconcile
Classnames listed in both roomitemtypes and wallitemtypes keep a canonical copy with the correct id/offerid while the stray wall copy can carry a legacy wrong id. reconcileFurniDataWithItemsBase now normalizes those stray copies to the offerid whenever the offerid maps to an items_base row whose classname matches exactly, so id === offerid === sprite id holds for every uniquely-mapped classname. The sandbox rehearsal asserts this invariant and the live database has been reconciled (76 ids fixed, 0 remaining).
This commit is contained in:
1 parent
3a63152ee3
commit
b811086de6
2 files changed
+48
No files matched your search
@@ -536,6 +536,24 @@ export async function reconcileFurniDataWithItemsBase(): Promise<FurniDataReconc
|
||||
}
|
||||
}
|
||||
|
||||
// Normalize cross-section duplicates (e.g. a wall item listed in both
|
||||
// roomitemtypes and wallitemtypes). The canonical copy already has the
|
||||
// correct id/offerid; a stray copy may carry a legacy wrong `id` while
|
||||
// its offerid still points at the right sprite. Only fix when the
|
||||
// offerid maps to an items_base row whose classname matches this entry
|
||||
// exactly, so we never guess.
|
||||
const dbById = new Map<number, string>();
|
||||
for (const row of rows) dbById.set(row.id, row.itemName);
|
||||
for (const section of ["roomitemtypes", "wallitemtypes"] as const) {
|
||||
for (const e of furniData[section]?.furnitype ?? []) {
|
||||
const offer = entryOfferId(e);
|
||||
if (offer <= 0 || Number(e.id) === offer) continue;
|
||||
if (dbById.get(offer) !== e.classname) continue;
|
||||
e.id = offer;
|
||||
fixedIds++;
|
||||
}
|
||||
}
|
||||
|
||||
if (fixedIds > 0 || fixedOfferIds > 0) {
|
||||
await writeFurniData(furniData as Record<string, unknown>);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user