From 383d05b4b98421ae3087d3ba7839ee07f80b33e4 Mon Sep 17 00:00:00 2001 From: David Markowitz Date: Sun, 12 Nov 2023 15:12:35 -0800 Subject: [PATCH] Database: formatting --- dGame/dGameMessages/GameMessages.cpp | 8 +++++++- migrations/dlu/12_modular_build_ugc.sql | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index 00d2e4e80..0bbd9a11f 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -5119,6 +5119,10 @@ void GameMessages::HandleModularBuildConvertModel(RakNet::BitStream* inStream, E item->Disassemble(TEMP_MODELS); + std::unique_ptr stmt(Database::CreatePreppedStmt("DELETE FROM ugc_modular_build where ugc_id = ?")); + stmt->setUInt64(1, item->GetSubKey()); + stmt->execute(); + item->SetCount(item->GetCount() - 1, false, false, true, eLootSourceType::QUICKBUILD); } @@ -5620,9 +5624,11 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity* inv->AddItem(8092, 1, eLootSourceType::QUICKBUILD, eInventoryType::MODELS, config, LWOOBJID_EMPTY, true, false, newIdBig); } - auto stmt = Database::CreatePreppedStmt("INSERT INTO ugc_modular_build (ugc_id, ldf_config) VALUES (?,?)"); + std::unique_ptr stmt(Database::CreatePreppedStmt("INSERT INTO ugc_modular_build (ugc_id, ldf_config, character_id) VALUES (?,?,?)")); stmt->setUInt64(1, newIdBig); stmt->setString(2, GeneralUtils::UTF16ToWTF8(modules)); + auto* pCharacter = character->GetCharacter(); + pCharacter ? stmt->setUInt(3, pCharacter->GetID()) : stmt->setNull(3, sql::DataType::BIGINT); stmt->execute(); auto* missionComponent = character->GetComponent(); diff --git a/migrations/dlu/12_modular_build_ugc.sql b/migrations/dlu/12_modular_build_ugc.sql index 98ec4d7b7..68e417bf4 100644 --- a/migrations/dlu/12_modular_build_ugc.sql +++ b/migrations/dlu/12_modular_build_ugc.sql @@ -1,4 +1,5 @@ CREATE TABLE IF NOT EXISTS ugc_modular_build ( ugc_id BIGINT NOT NULL PRIMARY KEY, + character_id BIGINT NOT NULL REFERENCES charinfo(id) ON DELETE CASCADE, ldf_config VARCHAR(60) NOT NULL );