fix: use configured furni source and catalog assets
This commit is contained in:
1 parent
aed70db81f
commit
c78f8812ad
25 files changed
+368
-129
No files matched your search
@@ -2,14 +2,16 @@ import { existsSync, promises as fs } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { and, eq, type SQL, sql } from "drizzle-orm";
|
||||
import { CatalogPages, db, ItemsBase } from "@/lib/db";
|
||||
import { officialHabboEnrichmentWarning } from "@/lib/habbo-gamedata-hotel";
|
||||
import { logger } from "@/lib/logger";
|
||||
import {
|
||||
appendFurniEntry,
|
||||
buildFurniEntry,
|
||||
removeFurniEntry,
|
||||
} from "@/lib/services/furni-data";
|
||||
import type { HabboItFurniEntry } from "@/lib/services/habbo-furnidata-cache";
|
||||
import { lookupHabboIt } from "@/lib/services/habbo-furnidata-cache";
|
||||
import type { OfficialHabboFurniEntry } from "@/lib/services/habbo-furnidata-cache";
|
||||
import { lookupOfficialHabboFurni } from "@/lib/services/habbo-furnidata-cache";
|
||||
import { getHabboGamedataHotel } from "@/lib/services/habbo-gamedata-hotel";
|
||||
|
||||
// Re-export the download helpers now owned by the shared import core.
|
||||
// Existing furni callers keep importing them from here.
|
||||
@@ -396,22 +398,23 @@ export async function importSingleFurni(params: {
|
||||
const itemType = type === "wallitem" ? "i" : "s";
|
||||
const spriteId = originalId;
|
||||
|
||||
// ── Cross-reference with habbo.it furnidata for enrichment ────────
|
||||
let habboIt: HabboItFurniEntry | null = null;
|
||||
// ── Cross-reference with configured official Habbo furnidata ──────
|
||||
let officialHabbo: OfficialHabboFurniEntry | null = null;
|
||||
try {
|
||||
habboIt = await lookupHabboIt(classname);
|
||||
if (habboIt) {
|
||||
warnings.push(`Enriched from habbo.it: "${habboIt.name}"`);
|
||||
const hotel = await getHabboGamedataHotel();
|
||||
officialHabbo = await lookupOfficialHabboFurni(classname);
|
||||
if (officialHabbo) {
|
||||
warnings.push(officialHabboEnrichmentWarning(hotel, officialHabbo.name));
|
||||
}
|
||||
} catch {
|
||||
// Non-blocking: habbo.it enrichment is optional
|
||||
// Non-blocking: official Habbo enrichment is optional
|
||||
}
|
||||
|
||||
// Best values: use habbo.it furnidata for enrichment
|
||||
const bestName = name || habboIt?.name || classname;
|
||||
const bestDescription = description || habboIt?.description || "";
|
||||
const bestRevision = revision || habboIt?.revision || 0;
|
||||
const bestCategory = category || habboIt?.category || "unknown";
|
||||
// Best values: use configured official Habbo furnidata for enrichment.
|
||||
const bestName = name || officialHabbo?.name || classname;
|
||||
const bestDescription = description || officialHabbo?.description || "";
|
||||
const bestRevision = revision || officialHabbo?.revision || 0;
|
||||
const bestCategory = category || officialHabbo?.category || "unknown";
|
||||
|
||||
// ── Insert into DB with enriched data ──────────────────────────────
|
||||
onProgress?.("writing_db");
|
||||
@@ -581,15 +584,15 @@ export async function importSingleFurni(params: {
|
||||
// ── Build enriched FurnitureData entry ────────────────────────────
|
||||
const dims =
|
||||
conversionResult?.dimensions ||
|
||||
(habboIt
|
||||
? { x: habboIt.xdim, y: habboIt.ydim, z: 0 }
|
||||
(officialHabbo
|
||||
? { x: officialHabbo.xdim, y: officialHabbo.ydim, z: 0 }
|
||||
: { x: 1, y: 1, z: 0 });
|
||||
const meta = conversionResult?.metadata ?? null;
|
||||
|
||||
// Merge interaction flags: prefer .nitro extraction, fallback to habbo.it
|
||||
const cansiton = meta?.cansiton ?? habboIt?.cansiton ?? false;
|
||||
const canlayon = meta?.canlayon ?? habboIt?.canlayon ?? false;
|
||||
const canstandon = meta?.canstandon ?? habboIt?.canstandon ?? false;
|
||||
// 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;
|
||||
|
||||
// Derive interaction_type. Priority:
|
||||
// 1. Wired LOGIC items (wf_act_/wf_trg_/wf_cnd_/wf_slc_/wf_xtra_/wf_var_)
|
||||
@@ -657,7 +660,7 @@ export async function importSingleFurni(params: {
|
||||
spriteId,
|
||||
dims,
|
||||
metadata: meta,
|
||||
habboIt,
|
||||
officialHabbo,
|
||||
});
|
||||
|
||||
// ── Add to FurnitureData.json (or defer for batch) ────────────────
|
||||
|
||||
Reference in new issue
Block a user