mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-13 08:13:46 +00:00
A new server (dUgcServer, started by master with enable_ugc_server=1) that takes unprocessed ugc and ugc_modular_build rows from the database and makes what the client downloads with UGCUSE3DSERVICES: an optimized NIF (hidden faces removed, ambient occlusion baked into vertex colors) and a 128px DDS icon for player models, rendered by a software rasterizer from the client's LDD brick primitives, and icons for cars and rockets assembled from their modules per ModularBuildComponent/ModuleComponent. It serves them, with the models' LXFML, over HTTP in the client's UGCC<dc>/3DOPTIMIZED and IMAGE128DDS layout with .gz and .checksum files, and keeps its folder under a size cap. Processing state lives in ugc.is_optimized plus new processed_at, process_attempts and process_error columns (and the same on ugc_modular_build). ServiceType::UGC is appended. NifFile moves to dCommon and records named node transforms for the modules' attach points. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
56 lines
1.8 KiB
C++
56 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <filesystem>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <vector>
|
|
|
|
#include "UgcBricks.h"
|
|
#include "UgcRender.h"
|
|
#include "UgcStorage.h"
|
|
|
|
/**
|
|
* The work a UGC worker thread does for one item: everything from the stored LXFML (or a modular build's modules) to
|
|
* the finished files. No database, network or CDClient: the main thread gathers the input and stores the result.
|
|
*/
|
|
namespace UgcJobs {
|
|
struct Settings {
|
|
UgcRender::OptimizeOptions optimize;
|
|
UgcRender::IconOptions icon;
|
|
UgcRender::IconOptions modularIcon;
|
|
};
|
|
|
|
struct Outcome {
|
|
bool ok{};
|
|
std::string error; // why it failed
|
|
std::string note; // what was odd but not fatal (missing bricks, ...)
|
|
UgcStorage::Files files; // name -> bytes, when ok
|
|
bool aoBaked{};
|
|
};
|
|
|
|
// The client's download of `data` (`name` + ".gz" and ".checksum") added to `files`
|
|
void AddDownload(UgcStorage::Files& files, const std::string& name, const std::string& data);
|
|
|
|
// The LXFML of a ugc row's lxfml column (an sd0 stream, or plain LXFML); empty when it can't be read
|
|
std::string LxfmlFromBlob(const std::string& blob);
|
|
|
|
// A player model: the optimized .nif, its icon and its LXFML for download
|
|
Outcome ProcessModel(const std::string& blob, UgcBricks::BrickLibrary& library, const Settings& settings);
|
|
|
|
struct ModuleInput {
|
|
uint32_t lot{};
|
|
uint32_t partCode{};
|
|
std::string renderAsset; // RenderComponent.render_asset, relative to the client's res folder
|
|
std::string moduleXml; // ModuleComponent.xml
|
|
};
|
|
|
|
struct ModularInput {
|
|
std::vector<ModuleInput> modules;
|
|
std::string buildXml; // ModularBuildComponent.xml of the modules' build type
|
|
};
|
|
|
|
// A modular build's icon, from its modules' meshes put together
|
|
Outcome ProcessModular(const ModularInput& input, const std::filesystem::path& res, const Settings& settings);
|
|
}
|