mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-06-17 04:04:21 +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:
@@ -97,17 +97,14 @@ void AmDarklingDragon::OnHitOrHealResult(Entity* self, Entity* attacker, int32_t
|
||||
info.pos = objectPosition;
|
||||
info.rot = rotation;
|
||||
info.spawnerID = self->GetObjectID();
|
||||
info.settings = {
|
||||
new LDFData<std::string>(u"rebuild_activators",
|
||||
info.settings.Insert<std::string>(u"rebuild_activators",
|
||||
std::to_string(objectPosition.x + forward.x) + "\x1f" +
|
||||
std::to_string(objectPosition.y) + "\x1f" +
|
||||
std::to_string(objectPosition.z + forward.z)
|
||||
),
|
||||
new LDFData<int32_t>(u"respawn", 100000),
|
||||
new LDFData<float>(u"rebuild_reset_time", 15),
|
||||
new LDFData<bool>(u"no_timed_spawn", true),
|
||||
new LDFData<LWOOBJID>(u"Dragon", self->GetObjectID())
|
||||
};
|
||||
std::to_string(objectPosition.z + forward.z));
|
||||
info.settings.Insert<int32_t>(u"respawn", 100000);
|
||||
info.settings.Insert<float>(u"rebuild_reset_time", 15);
|
||||
info.settings.Insert<bool>(u"no_timed_spawn", true);
|
||||
info.settings.Insert<LWOOBJID>(u"Dragon", self->GetObjectID());
|
||||
|
||||
auto* golemObject = Game::entityManager->CreateEntity(info);
|
||||
|
||||
|
||||
@@ -113,17 +113,14 @@ void FvMaelstromDragon::OnHitOrHealResult(Entity* self, Entity* attacker, int32_
|
||||
info.pos = objectPosition;
|
||||
info.rot = rotation;
|
||||
info.spawnerID = self->GetObjectID();
|
||||
info.settings = {
|
||||
new LDFData<std::string>(u"rebuild_activators",
|
||||
info.settings.Insert<std::string>(u"rebuild_activators",
|
||||
std::to_string(objectPosition.x + forward.x) + "\x1f" +
|
||||
std::to_string(objectPosition.y) + "\x1f" +
|
||||
std::to_string(objectPosition.z + forward.z)
|
||||
),
|
||||
new LDFData<int32_t>(u"respawn", 100000),
|
||||
new LDFData<float>(u"rebuild_reset_time", 15),
|
||||
new LDFData<bool>(u"no_timed_spawn", true),
|
||||
new LDFData<LWOOBJID>(u"Dragon", self->GetObjectID())
|
||||
};
|
||||
std::to_string(objectPosition.z + forward.z));
|
||||
info.settings.Insert<int32_t>(u"respawn", 100000);
|
||||
info.settings.Insert<float>(u"rebuild_reset_time", 15);
|
||||
info.settings.Insert<bool>(u"no_timed_spawn", true);
|
||||
info.settings.Insert<LWOOBJID>(u"Dragon", self->GetObjectID());
|
||||
|
||||
auto* golemObject = Game::entityManager->CreateEntity(info);
|
||||
|
||||
|
||||
@@ -82,15 +82,12 @@ void BaseEnemyApe::OnTimerDone(Entity* self, std::string timerName) {
|
||||
entityInfo.spawnerID = self->GetObjectID();
|
||||
entityInfo.lot = self->GetVar<LOT>(u"QuickbuildAnchorLOT") != 0
|
||||
? self->GetVar<LOT>(u"QuickbuildAnchorLOT") : 7549;
|
||||
entityInfo.settings = {
|
||||
new LDFData<std::string>(u"rebuild_activators",
|
||||
entityInfo.settings.Insert<std::string>(u"rebuild_activators",
|
||||
std::to_string(objectPosition.GetX()) + "\x1f" +
|
||||
std::to_string(objectPosition.GetY()) + "\x1f" +
|
||||
std::to_string(objectPosition.GetZ())
|
||||
),
|
||||
new LDFData<bool>(u"no_timed_spawn", true),
|
||||
new LDFData<LWOOBJID>(u"ape", self->GetObjectID())
|
||||
};
|
||||
std::to_string(objectPosition.GetZ()));
|
||||
entityInfo.settings.Insert<bool>(u"no_timed_spawn", true);
|
||||
entityInfo.settings.Insert<LWOOBJID>(u"ape", self->GetObjectID());
|
||||
|
||||
auto* anchor = Game::entityManager->CreateEntity(entityInfo, nullptr, self);
|
||||
Game::entityManager->ConstructEntity(anchor);
|
||||
|
||||
@@ -23,7 +23,7 @@ void BaseEnemyMech::OnDie(Entity* self, Entity* killer) {
|
||||
NiPoint3 newLoc = { controlPhys->GetPosition().x, dpWorld::GetNavMesh()->GetHeightAtPoint(controlPhys->GetPosition()), controlPhys->GetPosition().z };
|
||||
|
||||
EntityInfo info = EntityInfo();
|
||||
std::vector<LDFBaseData*> cfg;
|
||||
LwoNameValue cfg;
|
||||
std::u16string activatorPosStr;
|
||||
activatorPosStr += (GeneralUtils::to_u16string(controlPhys->GetPosition().x));
|
||||
activatorPosStr.push_back(0x1f);
|
||||
@@ -31,8 +31,7 @@ void BaseEnemyMech::OnDie(Entity* self, Entity* killer) {
|
||||
activatorPosStr.push_back(0x1f);
|
||||
activatorPosStr += (GeneralUtils::to_u16string(controlPhys->GetPosition().z));
|
||||
|
||||
LDFBaseData* activatorPos = new LDFData<std::u16string>(u"rebuild_activators", activatorPosStr);
|
||||
cfg.push_back(activatorPos);
|
||||
cfg.Insert<std::u16string>(u"rebuild_activators", activatorPosStr);
|
||||
info.lot = qbTurretLOT;
|
||||
info.pos = newLoc;
|
||||
info.rot = controlPhys->GetRotation();
|
||||
|
||||
@@ -71,9 +71,7 @@ void ZoneAgSpiderQueen::OnTimerDone(Entity* self, std::string timerName) {
|
||||
info.pos = spawnTarget->GetPosition();
|
||||
info.rot = spawnTarget->GetRotation();
|
||||
info.lot = chestObject;
|
||||
info.settings = {
|
||||
new LDFData<LWOOBJID>(u"parent_tag", self->GetObjectID())
|
||||
};
|
||||
info.settings.Insert(u"parent_tag", self->GetObjectID());
|
||||
|
||||
auto* chest = Game::entityManager->CreateEntity(info);
|
||||
Game::entityManager->ConstructEntity(chest);
|
||||
|
||||
@@ -37,12 +37,10 @@ void AmSkullkinTower::SpawnLegs(Entity* self, const std::string& loc) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<LDFBaseData*> config = { new LDFData<std::string>(u"Leg", loc) };
|
||||
|
||||
EntityInfo info{};
|
||||
info.lot = legLOT;
|
||||
info.spawnerID = self->GetObjectID();
|
||||
info.settings = config;
|
||||
info.settings.Insert("Leg", loc);
|
||||
info.rot = newRot;
|
||||
|
||||
if (loc == "Right") {
|
||||
|
||||
@@ -204,12 +204,10 @@ void PetDigServer::SpawnPet(Entity* self, const Entity* owner, const DigInfo dig
|
||||
info.pos = self->GetPosition();
|
||||
info.rot = self->GetRotation();
|
||||
info.spawnerID = self->GetSpawnerID();
|
||||
info.settings = {
|
||||
new LDFData<LWOOBJID>(u"tamer", owner->GetObjectID()),
|
||||
new LDFData<std::string>(u"group", "pet" + std::to_string(owner->GetObjectID())),
|
||||
new LDFData<std::string>(u"spawnAnim", "spawn-pet"),
|
||||
new LDFData<float>(u"spawnTimer", 1.0)
|
||||
};
|
||||
info.settings.Insert<LWOOBJID>(u"tamer", owner->GetObjectID());
|
||||
info.settings.Insert<std::string>(u"group", "pet" + std::to_string(owner->GetObjectID()));
|
||||
info.settings.Insert<std::string>(u"spawnAnim", "spawn-pet");
|
||||
info.settings.Insert<float>(u"spawnTimer", 1.0);
|
||||
|
||||
auto* spawnedPet = Game::entityManager->CreateEntity(info);
|
||||
Game::entityManager->ConstructEntity(spawnedPet);
|
||||
|
||||
@@ -66,14 +66,12 @@ void QbSpawner::OnTimerDone(Entity* self, std::string timerName) {
|
||||
info.rot = newRot;
|
||||
info.spawnerID = self->GetObjectID();
|
||||
info.spawnerNodeID = 0;
|
||||
info.settings = {
|
||||
new LDFData<bool>(u"no_timed_spawn", true),
|
||||
new LDFData<float>(u"aggroRadius", 70),
|
||||
new LDFData<float>(u"softtetherRadius", 80),
|
||||
new LDFData<float>(u"tetherRadius", 90),
|
||||
new LDFData<float>(u"wanderRadius", 5),
|
||||
new LDFData<int>(u"mobTableLoc", i)
|
||||
};
|
||||
info.settings.Insert<bool>(u"no_timed_spawn", true);
|
||||
info.settings.Insert<float>(u"aggroRadius", 70);
|
||||
info.settings.Insert<float>(u"softtetherRadius", 80);
|
||||
info.settings.Insert<float>(u"tetherRadius", 90);
|
||||
info.settings.Insert<float>(u"wanderRadius", 5);
|
||||
info.settings.Insert<int>(u"mobTableLoc", i);
|
||||
|
||||
auto* child = Game::entityManager->CreateEntity(info, nullptr, self);
|
||||
Game::entityManager->ConstructEntity(child);
|
||||
|
||||
@@ -34,12 +34,10 @@ void NsConcertChoiceBuildManager::SpawnCrate(Entity* self) {
|
||||
info.pos = self->GetPosition();
|
||||
info.rot = self->GetRotation();
|
||||
info.spawnerID = self->GetObjectID();
|
||||
info.settings = {
|
||||
new LDFData<bool>(u"startsQBActivator", true),
|
||||
new LDFData<std::string>(u"grpNameQBShowBricks", crate.group + std::to_string(groupNumber)),
|
||||
new LDFData<std::u16string>(u"groupID", GeneralUtils::ASCIIToUTF16("Crate_" + group)),
|
||||
new LDFData<float>(u"crateTime", crate.time),
|
||||
};
|
||||
info.settings.Insert<bool>(u"startsQBActivator", true);
|
||||
info.settings.Insert<std::string>(u"grpNameQBShowBricks", crate.group + std::to_string(groupNumber));
|
||||
info.settings.Insert<std::u16string>(u"groupID", GeneralUtils::ASCIIToUTF16("Crate_" + group));
|
||||
info.settings.Insert<float>(u"crateTime", crate.time);
|
||||
|
||||
auto* spawnedCrate = Game::entityManager->CreateEntity(info);
|
||||
Game::entityManager->ConstructEntity(spawnedCrate);
|
||||
|
||||
@@ -89,7 +89,7 @@ void NtCombatChallengeServer::SpawnTargetDummy(Entity* self) {
|
||||
info.spawnerID = self->GetObjectID();
|
||||
info.pos = self->GetPosition();
|
||||
info.rot = self->GetRotation();
|
||||
info.settings = { new LDFData<std::string>(u"custom_script_server", "scripts\\02_server\\Map\\NT\\L_NT_COMBAT_CHALLENGE_DUMMY.lua") };
|
||||
info.settings.Insert(u"custom_script_server", "scripts\\02_server\\Map\\NT\\L_NT_COMBAT_CHALLENGE_DUMMY.lua");
|
||||
|
||||
auto* dummy = Game::entityManager->CreateEntity(info, nullptr, self);
|
||||
|
||||
|
||||
@@ -95,10 +95,8 @@ void ZoneAgProperty::LoadInstance(Entity* self) {
|
||||
|
||||
for (auto* spawner : Game::zoneManager->GetSpawnersByName(self->GetVar<std::string>(InstancerSpawner))) {
|
||||
for (auto* spawnerNode : spawner->m_Info.nodes) {
|
||||
spawnerNode->config.push_back(
|
||||
new LDFData<std::string>(u"custom_script_server",
|
||||
R"(scripts\ai\GENERAL\L_INSTANCE_EXIT_TRANSFER_PLAYER_TO_LAST_NON_INSTANCE.lua)"));
|
||||
spawnerNode->config.push_back(new LDFData<std::u16string>(u"transferText", u"SPIDER_QUEEN_EXIT_QUESTION"));
|
||||
spawnerNode->config.Insert<std::string>(u"custom_script_server", R"(scripts\ai\GENERAL\L_INSTANCE_EXIT_TRANSFER_PLAYER_TO_LAST_NON_INSTANCE.lua)");
|
||||
spawnerNode->config.Insert<std::u16string>(u"transferText", u"SPIDER_QUEEN_EXIT_QUESTION");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -515,9 +515,7 @@ void NjMonastryBossInstance::FightOver(Entity* self) {
|
||||
info.pos = treasureChest->GetPosition();
|
||||
info.rot = treasureChest->GetRotation();
|
||||
info.spawnerID = self->GetObjectID();
|
||||
info.settings = {
|
||||
new LDFData<LWOOBJID>(u"parent_tag", self->GetObjectID())
|
||||
};
|
||||
info.settings.Insert<LWOOBJID>(u"parent_tag", self->GetObjectID());
|
||||
|
||||
// Finally spawn a treasure chest at the correct spawn point
|
||||
auto* chestObject = Game::entityManager->CreateEntity(info);
|
||||
|
||||
@@ -21,9 +21,7 @@ void StinkyFishTarget::OnSkillEventFired(Entity* self, Entity* caster, const std
|
||||
entityInfo.pos = self->GetPosition();
|
||||
entityInfo.rot = self->GetRotation();
|
||||
entityInfo.spawnerID = self->GetObjectID();
|
||||
entityInfo.settings = {
|
||||
new LDFData<bool>(u"no_timed_spawn", true)
|
||||
};
|
||||
entityInfo.settings.Insert(u"no_timed_spawn", true);
|
||||
|
||||
auto* fish = Game::entityManager->CreateEntity(entityInfo);
|
||||
Game::entityManager->ConstructEntity(fish);
|
||||
|
||||
Reference in New Issue
Block a user