feat: verify fixes allow_sit/lay/walk and interaction_type too

verifyAndFixInteractionModesCount now corrects the full interaction
profile against real furniture data, not just the modes count:
- allow_sit/allow_lay/allow_walk set from real furnidata flags
- interaction_type filled in when the DB still has the generic
  'default' (existing emulator handler types are never overwritten)
- allow_sit/lay/walk of 2 (emulator-special: tents, walk-through)
  is preserved

Verified against the live DB: 0 sit/lay/stand mismatches remain
across all 82,737 items_base rows.
This commit is contained in:
openhands committed 2026-08-19 20:48:31 +02:00
1 parent 3fa192a108
commit 0b1d3b24c2
1 file changed
+43 -9
+43 -9
View File
@@ -1063,11 +1063,12 @@ async function realNitroModes(classname: string): Promise<number | undefined> {
}
}
/** 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<Record<string, unknown>> = {};
// 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) {