mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 10:53:44 +00:00
Brighter icons: a world light, a fill from the camera, a highlight, exposure and contrast; with the defaults the icons' mean luminance matches the game's own model icons (118 against 120 on a scratch set). Every icon parameter is listed once (UgcIconParams: key, setting, range, default); the settings, the dashboard's settings entries and the icon editor come from that list. Presets per kind (player models, each car or rocket build type from ModularBuildComponent) and overrides per model or module combination are in ugc_icon_settings. Saved models wait ugc_debounce_seconds (sharedconfig) after the owner's last save before they're made (ugc.process_after); a client asking for one, the owner leaving the world or a reset ends the wait. Cars and rockets: one icon per combination of modules (sorted LOTs), shared by every build of it; builds of a combination made already are marked made right away, the client's per-blueprint downloads serve the shared files. The dashboard can delete one item's files, purge by filter or all, preview icons with any values on the UGC server (/admin routes, master password), save presets and overrides, and draw a kind's icons again (icons only). Migrations dlu/mysql/86 and dlu/sqlite/69. Not done yet: the dashboard editor's lighting controls in the page script (routes are there), docs for it, the empty-model state, /ugc?item= links, the shared fetch helper; the storage size and property loading bugs are next. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
72 lines
3.1 KiB
C++
72 lines
3.1 KiB
C++
#include "ModelNormalizeMigration.h"
|
|
|
|
#include "Database.h"
|
|
#include "Lxfml.h"
|
|
#include "Sd0.h"
|
|
|
|
void ModelNormalizeMigration::Run() {
|
|
const auto oldCommit = Database::Get()->GetAutoCommit();
|
|
Database::Get()->SetAutoCommit(false);
|
|
for (auto& [lxfmlData, id, modelID] : Database::Get()->GetAllUgcModels()) {
|
|
const auto model = Database::Get()->GetModel(modelID);
|
|
// only BBB models (lot 14) and models with a position of NiPoint3::ZERO need to have their position fixed.
|
|
if (!model || model->position != NiPoint3Constant::ZERO || model->lot != 14) continue;
|
|
|
|
Sd0 sd0(lxfmlData);
|
|
const auto asStr = sd0.GetAsStringUncompressed();
|
|
const auto [newLxfml, newCenter] = Lxfml::NormalizePositionOnlyFirstPart(asStr);
|
|
if (newCenter == NiPoint3Constant::ZERO) {
|
|
LOG("Failed to update model %llu due to failure reading xml.");
|
|
continue;
|
|
}
|
|
|
|
LOG("Updated model %llu to have a center of %f %f %f", modelID, newCenter.x, newCenter.y, newCenter.z);
|
|
sd0.FromData(reinterpret_cast<const uint8_t*>(newLxfml.data()), newLxfml.size());
|
|
auto asStream = sd0.GetAsStream();
|
|
Database::Get()->UpdateModel(model->id, newCenter, model->rotation, model->behaviors);
|
|
Database::Get()->UpdateUgcModelData(id, asStream, 0);
|
|
}
|
|
Database::Get()->SetAutoCommit(oldCommit);
|
|
}
|
|
|
|
void ModelNormalizeMigration::RunAfterFirstPart() {
|
|
const auto oldCommit = Database::Get()->GetAutoCommit();
|
|
Database::Get()->SetAutoCommit(false);
|
|
for (auto& [lxfmlData, id, modelID] : Database::Get()->GetAllUgcModels()) {
|
|
const auto model = Database::Get()->GetModel(modelID);
|
|
// only BBB models (lot 14) need to have their position fixed from the above blunder
|
|
if (!model || model->lot != 14) continue;
|
|
|
|
Sd0 sd0(lxfmlData);
|
|
const auto asStr = sd0.GetAsStringUncompressed();
|
|
const auto [newLxfml, newCenter] = Lxfml::NormalizePositionAfterFirstPart(asStr, model->position);
|
|
|
|
sd0.FromData(reinterpret_cast<const uint8_t*>(newLxfml.data()), newLxfml.size());
|
|
auto asStream = sd0.GetAsStream();
|
|
Database::Get()->UpdateModel(model->id, newCenter, model->rotation, model->behaviors);
|
|
Database::Get()->UpdateUgcModelData(id, asStream, 0);
|
|
}
|
|
Database::Get()->SetAutoCommit(oldCommit);
|
|
}
|
|
|
|
void ModelNormalizeMigration::RunBrickBuildGrid() {
|
|
const auto oldCommit = Database::Get()->GetAutoCommit();
|
|
Database::Get()->SetAutoCommit(false);
|
|
for (auto& [lxfmlData, id, modelID] : Database::Get()->GetAllUgcModels()) {
|
|
const auto model = Database::Get()->GetModel(modelID);
|
|
// only BBB models (lot 14) need to have their position fixed from the above blunder
|
|
if (!model || model->lot != 14) continue;
|
|
|
|
Sd0 sd0(lxfmlData);
|
|
const auto asStr = sd0.GetAsStringUncompressed();
|
|
const auto [newLxfml, newCenter] = Lxfml::NormalizePosition(asStr, model->position);
|
|
|
|
sd0.FromData(reinterpret_cast<const uint8_t*>(newLxfml.data()), newLxfml.size());
|
|
LOG("Updated model %llu to have a center of %f %f %f", modelID, newCenter.x, newCenter.y, newCenter.z);
|
|
auto asStream = sd0.GetAsStream();
|
|
Database::Get()->UpdateModel(model->id, newCenter, model->rotation, model->behaviors);
|
|
Database::Get()->UpdateUgcModelData(id, asStream, 0);
|
|
}
|
|
Database::Get()->SetAutoCommit(oldCommit);
|
|
}
|