feat: keep every brick by brick save before it is split into models

The save is stored as the client sent it in the new ugc_unsplit table, and each model split from it points back to it (ugc.unsplit_id), so the whole build can be looked at or restored later. A save is kept while any model split from it exists: deleting models removes saves no model points to any more, and deleting a character removes its saves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-10-16 20:46:33 -05:00
parent d870207a9f
commit 4bbf22f912
12 changed files with 78 additions and 13 deletions

View File

@@ -64,6 +64,8 @@ std::vector<IUgc::Model> MySQLDatabase::GetAllUgcModels() {
void MySQLDatabase::RemoveUnreferencedUgcModels() {
ExecuteDelete("DELETE FROM ugc WHERE id NOT IN (SELECT ugc_id FROM properties_contents WHERE ugc_id IS NOT NULL);");
// An unsplit save is kept while any model split from it is
ExecuteDelete("DELETE FROM ugc_unsplit WHERE id NOT IN (SELECT unsplit_id FROM ugc WHERE unsplit_id IS NOT NULL);");
}
void MySQLDatabase::InsertNewUgcModel(
@@ -71,10 +73,11 @@ void MySQLDatabase::InsertNewUgcModel(
const uint64_t blueprintId,
const uint32_t accountId,
const LWOOBJID characterId,
const int64_t processAfter) {
const int64_t processAfter,
const std::optional<LWOOBJID> unsplitId) {
const std::istream stream(sd0Data.rdbuf());
ExecuteInsert(
"INSERT INTO `ugc`(`id`, `account_id`, `character_id`, `is_optimized`, `lxfml`, `bake_ao`, `filename`, `process_after`, `queued`) VALUES (?,?,?,?,?,?,?,?,1)",
"INSERT INTO `ugc`(`id`, `account_id`, `character_id`, `is_optimized`, `lxfml`, `bake_ao`, `filename`, `process_after`, `queued`, `unsplit_id`) VALUES (?,?,?,?,?,?,?,?,1,?)",
blueprintId,
accountId,
characterId,
@@ -82,15 +85,22 @@ void MySQLDatabase::InsertNewUgcModel(
&stream,
false,
"weedeater.lxfml",
processAfter
processAfter,
unsplitId
);
// The owner is still building: their other models waiting for their quiet period wait longer
if (processAfter > 0) ExecuteUpdate("UPDATE ugc SET process_after = ? WHERE character_id = ? AND is_optimized = 0 AND process_after > 0 AND process_after < ?;", processAfter, characterId, processAfter);
}
void MySQLDatabase::InsertUnsplitUgcModel(std::stringstream& sd0Data, const LWOOBJID id, const uint32_t accountId, const LWOOBJID characterId) {
const std::istream stream(sd0Data.rdbuf());
ExecuteInsert("INSERT INTO `ugc_unsplit`(`id`, `account_id`, `character_id`, `lxfml`) VALUES (?,?,?,?)", id, accountId, characterId, &stream);
}
void MySQLDatabase::DeleteUgcModelData(const LWOOBJID& modelId) {
ExecuteDelete("DELETE FROM ugc WHERE id = ?;", modelId);
ExecuteDelete("DELETE FROM properties_contents WHERE ugc_id = ?;", modelId);
ExecuteDelete("DELETE FROM ugc_unsplit WHERE id NOT IN (SELECT unsplit_id FROM ugc WHERE unsplit_id IS NOT NULL);");
}
void MySQLDatabase::UpdateUgcModelData(const LWOOBJID& modelId, std::stringstream& lxfml, const int64_t processAfter) {