mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 05:27:19 +00:00
fix: ugc Save rocket and car modular assembly data to database (#1279)
* Ugc: Use persistent Id for rocekts and cars * Remove comment * Ugc: Save rocket and car IDs to the database * Correct names * Database: formatting
This commit is contained in:
parent
f59ca8b1da
commit
0ddd20e2b5
@ -5119,6 +5119,10 @@ void GameMessages::HandleModularBuildConvertModel(RakNet::BitStream* inStream, E
|
|||||||
|
|
||||||
item->Disassemble(TEMP_MODELS);
|
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);
|
item->SetCount(item->GetCount() - 1, false, false, true, eLootSourceType::QUICKBUILD);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5562,13 +5566,6 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity*
|
|||||||
InventoryComponent* inv = static_cast<InventoryComponent*>(character->GetComponent(eReplicaComponentType::INVENTORY));
|
InventoryComponent* inv = static_cast<InventoryComponent*>(character->GetComponent(eReplicaComponentType::INVENTORY));
|
||||||
if (!inv) return;
|
if (!inv) return;
|
||||||
|
|
||||||
LOG("Build finished");
|
|
||||||
|
|
||||||
GameMessages::SendFinishArrangingWithItem(character, entity->GetObjectID()); // kick them from modular build
|
|
||||||
GameMessages::SendModularBuildEnd(character); // i dont know if this does anything but DLUv2 did it
|
|
||||||
|
|
||||||
//inv->UnequipItem(inv->GetItemStackByLOT(6086, eInventoryType::ITEMS)); // take off the thinking cap
|
|
||||||
//Game::entityManager->SerializeEntity(entity);
|
|
||||||
|
|
||||||
uint8_t count; // 3 for rockets, 7 for cars
|
uint8_t count; // 3 for rockets, 7 for cars
|
||||||
|
|
||||||
@ -5603,18 +5600,21 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity*
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ObjectIDManager::Instance()->RequestPersistentID([=](uint32_t newId) {
|
||||||
|
LOG("Build finished");
|
||||||
|
GameMessages::SendFinishArrangingWithItem(character, entity->GetObjectID()); // kick them from modular build
|
||||||
|
GameMessages::SendModularBuildEnd(character); // i dont know if this does anything but DLUv2 did it
|
||||||
|
|
||||||
|
//inv->UnequipItem(inv->GetItemStackByLOT(6086, eInventoryType::ITEMS)); // take off the thinking cap
|
||||||
|
//Game::entityManager->SerializeEntity(entity);
|
||||||
|
|
||||||
const auto moduleAssembly = new LDFData<std::u16string>(u"assemblyPartLOTs", modules);
|
const auto moduleAssembly = new LDFData<std::u16string>(u"assemblyPartLOTs", modules);
|
||||||
|
|
||||||
std::vector<LDFBaseData*> config;
|
std::vector<LDFBaseData*> config;
|
||||||
config.push_back(moduleAssembly);
|
config.push_back(moduleAssembly);
|
||||||
|
|
||||||
LWOOBJID newIdBig;
|
LWOOBJID newIdBig = newId;
|
||||||
// Make sure a subkey isnt already in use. Persistent Ids do not make sense here since this only needs to be unique for
|
|
||||||
// this character. Because of that, we just generate a random id and check for a collision.
|
|
||||||
do {
|
|
||||||
newIdBig = ObjectIDManager::Instance()->GenerateRandomObjectID();
|
|
||||||
GeneralUtils::SetBit(newIdBig, eObjectBits::CHARACTER);
|
GeneralUtils::SetBit(newIdBig, eObjectBits::CHARACTER);
|
||||||
} while (inv->FindItemBySubKey(newIdBig));
|
|
||||||
|
|
||||||
if (count == 3) {
|
if (count == 3) {
|
||||||
inv->AddItem(6416, 1, eLootSourceType::QUICKBUILD, eInventoryType::MODELS, config, LWOOBJID_EMPTY, true, false, newIdBig);
|
inv->AddItem(6416, 1, eLootSourceType::QUICKBUILD, eInventoryType::MODELS, config, LWOOBJID_EMPTY, true, false, newIdBig);
|
||||||
@ -5622,6 +5622,13 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity*
|
|||||||
inv->AddItem(8092, 1, eLootSourceType::QUICKBUILD, eInventoryType::MODELS, config, LWOOBJID_EMPTY, true, false, newIdBig);
|
inv->AddItem(8092, 1, eLootSourceType::QUICKBUILD, eInventoryType::MODELS, config, LWOOBJID_EMPTY, true, false, newIdBig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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>();
|
auto* missionComponent = character->GetComponent<MissionComponent>();
|
||||||
|
|
||||||
if (entity->GetLOT() != 9980 || Game::server->GetZoneID() != 1200) {
|
if (entity->GetLOT() != 9980 || Game::server->GetZoneID() != 1200) {
|
||||||
@ -5630,7 +5637,6 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity*
|
|||||||
if (count >= 7 && everyPieceSwapped) missionComponent->Progress(eMissionTaskType::RACING, LWOOBJID_EMPTY, (LWOOBJID)eRacingTaskParam::MODULAR_BUILDING);
|
if (count >= 7 && everyPieceSwapped) missionComponent->Progress(eMissionTaskType::RACING, LWOOBJID_EMPTY, (LWOOBJID)eRacingTaskParam::MODULAR_BUILDING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ScriptComponent* script = static_cast<ScriptComponent*>(entity->GetComponent(eReplicaComponentType::SCRIPT));
|
ScriptComponent* script = static_cast<ScriptComponent*>(entity->GetComponent(eReplicaComponentType::SCRIPT));
|
||||||
|
|
||||||
@ -5648,6 +5654,8 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity*
|
|||||||
for (auto* item : items) {
|
for (auto* item : items) {
|
||||||
inv->MoveItemToInventory(item, eInventoryType::MODELS, item->GetCount(), false);
|
inv->MoveItemToInventory(item, eInventoryType::MODELS, item->GetCount(), false);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameMessages::HandleDoneArrangingWithItem(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
|
void GameMessages::HandleDoneArrangingWithItem(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
|
||||||
|
5
migrations/dlu/12_modular_build_ugc.sql
Normal file
5
migrations/dlu/12_modular_build_ugc.sql
Normal file
@ -0,0 +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
|
||||||
|
);
|
Loading…
Reference in New Issue
Block a user