fix: map furni imports to production gamedata
This commit is contained in:
1 parent
a81af2d71a
commit
01570874a8
6 files changed
+224
-15
No files matched your search
@@ -7,6 +7,8 @@ export const DEFAULT_NITRO_FILES_ROOT = path.join(
|
||||
"DEV",
|
||||
"Nitro-Files",
|
||||
);
|
||||
export const DEFAULT_GAMEDATA_ROOT =
|
||||
process.platform === "win32" ? "" : "/var/www/Gamedata";
|
||||
export const DEFAULT_FURNI_ICON_DIR = path.join(
|
||||
/*turbopackIgnore: true*/ process.cwd(),
|
||||
"public/swf/dcr/hof_furni/icons",
|
||||
@@ -63,6 +65,16 @@ export async function getNitroFilesRoot(): Promise<string> {
|
||||
: "";
|
||||
}
|
||||
|
||||
export async function getGamedataRoot(): Promise<string> {
|
||||
const configured = (await siteSettings.get("gamedata_root", "")) ?? "";
|
||||
if (configured.trim()) return normalizeDir(configured, configured);
|
||||
|
||||
return DEFAULT_GAMEDATA_ROOT &&
|
||||
existsSync(/*turbopackIgnore: true*/ DEFAULT_GAMEDATA_ROOT)
|
||||
? normalizeDir(DEFAULT_GAMEDATA_ROOT, DEFAULT_GAMEDATA_ROOT)
|
||||
: "";
|
||||
}
|
||||
|
||||
function dirsFromNitroFilesRoot(root: string): FurniAssetDirs {
|
||||
return {
|
||||
swfDir: path.join(/*turbopackIgnore: true*/ root, "swf/dcr/hof_furni"),
|
||||
@@ -77,6 +89,17 @@ function dirsFromNitroFilesRoot(root: string): FurniAssetDirs {
|
||||
};
|
||||
}
|
||||
|
||||
function dirsFromGamedataRoot(
|
||||
root: string,
|
||||
primarySwfDir: string,
|
||||
): FurniAssetDirs {
|
||||
return {
|
||||
swfDir: primarySwfDir,
|
||||
iconDir: path.join(/*turbopackIgnore: true*/ root, "icons"),
|
||||
nitroDir: path.join(/*turbopackIgnore: true*/ root, "bundled/furniture"),
|
||||
};
|
||||
}
|
||||
|
||||
export async function getFurniAssetDirs(): Promise<FurniAssetDirs> {
|
||||
const [swfDir, iconDir, nitroDir] = await Promise.all([
|
||||
siteSettings
|
||||
@@ -99,10 +122,16 @@ export async function getFurniAssetDirs(): Promise<FurniAssetDirs> {
|
||||
|
||||
export async function getFurniAssetWriteTargets(): Promise<FurniAssetWriteTargets> {
|
||||
const primary = await getFurniAssetDirs();
|
||||
const nitroFilesRoot = await getNitroFilesRoot();
|
||||
const mirrorCandidates = nitroFilesRoot
|
||||
? [dirsFromNitroFilesRoot(nitroFilesRoot)]
|
||||
: [];
|
||||
const [nitroFilesRoot, gamedataRoot] = await Promise.all([
|
||||
getNitroFilesRoot(),
|
||||
getGamedataRoot(),
|
||||
]);
|
||||
const mirrorCandidates = [
|
||||
...(nitroFilesRoot ? [dirsFromNitroFilesRoot(nitroFilesRoot)] : []),
|
||||
...(gamedataRoot
|
||||
? [dirsFromGamedataRoot(gamedataRoot, primary.swfDir)]
|
||||
: []),
|
||||
];
|
||||
|
||||
const primaryKey = {
|
||||
swfDir:
|
||||
@@ -119,18 +148,26 @@ export async function getFurniAssetWriteTargets(): Promise<FurniAssetWriteTarget
|
||||
: primary.nitroDir,
|
||||
};
|
||||
|
||||
const seenCandidates = new Set<string>();
|
||||
const mirrorDirs = mirrorCandidates.filter((dirs) => {
|
||||
const swfDir = normalizeDir(dirs.swfDir, dirs.swfDir);
|
||||
const iconDir = normalizeDir(dirs.iconDir, dirs.iconDir);
|
||||
const nitroDir = normalizeDir(dirs.nitroDir, dirs.nitroDir);
|
||||
return (
|
||||
const isDifferent =
|
||||
(process.platform === "win32" ? swfDir.toLowerCase() : swfDir) !==
|
||||
primaryKey.swfDir ||
|
||||
(process.platform === "win32" ? iconDir.toLowerCase() : iconDir) !==
|
||||
primaryKey.iconDir ||
|
||||
(process.platform === "win32" ? nitroDir.toLowerCase() : nitroDir) !==
|
||||
primaryKey.nitroDir
|
||||
);
|
||||
primaryKey.nitroDir;
|
||||
if (!isDifferent) return false;
|
||||
|
||||
const candidateKey = [swfDir, iconDir, nitroDir]
|
||||
.map((dir) => (process.platform === "win32" ? dir.toLowerCase() : dir))
|
||||
.join("\0");
|
||||
if (seenCandidates.has(candidateKey)) return false;
|
||||
seenCandidates.add(candidateKey);
|
||||
return true;
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user