diff --git a/src/lib/services/furni-import.ts b/src/lib/services/furni-import.ts index 0e291dd27b..66e9fbad21 100644 --- a/src/lib/services/furni-import.ts +++ b/src/lib/services/furni-import.ts @@ -1063,11 +1063,12 @@ async function realNitroModes(classname: string): Promise { } } -/** Verify and fix interaction_modes_count for ALL furniture in items_base. - * Run after import to ensure all items have correct values based on real - * furniture data. Only items with authoritative data (furnidata flags or - * .nitro animation states) are touched — keyword guesses are never applied - * here, so there are no false positives. */ +/** Verify and fix interaction values for ALL furniture in items_base. + * Run after import to ensure every item's interaction_type, modes count and + * sit/lay/stand flags match the real furniture data. Only items with + * authoritative data (furnidata flags or .nitro animation states) are + * touched — keyword guesses are never applied here, so there are no false + * positives. */ export async function verifyAndFixInteractionModesCount(): Promise<{ fixed: number; checked: number; @@ -1085,6 +1086,10 @@ export async function verifyAndFixInteractionModesCount(): Promise<{ id: ItemsBase.id, itemName: ItemsBase.itemName, publicName: ItemsBase.publicName, + allowSit: ItemsBase.allowSit, + allowLay: ItemsBase.allowLay, + allowWalk: ItemsBase.allowWalk, + interactionType: ItemsBase.interactionType, interactionModesCount: ItemsBase.interactionModesCount, }) .from(ItemsBase); @@ -1106,14 +1111,43 @@ export async function verifyAndFixInteractionModesCount(): Promise<{ canstandon: realFlags.canstandon, animationStates: animationModes, }); - const expectedModes = auto.interactionModesCount; - const currentModes = item.interactionModesCount ?? 0; - if (currentModes !== expectedModes) { + const changes: Partial> = {}; + // allow_sit/lay/walk of 2 is emulator-special (e.g. tents lay=2, + // walk-through walk=2) — never overwrite those with a 0/1. + if ( + item.allowSit !== 2 && + (item.allowSit ? 1 : 0) !== (auto.canSit ? 1 : 0) + ) + changes.allowSit = auto.canSit ? 1 : 0; + if ( + item.allowLay !== 2 && + (item.allowLay ? 1 : 0) !== (auto.canLay ? 1 : 0) + ) + changes.allowLay = auto.canLay ? 1 : 0; + if ( + item.allowWalk !== 2 && + (item.allowWalk ? 1 : 0) !== (auto.canStand ? 1 : 0) + ) + changes.allowWalk = auto.canStand ? 1 : 0; + if ((item.interactionModesCount ?? 0) !== auto.interactionModesCount) + changes.interactionModesCount = auto.interactionModesCount; + // Only fill interaction_type when the DB still has the generic + // "default" (nothing emulator-specific configured). Never overwrite + // an existing handler type (e.g. intelligence_bookcase, nest, wf_*) + // — those are emulator semantics that real furnidata cannot replace. + if ( + (item.interactionType === "default" || !item.interactionType) && + auto.interactionType !== "default" + ) { + changes.interactionType = auto.interactionType; + } + + if (Object.keys(changes).length > 0) { try { await db .update(ItemsBase) - .set({ interactionModesCount: expectedModes }) + .set(changes) .where(eq(ItemsBase.id, item.id)); fixed++; } catch (err) {