Skip to content

Commit

Permalink
Database: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
EmosewaMC committed Nov 12, 2023
1 parent 8d41cd2 commit 383d05b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion dGame/dGameMessages/GameMessages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5119,6 +5119,10 @@ void GameMessages::HandleModularBuildConvertModel(RakNet::BitStream* inStream, E

item->Disassemble(TEMP_MODELS);

std::unique_ptr<sql::PreparedStatement> 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);
}

Expand Down Expand Up @@ -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<sql::PreparedStatement> 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<MissionComponent>();
Expand Down
1 change: 1 addition & 0 deletions migrations/dlu/12_modular_build_ugc.sql
Original file line number Diff line number Diff line change
@@ -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
);

0 comments on commit 383d05b

Please sign in to comment.