You've already forked Nitro_Render_V3
mirror of
https://github.com/duckietm/Nitro_Render_V3.git
synced 2026-06-19 15:06:20 +00:00
feat(utils): split-aware gamedata loader with tiered merge
Introduces loadGamedata(url, options?) and mergeGamedata(a, b) in @nitrots/utils. The loader transparently accepts: - a single-file URL (legacy) -> parsed as before - a directory URL ending with '/' -> tier-merged from core/custom/seasonal, each tier driven by its own manifest.json5 Merge rules: - arrays of objects sharing an id key (id, classname, name): merged by id, later layers overriding earlier ones - arrays without an id key: concatenated - plain objects: recursive merge per key - anything else: later value wins All gamedata consumers (FurnitureDataLoader, ProductDataLoader, EffectAssetDownloadManager, AvatarRenderManager actions+figuredata, LocalizationManager) are migrated to loadGamedata. Behaviour is unchanged for single-file URLs, so existing deployments need no config changes; opt-in to split mode by appending '/' to the URL once the layout is in place. README updated with the directory layout, merge table and programmatic usage example. The companion CLI splitter that produces the core/ tier from legacy files lives in the Nitro V3 client repo.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { FurnitureType, IFurnitureData } from '@nitrots/api';
|
||||
import { GetConfiguration } from '@nitrots/configuration';
|
||||
import { GetLocalizationManager } from '@nitrots/localization';
|
||||
import { parseConfigJsonFromResponse } from '@nitrots/utils';
|
||||
import { loadGamedata } from '@nitrots/utils';
|
||||
import { FurnitureData } from './FurnitureData';
|
||||
|
||||
export class FurnitureDataLoader
|
||||
@@ -21,28 +21,15 @@ export class FurnitureDataLoader
|
||||
|
||||
if(!url || !url.length) throw new Error('Missing "furnidata.url" in config — add the furniture data URL to your renderer-config.json');
|
||||
|
||||
let response: Response;
|
||||
|
||||
try
|
||||
{
|
||||
response = await fetch(url);
|
||||
}
|
||||
catch(fetchErr)
|
||||
{
|
||||
throw new Error(`Could not fetch furniture data from "${ url }" — check "furnidata.url" in renderer-config.json (${ fetchErr.message })`);
|
||||
}
|
||||
|
||||
if(response.status !== 200) throw new Error(`Failed to load furniture data from "${ url }" — server returned HTTP ${ response.status }. Check "furnidata.url" in renderer-config.json`);
|
||||
|
||||
let responseData: any;
|
||||
|
||||
try
|
||||
{
|
||||
responseData = await parseConfigJsonFromResponse(response, url);
|
||||
responseData = await loadGamedata(url);
|
||||
}
|
||||
catch(parseErr)
|
||||
catch(err)
|
||||
{
|
||||
throw new Error(`Invalid furniture data "${ url }" — JSON/JSON5 parse failed. Check "furnidata.url" in renderer-config.json (${ parseErr.message })`);
|
||||
throw new Error(`Could not load furniture data from "${ url }" — check "furnidata.url" in renderer-config.json (${ err?.message || err })`);
|
||||
}
|
||||
|
||||
if(responseData.roomitemtypes) this.parseFloorItems(responseData.roomitemtypes);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { IProductData } from '@nitrots/api';
|
||||
import { GetConfiguration } from '@nitrots/configuration';
|
||||
import { parseConfigJsonFromResponse } from '@nitrots/utils';
|
||||
import { loadGamedata } from '@nitrots/utils';
|
||||
import { ProductData } from './ProductData';
|
||||
|
||||
export class ProductDataLoader
|
||||
@@ -18,28 +18,15 @@ export class ProductDataLoader
|
||||
|
||||
if(!url || !url.length) throw new Error('Missing "productdata.url" in config — add the product data URL to your renderer-config.json');
|
||||
|
||||
let response: Response;
|
||||
|
||||
try
|
||||
{
|
||||
response = await fetch(url);
|
||||
}
|
||||
catch(fetchErr)
|
||||
{
|
||||
throw new Error(`Could not fetch product data from "${ url }" — check "productdata.url" in renderer-config.json (${ fetchErr.message })`);
|
||||
}
|
||||
|
||||
if(response.status !== 200) throw new Error(`Failed to load product data from "${ url }" — server returned HTTP ${ response.status }. Check "productdata.url" in renderer-config.json`);
|
||||
|
||||
let responseData: any;
|
||||
|
||||
try
|
||||
{
|
||||
responseData = await parseConfigJsonFromResponse(response, url);
|
||||
responseData = await loadGamedata(url);
|
||||
}
|
||||
catch(parseErr)
|
||||
catch(err)
|
||||
{
|
||||
throw new Error(`Invalid product data "${ url }" — JSON/JSON5 parse failed. Check "productdata.url" in renderer-config.json (${ parseErr.message })`);
|
||||
throw new Error(`Could not load product data from "${ url }" — check "productdata.url" in renderer-config.json (${ err?.message || err })`);
|
||||
}
|
||||
|
||||
this.parseProducts(responseData.productdata);
|
||||
|
||||
Reference in New Issue
Block a user