Compare commits
2
Commits
652d331402
...
92b0ba3b18
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
92b0ba3b18 | ||
|
|
4b7cb519df |
No files matched your search
@@ -10,6 +10,7 @@ import { getSource } from "@/lib/services/clone-sources";
|
||||
import {
|
||||
appendFurniEntriesBatch,
|
||||
appendFurniEntry,
|
||||
rebuildCatalogOfferIds,
|
||||
reconcileFurniDataWithItemsBase,
|
||||
} from "@/lib/services/furni-data";
|
||||
import {
|
||||
@@ -142,6 +143,7 @@ export const POST = withAdmin(
|
||||
try {
|
||||
await reconcileImportedOfferIds();
|
||||
await reconcileFurniDataWithItemsBase();
|
||||
await rebuildCatalogOfferIds();
|
||||
await verifyAndFixInteractionModesCount();
|
||||
await ensureFurniOwnership();
|
||||
await syncAssetsToGamedataBundle();
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
appendFurniEntriesBatch,
|
||||
buildFurniEntry,
|
||||
readFurniData,
|
||||
rebuildCatalogOfferIds,
|
||||
reconcileFurniDataWithItemsBase,
|
||||
} from "@/lib/services/furni-data";
|
||||
import {
|
||||
@@ -269,6 +270,9 @@ export const POST = withAdmin(
|
||||
// Verify the furnidata matches the DB ids
|
||||
const furniReconcile = await reconcileFurniDataWithItemsBase();
|
||||
|
||||
// Rebuild every catalog offer_id from the furnidata
|
||||
const offerRebuild = await rebuildCatalogOfferIds();
|
||||
|
||||
send({
|
||||
type: "regen_complete",
|
||||
succeeded,
|
||||
@@ -281,6 +285,8 @@ export const POST = withAdmin(
|
||||
furniDataFixedIds: furniReconcile.fixedIds,
|
||||
furniDataMissing: furniReconcile.missing,
|
||||
furniDataConflicts: furniReconcile.conflicts,
|
||||
offerRebuildChecked: offerRebuild.checked,
|
||||
offerRebuildFixed: offerRebuild.fixed,
|
||||
duration: Date.now() - startTime,
|
||||
});
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import { logAudit } from "@/lib/services/audit";
|
||||
import { getSource } from "@/lib/services/clone-sources";
|
||||
import {
|
||||
appendFurniEntriesBatch,
|
||||
rebuildCatalogOfferIds,
|
||||
reconcileFurniDataWithItemsBase,
|
||||
} from "@/lib/services/furni-data";
|
||||
import {
|
||||
@@ -227,6 +228,7 @@ export const POST = withAdmin(
|
||||
let furniDataFixedOfferIds = 0;
|
||||
let furniDataMissing = 0;
|
||||
let furniDataConflicts = 0;
|
||||
let offerRebuildFixed = 0;
|
||||
let interactionFixed = 0;
|
||||
try {
|
||||
offerIdsFixed = (await reconcileImportedOfferIds()).fixed;
|
||||
@@ -239,6 +241,7 @@ export const POST = withAdmin(
|
||||
furniDataFixedOfferIds = furniReconcile.fixedOfferIds;
|
||||
furniDataMissing = furniReconcile.missing;
|
||||
furniDataConflicts = furniReconcile.conflicts;
|
||||
offerRebuildFixed = (await rebuildCatalogOfferIds()).fixed;
|
||||
interactionFixed = (await verifyAndFixInteractionModesCount()).fixed;
|
||||
} catch (err) {
|
||||
console.warn(
|
||||
@@ -260,6 +263,7 @@ export const POST = withAdmin(
|
||||
furniDataFixedOfferIds,
|
||||
furniDataMissing,
|
||||
furniDataConflicts,
|
||||
offerRebuildFixed,
|
||||
interactionFixed,
|
||||
duration: Date.now() - startTime,
|
||||
});
|
||||
|
||||
@@ -9,7 +9,10 @@ import { logAudit } from "@/lib/services/audit";
|
||||
import { getCloneList } from "@/lib/services/clone-import";
|
||||
import { getSource } from "@/lib/services/clone-sources";
|
||||
import { getFurniAssetDirs } from "@/lib/services/furni-asset-dirs";
|
||||
import { reconcileFurniDataWithItemsBase } from "@/lib/services/furni-data";
|
||||
import {
|
||||
rebuildCatalogOfferIds,
|
||||
reconcileFurniDataWithItemsBase,
|
||||
} from "@/lib/services/furni-data";
|
||||
import {
|
||||
autoPriceFurni,
|
||||
CATEGORY_PAGE,
|
||||
@@ -171,11 +174,14 @@ export const GET = withAdmin(
|
||||
// Live furnidata reconcile (without hotel RCON reload)
|
||||
if (action === "live-reconcile") {
|
||||
const furniReconcile = await reconcileFurniDataWithItemsBase();
|
||||
const offerRebuild = await rebuildCatalogOfferIds();
|
||||
return apiOk({
|
||||
furniDataFixedIds: furniReconcile.fixedIds,
|
||||
furniDataFixedOfferIds: furniReconcile.fixedOfferIds,
|
||||
furniDataMissing: furniReconcile.missing,
|
||||
furniDataConflicts: furniReconcile.conflicts,
|
||||
offerRebuildChecked: offerRebuild.checked,
|
||||
offerRebuildFixed: offerRebuild.fixed,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -452,6 +458,9 @@ export const POST = withAdmin(
|
||||
// Verify the furnidata matches the DB ids
|
||||
const furniReconcile = await reconcileFurniDataWithItemsBase();
|
||||
|
||||
// Rebuild every catalog offer_id from the furnidata
|
||||
const offerRebuild = await rebuildCatalogOfferIds();
|
||||
|
||||
// Verify + fix interaction_modes_count once for the whole batch
|
||||
const verification = await verifyAndFixInteractionModesCount();
|
||||
|
||||
@@ -471,6 +480,8 @@ export const POST = withAdmin(
|
||||
furniDataFixedOfferIds: furniReconcile.fixedOfferIds,
|
||||
furniDataMissing: furniReconcile.missing,
|
||||
furniDataConflicts: furniReconcile.conflicts,
|
||||
offerRebuildChecked: offerRebuild.checked,
|
||||
offerRebuildFixed: offerRebuild.fixed,
|
||||
interactionFixed: verification.fixed,
|
||||
});
|
||||
}
|
||||
@@ -533,6 +544,9 @@ export const POST = withAdmin(
|
||||
// Verify the furnidata matches the DB ids
|
||||
const furniReconcile = await reconcileFurniDataWithItemsBase();
|
||||
|
||||
// Rebuild every catalog offer_id from the furnidata
|
||||
const offerRebuild = await rebuildCatalogOfferIds();
|
||||
|
||||
// Verify + fix interaction_modes_count (single consolidated pass)
|
||||
const verification = await verifyAndFixInteractionModesCount();
|
||||
|
||||
@@ -564,6 +578,8 @@ export const POST = withAdmin(
|
||||
furniDataFixedOfferIds: furniReconcile.fixedOfferIds,
|
||||
furniDataMissing: furniReconcile.missing,
|
||||
furniDataConflicts: furniReconcile.conflicts,
|
||||
offerRebuildChecked: offerRebuild.checked,
|
||||
offerRebuildFixed: offerRebuild.fixed,
|
||||
interactionFixed: verification.fixed,
|
||||
spriteCount: result.spriteCount,
|
||||
warnings: result.warnings,
|
||||
|
||||
@@ -151,17 +151,16 @@ export function StudioClient({
|
||||
result = result.filter((i) => i.category === categoryFilter);
|
||||
}
|
||||
if (statusFilter !== "all") {
|
||||
if (statusFilter === "new")
|
||||
result = result.filter((i) => !i.alreadyImported);
|
||||
else if (statusFilter === "imported")
|
||||
if (statusFilter === "imported")
|
||||
result = result.filter((i) => i.alreadyImported);
|
||||
else if (statusFilter === "inCatalog")
|
||||
result = result.filter((i) => i.alreadyImported && i.nitroExists);
|
||||
else if (statusFilter === "missingNitro")
|
||||
result = result.filter((i) => i.alreadyImported && !i.nitroExists);
|
||||
else if (statusFilter === "notImported")
|
||||
result = result.filter((i) => !i.alreadyImported);
|
||||
}
|
||||
// Not imported filter - works independently (also with statusFilter === "all")
|
||||
if (statusFilter === "notImported" || statusFilter === "all")
|
||||
result = result.filter((i) => i.alreadyImported === false);
|
||||
const sorted = [...result];
|
||||
if (sortBy === "name") sorted.sort((a, b) => a.name.localeCompare(b.name));
|
||||
else if (sortBy === "classname")
|
||||
@@ -597,6 +596,11 @@ export function StudioClient({
|
||||
[filteredItems],
|
||||
);
|
||||
|
||||
const notImportedCount = useMemo(
|
||||
() => filteredItems.filter((i) => i.alreadyImported === false).length,
|
||||
[filteredItems],
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
className="flex h-[calc(100dvh-7rem)] min-h-[520px] flex-col overflow-hidden rounded-xl border border-[var(--admin-border)]"
|
||||
@@ -741,8 +745,9 @@ export function StudioClient({
|
||||
<SelectValue placeholder="Status" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all">All statuses</SelectItem>
|
||||
<SelectItem value="new">Not imported</SelectItem>
|
||||
<SelectItem value="all">
|
||||
All statuses {notImportedCount > 0 && notImportedCount}
|
||||
</SelectItem>
|
||||
<SelectItem value="imported">Imported</SelectItem>
|
||||
<SelectItem value="inCatalog">In catalog</SelectItem>
|
||||
<SelectItem value="missingNitro">Missing nitro</SelectItem>
|
||||
|
||||
@@ -30,16 +30,52 @@ describe("autoDetectInteraction with real data", () => {
|
||||
expect(result.interactionType).toBe("bed");
|
||||
});
|
||||
|
||||
it("respects all-false real flags (no keyword false positive)", () => {
|
||||
it("respects curated all-false real flags (no keyword false positive)", () => {
|
||||
const result = autoDetectInteraction("table_plasto_4leg", "Table", {
|
||||
cansiton: false,
|
||||
canlayon: false,
|
||||
canstandon: false,
|
||||
hasActionData: true,
|
||||
});
|
||||
expect(result.canSit).toBe(false);
|
||||
expect(result.canLay).toBe(false);
|
||||
expect(result.canStand).toBe(false);
|
||||
expect(result.interactionModesCount).toBe(0);
|
||||
});
|
||||
|
||||
it("falls back to keywords when flags carry no action data", () => {
|
||||
const result = autoDetectInteraction("chaise_metal_lamarr", "Chaise", {
|
||||
cansiton: false,
|
||||
canlayon: false,
|
||||
canstandon: false,
|
||||
animationStates: 4,
|
||||
});
|
||||
expect(result.canSit).toBe(true);
|
||||
expect(result.canStand).toBe(false);
|
||||
expect(result.interactionModesCount).toBe(4);
|
||||
});
|
||||
|
||||
it("detects French bench (banquette) with raw state count", () => {
|
||||
const result = autoDetectInteraction("banquette_lamarr", "Banquette", {
|
||||
cansiton: false,
|
||||
canlayon: false,
|
||||
canstandon: false,
|
||||
animationStates: 6,
|
||||
});
|
||||
expect(result.canSit).toBe(true);
|
||||
expect(result.interactionType).toBe("bench");
|
||||
expect(result.interactionModesCount).toBe(6);
|
||||
});
|
||||
|
||||
it("does not match short keywords without token boundaries", () => {
|
||||
const result = autoDetectInteraction("bedside_table", "Bedside Table", {
|
||||
cansiton: false,
|
||||
canlayon: false,
|
||||
canstandon: false,
|
||||
});
|
||||
expect(result.canSit).toBe(false);
|
||||
expect(result.canLay).toBe(false);
|
||||
expect(result.canStand).toBe(false);
|
||||
expect(result.interactionModesCount).toBe(0);
|
||||
expect(result.interactionType).toBe("table");
|
||||
});
|
||||
|
||||
it("detects dice mechanics from classname with fixed modes=6", () => {
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -361,6 +361,16 @@ export async function generateCatalogSql(
|
||||
skipped++;
|
||||
continue;
|
||||
}
|
||||
// Re-check against the live table: the audit snapshot may be stale and
|
||||
// an import may have created the entry in the meantime. Inserting would
|
||||
// create a duplicate catalog_items row for the same item_ids.
|
||||
const [existing] = (await db.execute(sql`
|
||||
SELECT id FROM catalog_items WHERE item_ids = ${String(entry.itemId)} LIMIT 1
|
||||
`)) as unknown as [Array<{ id: number }>, unknown];
|
||||
if (existing.length > 0) {
|
||||
skipped++;
|
||||
continue;
|
||||
}
|
||||
let pageId: number;
|
||||
if (organizeSql && parentPageId) {
|
||||
const catKey = classifyFurni(entry.classname, entry.itemType);
|
||||
|
||||
@@ -379,6 +379,8 @@ export async function cloneSingleFurni(params: {
|
||||
cansiton: entry.cansiton,
|
||||
canlayon: entry.canlayon,
|
||||
canstandon: entry.canstandon,
|
||||
// Source furnidata flags are curated → authoritative over keywords.
|
||||
hasActionData: true,
|
||||
logicType: (clonedNitroJson?.logicType as string) || undefined,
|
||||
animationStates: nitroAnimationStatesCount(clonedNitroJson),
|
||||
});
|
||||
@@ -440,7 +442,17 @@ export async function cloneSingleFurni(params: {
|
||||
}
|
||||
|
||||
// Catalog entry (category sub-page + auto price), serialized id allocation.
|
||||
// Skip when the item already has a catalog row — re-imports must never
|
||||
// create a second row for the same item_ids.
|
||||
try {
|
||||
const [existingCatalog] = (await db.execute(sql`
|
||||
SELECT id FROM catalog_items WHERE item_ids = ${String(newId)} LIMIT 1
|
||||
`)) as unknown as [Array<{ id: number }>, unknown];
|
||||
if (existingCatalog.length > 0) {
|
||||
warnings.push(
|
||||
`catalog entry already exists (#${existingCatalog[0].id}) — skipped duplicate`,
|
||||
);
|
||||
} else {
|
||||
const pageId = await getOrCreateCategoryPage(classname, itemType);
|
||||
const price = autoPriceFurni(classname);
|
||||
await allocateCatalogItemId(async (nextCatalogId) => {
|
||||
@@ -449,6 +461,7 @@ export async function cloneSingleFurni(params: {
|
||||
VALUES (${nextCatalogId}, ${String(pageId)}, ${String(newId)}, ${classname}, ${price.credits}, ${price.points}, ${price.pointsType}, 1, 1, ${newId}, '')`);
|
||||
return nextCatalogId;
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
logger.warn("[clone-import] catalog entry failed for", {
|
||||
classname,
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -848,10 +848,21 @@ export async function importSingleFurni(params: {
|
||||
: { x: 1, y: 1, z: 0 });
|
||||
const meta = conversionResult?.metadata ?? null;
|
||||
|
||||
// Prefer .nitro flags, then the configured official Habbo furnidata.
|
||||
const cansiton = meta?.cansiton ?? officialHabbo?.cansiton ?? false;
|
||||
const canlayon = meta?.canlayon ?? officialHabbo?.canlayon ?? false;
|
||||
const canstandon = meta?.canstandon ?? officialHabbo?.canstandon ?? false;
|
||||
// Real sit/lay/stand flags: prefer .nitro logic flags, then the configured
|
||||
// official Habbo furnidata. Only pass them when a real source exists —
|
||||
// defaulted all-false values must not suppress keyword detection (custom
|
||||
// SWFs often ship without <action> nodes even for sittable furniture).
|
||||
const realSource = meta ?? officialHabbo;
|
||||
const realFlags = realSource
|
||||
? {
|
||||
cansiton: realSource.cansiton ?? false,
|
||||
canlayon: realSource.canlayon ?? false,
|
||||
canstandon: realSource.canstandon ?? false,
|
||||
// Official furnidata is curated → authoritative. SWF-derived flags
|
||||
// are only authoritative when the logic actually had <action> nodes.
|
||||
hasActionData: meta ? (meta.hasActions ?? true) : true,
|
||||
}
|
||||
: undefined;
|
||||
|
||||
// Derive interaction_type. Priority:
|
||||
// 1. Wired LOGIC items (wf_act_/wf_trg_/wf_cnd_/wf_slc_/wf_xtra_/wf_var_)
|
||||
@@ -903,9 +914,7 @@ export async function importSingleFurni(params: {
|
||||
// no .nitro JSON available — keyword fallback only
|
||||
}
|
||||
const autoInteraction = autoDetectInteraction(classname, bestName, {
|
||||
cansiton,
|
||||
canlayon,
|
||||
canstandon,
|
||||
...realFlags,
|
||||
logicType,
|
||||
animationStates: nitroAnimationStatesCount(nitroJsonForModes),
|
||||
});
|
||||
@@ -929,9 +938,9 @@ export async function importSingleFurni(params: {
|
||||
const update = buildItemsBaseEnrichmentUpdate({
|
||||
id: spriteId,
|
||||
dims,
|
||||
cansiton,
|
||||
canlayon,
|
||||
canstandon,
|
||||
cansiton: autoInteraction.canSit,
|
||||
canlayon: autoInteraction.canLay,
|
||||
canstandon: autoInteraction.canStand,
|
||||
allowStack,
|
||||
interactionType,
|
||||
interactionModesCount,
|
||||
@@ -1123,6 +1132,8 @@ export async function verifyAndFixInteractionModesCount(): Promise<{
|
||||
cansiton: realFlags.cansiton,
|
||||
canlayon: realFlags.canlayon,
|
||||
canstandon: realFlags.canstandon,
|
||||
// Furnidata flags are curated → authoritative over keywords.
|
||||
hasActionData: true,
|
||||
animationStates: animationModes,
|
||||
});
|
||||
|
||||
|
||||
@@ -425,6 +425,7 @@ export function convertSwfToNitro(
|
||||
canstandon: logic.canstandon,
|
||||
cansiton: logic.cansiton,
|
||||
canlayon: logic.canlayon,
|
||||
hasActions: logic.hasActions,
|
||||
specialtype: indexData?.specialtype ?? 0,
|
||||
defaultdir: computeDefaultDir(logic.directions),
|
||||
partcolors: extractPartColors(visualizations),
|
||||
|
||||
@@ -226,6 +226,8 @@ export interface LogicResult {
|
||||
canstandon: boolean;
|
||||
cansiton: boolean;
|
||||
canlayon: boolean;
|
||||
/** True when the logic XML actually declared <action> nodes — flags are then authoritative. */
|
||||
hasActions: boolean;
|
||||
action?: { link?: string; startState?: number };
|
||||
credits?: string;
|
||||
soundSample?: { id: number; noPitch?: boolean };
|
||||
@@ -242,6 +244,7 @@ export function processLogic(xml: string): LogicResult {
|
||||
canstandon: false,
|
||||
cansiton: false,
|
||||
canlayon: false,
|
||||
hasActions: false,
|
||||
};
|
||||
const root = parseXml(xml);
|
||||
if (!root) return defaults;
|
||||
@@ -285,6 +288,7 @@ export function processLogic(xml: string): LogicResult {
|
||||
canstandon,
|
||||
cansiton,
|
||||
canlayon,
|
||||
hasActions: actions.length > 0,
|
||||
};
|
||||
|
||||
// Parse action link/startState
|
||||
|
||||
@@ -337,6 +337,8 @@ export async function uploadSingleFurni(params: {
|
||||
cansiton,
|
||||
canlayon,
|
||||
canstandon,
|
||||
// Flags come from explicit user input → authoritative over keywords.
|
||||
hasActionData: true,
|
||||
logicType: (nitroMeta?.logicType as string) || undefined,
|
||||
animationStates: nitroAnimationStatesCount(nitroMeta),
|
||||
});
|
||||
@@ -387,6 +389,17 @@ export async function uploadSingleFurni(params: {
|
||||
|
||||
let catalogItemId: number | null = null;
|
||||
try {
|
||||
// Skip when the item already has a catalog row — re-uploads must never
|
||||
// create a second row for the same item_ids.
|
||||
const [existingCatalog] = (await db.execute(sql`
|
||||
SELECT id FROM catalog_items WHERE item_ids = ${String(newId)} LIMIT 1
|
||||
`)) as unknown as [Array<{ id: number }>, unknown];
|
||||
if (existingCatalog.length > 0) {
|
||||
catalogItemId = existingCatalog[0].id;
|
||||
warnings.push(
|
||||
`catalog entry already exists (#${catalogItemId}) — skipped duplicate`,
|
||||
);
|
||||
} else {
|
||||
const pageId = await getOrCreateCategoryPage(classname, itemType);
|
||||
catalogItemId = await allocateCatalogItemId(async (nextCatalogId) => {
|
||||
await db.execute(sql`
|
||||
@@ -394,6 +407,7 @@ export async function uploadSingleFurni(params: {
|
||||
VALUES (${nextCatalogId}, ${String(pageId)}, ${String(newId)}, ${classname}, ${price.credits}, ${price.points}, ${price.pointsType}, 1, 1, ${newId}, '')`);
|
||||
return nextCatalogId;
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
warnings.push(`catalog entry failed: ${(err as Error).message}`);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ export interface FurniMetadata {
|
||||
canstandon: boolean;
|
||||
cansiton: boolean;
|
||||
canlayon: boolean;
|
||||
/** True when the SWF logic XML declared <action> nodes (flags authoritative). */
|
||||
hasActions?: boolean;
|
||||
specialtype: number;
|
||||
defaultdir: number;
|
||||
partcolors: { color: string[] };
|
||||
|
||||
Reference in new issue
Block a user