mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-06-16 19:54:23 +00:00
chore: cleanup pointer management for LDF data (#1995)
* change network settings from vector to LwoNameValue * move settings on Entity to managed memory * Migrate more members * chore: remove pointer leakage from raw ldf pointers * feedback * fix ci
This commit is contained in:
@@ -802,7 +802,7 @@ namespace DEVGMCommands {
|
||||
info.spawner = nullptr;
|
||||
info.spawnerID = entity->GetObjectID();
|
||||
info.spawnerNodeID = 0;
|
||||
info.settings = { new LDFData<bool>(u"SpawnedFromSlashCommand", true) };
|
||||
info.settings.Insert<bool>(u"SpawnedFromSlashCommand", true);
|
||||
|
||||
Entity* newEntity = Game::entityManager->CreateEntity(info, nullptr);
|
||||
|
||||
@@ -844,7 +844,7 @@ namespace DEVGMCommands {
|
||||
info.spawner = nullptr;
|
||||
info.spawnerID = entity->GetObjectID();
|
||||
info.spawnerNodeID = 0;
|
||||
info.settings = { new LDFData<bool>(u"SpawnedFromSlashCommand", true) };
|
||||
info.settings.Insert(u"SpawnedFromSlashCommand", true);
|
||||
|
||||
auto playerPosition = entity->GetPosition();
|
||||
while (numberToSpawn > 0) {
|
||||
@@ -1268,10 +1268,10 @@ namespace DEVGMCommands {
|
||||
auto* inventoryComponent = entity->GetComponent<InventoryComponent>();
|
||||
if (!inventoryComponent) return;
|
||||
|
||||
std::vector<LDFBaseData*> data{};
|
||||
data.push_back(new LDFData<int32_t>(u"reforgedLOT", reforgedItem.value()));
|
||||
LwoNameValue config;
|
||||
config.Insert<LOT>(u"reforgedLOT", reforgedItem.value());
|
||||
|
||||
inventoryComponent->AddItem(baseItem.value(), 1, eLootSourceType::MODERATION, eInventoryType::INVALID, data);
|
||||
inventoryComponent->AddItem(baseItem.value(), 1, eLootSourceType::MODERATION, eInventoryType::INVALID, config);
|
||||
}
|
||||
|
||||
void Crash(Entity* entity, const SystemAddress& sysAddr, const std::string args) {
|
||||
|
||||
@@ -45,10 +45,8 @@ void VanityUtilities::SpawnVanity() {
|
||||
info.pos = { 259.5f, 246.4f, -705.2f };
|
||||
info.rot = { 0.0f, 0.0f, 1.0f, 0.0f };
|
||||
info.spawnerID = Game::entityManager->GetZoneControlEntity()->GetObjectID();
|
||||
info.settings = {
|
||||
new LDFData<bool>(u"hasCustomText", true),
|
||||
new LDFData<std::string>(u"customText", ParseMarkdown((BinaryPathFinder::GetBinaryDir() / "vanity/TESTAMENT.md").string()))
|
||||
};
|
||||
info.settings.Insert<bool>(u"hasCustomText", true);
|
||||
info.settings.Insert<std::string>(u"customText", ParseMarkdown((BinaryPathFinder::GetBinaryDir() / "vanity/TESTAMENT.md").string()));
|
||||
|
||||
auto* entity = Game::entityManager->CreateEntity(info);
|
||||
Game::entityManager->ConstructEntity(entity);
|
||||
@@ -231,7 +229,7 @@ void ParseXml(const std::string& file) {
|
||||
|
||||
auto* configElement = object->FirstChildElement("config");
|
||||
std::vector<std::u16string> keys = {};
|
||||
std::vector<LDFBaseData*> config = {};
|
||||
LwoNameValue config;
|
||||
if (configElement) {
|
||||
for (auto* key = configElement->FirstChildElement("key"); key != nullptr;
|
||||
key = key->NextSiblingElement("key")) {
|
||||
@@ -239,16 +237,16 @@ void ParseXml(const std::string& file) {
|
||||
auto* data = key->GetText();
|
||||
if (!data) continue;
|
||||
|
||||
LDFBaseData* configData = LDFBaseData::DataFromString(data);
|
||||
const auto& configData = config.ParseInsert(data);
|
||||
if (configData->GetKey() == u"useLocationsAsRandomSpawnPoint" && configData->GetValueType() == eLDFType::LDF_TYPE_BOOLEAN) {
|
||||
useLocationsAsRandomSpawnPoint = static_cast<bool>(configData);
|
||||
useLocationsAsRandomSpawnPoint = static_cast<const LDFData<bool>*>(configData.get())->GetValue();
|
||||
config.Erase(u"useLocationsAsRandomSpawnPoint");
|
||||
continue;
|
||||
}
|
||||
keys.push_back(configData->GetKey());
|
||||
config.push_back(configData);
|
||||
}
|
||||
}
|
||||
if (!keys.empty()) config.push_back(new LDFData<std::vector<std::u16string>>(u"syncLDF", keys));
|
||||
if (!keys.empty()) config.Insert<std::vector<std::u16string>>(u"syncLDF", keys);
|
||||
|
||||
VanityObject objectData{
|
||||
.m_Name = name,
|
||||
|
||||
@@ -19,7 +19,7 @@ struct VanityObject {
|
||||
std::vector<LOT> m_Equipment;
|
||||
std::vector<std::string> m_Phrases;
|
||||
std::map<uint32_t, std::vector<VanityObjectLocation>> m_Locations;
|
||||
std::vector<LDFBaseData*> m_Config;
|
||||
LwoNameValue m_Config;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user