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 f871261b16
commit b579344482
12 changed files with 77 additions and 13 deletions

View File

@@ -2530,6 +2530,12 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream& inStream, Entity* ent
outFile.close();
}
// Keep the save as the client sent it before splitting it; every model made from it points back to it
const auto accountId = entity->GetCharacter()->GetParentUser()->GetAccountID();
const LWOOBJID unsplitId = ObjectIDManager::GetPersistentID();
std::stringstream unsplitData(str);
Database::Get()->InsertUnsplitUgcModel(unsplitData, unsplitId, accountId, entity->GetCharacter()->GetID());
auto splitLxfmls = Lxfml::Split(asStr);
LOG_DEBUG("Split into %zu models", splitLxfmls.size());
@@ -2567,7 +2573,7 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream& inStream, Entity* ent
// Save each model to the database
sd0.FromData(reinterpret_cast<const uint8_t*>(splitLxfmls[i].lxfml.data()), splitLxfmls[i].lxfml.size());
auto sd0AsStream = sd0.GetAsStream();
Database::Get()->InsertNewUgcModel(sd0AsStream, blueprintID, entity->GetCharacter()->GetParentUser()->GetAccountID(), entity->GetCharacter()->GetID());
Database::Get()->InsertNewUgcModel(sd0AsStream, blueprintID, accountId, entity->GetCharacter()->GetID(), unsplitId);
// Insert the new property model
IPropertyContents::Model model;