mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-07 03:04:05 +00:00
format codebase
This commit is contained in:
@@ -23,8 +23,7 @@
|
||||
|
||||
PropertyManagementComponent* PropertyManagementComponent::instance = nullptr;
|
||||
|
||||
PropertyManagementComponent::PropertyManagementComponent(Entity* parent) : Component(parent)
|
||||
{
|
||||
PropertyManagementComponent::PropertyManagementComponent(Entity* parent) : Component(parent) {
|
||||
this->owner = LWOOBJID_EMPTY;
|
||||
this->templateId = 0;
|
||||
this->propertyId = LWOOBJID_EMPTY;
|
||||
@@ -43,12 +42,11 @@ PropertyManagementComponent::PropertyManagementComponent(Entity* parent) : Compo
|
||||
|
||||
auto query = CDClientDatabase::CreatePreppedStmt(
|
||||
"SELECT id FROM PropertyTemplate WHERE mapID = ?;");
|
||||
query.bind(1, (int) zoneId);
|
||||
query.bind(1, (int)zoneId);
|
||||
|
||||
auto result = query.execQuery();
|
||||
|
||||
if (result.eof() || result.fieldIsNull(0))
|
||||
{
|
||||
if (result.eof() || result.fieldIsNull(0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -63,8 +61,7 @@ PropertyManagementComponent::PropertyManagementComponent(Entity* parent) : Compo
|
||||
|
||||
auto* propertyEntry = propertyLookup->executeQuery();
|
||||
|
||||
if (propertyEntry->next())
|
||||
{
|
||||
if (propertyEntry->next()) {
|
||||
this->propertyId = propertyEntry->getUInt64(1);
|
||||
this->owner = propertyEntry->getUInt64(2);
|
||||
this->owner = GeneralUtils::SetBit(this->owner, OBJECT_BIT_CHARACTER);
|
||||
@@ -85,35 +82,30 @@ PropertyManagementComponent::PropertyManagementComponent(Entity* parent) : Compo
|
||||
delete propertyLookup;
|
||||
}
|
||||
|
||||
LWOOBJID PropertyManagementComponent::GetOwnerId() const
|
||||
{
|
||||
LWOOBJID PropertyManagementComponent::GetOwnerId() const {
|
||||
return owner;
|
||||
}
|
||||
|
||||
Entity* PropertyManagementComponent::GetOwner() const
|
||||
{
|
||||
Entity* PropertyManagementComponent::GetOwner() const {
|
||||
return EntityManager::Instance()->GetEntity(owner);
|
||||
}
|
||||
|
||||
void PropertyManagementComponent::SetOwner(Entity* value)
|
||||
{
|
||||
void PropertyManagementComponent::SetOwner(Entity* value) {
|
||||
owner = value->GetObjectID();
|
||||
}
|
||||
|
||||
std::vector<NiPoint3> PropertyManagementComponent::GetPaths() const
|
||||
{
|
||||
std::vector<NiPoint3> PropertyManagementComponent::GetPaths() const {
|
||||
const auto zoneId = dZoneManager::Instance()->GetZone()->GetWorldID();
|
||||
|
||||
auto query = CDClientDatabase::CreatePreppedStmt(
|
||||
"SELECT path FROM PropertyTemplate WHERE mapID = ?;");
|
||||
query.bind(1, (int) zoneId);
|
||||
query.bind(1, (int)zoneId);
|
||||
|
||||
auto result = query.execQuery();
|
||||
|
||||
std::vector<NiPoint3> paths {};
|
||||
std::vector<NiPoint3> paths{};
|
||||
|
||||
if (result.eof())
|
||||
{
|
||||
if (result.eof()) {
|
||||
return paths;
|
||||
}
|
||||
|
||||
@@ -122,35 +114,28 @@ std::vector<NiPoint3> PropertyManagementComponent::GetPaths() const
|
||||
std::istringstream stream(result.getStringField(0));
|
||||
std::string token;
|
||||
|
||||
while (std::getline(stream, token, ' '))
|
||||
{
|
||||
try
|
||||
{
|
||||
while (std::getline(stream, token, ' ')) {
|
||||
try {
|
||||
auto value = std::stof(token);
|
||||
|
||||
points.push_back(value);
|
||||
}
|
||||
catch (std::invalid_argument& exception)
|
||||
{
|
||||
} catch (std::invalid_argument& exception) {
|
||||
Game::logger->Log("PropertyManagementComponent", "Failed to parse value (%s): (%s)!", token.c_str(), exception.what());
|
||||
}
|
||||
}
|
||||
|
||||
for (auto i = 0u; i < points.size(); i += 3)
|
||||
{
|
||||
for (auto i = 0u; i < points.size(); i += 3) {
|
||||
paths.emplace_back(points[i], points[i + 1], points[i + 2]);
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
PropertyPrivacyOption PropertyManagementComponent::GetPrivacyOption() const
|
||||
{
|
||||
PropertyPrivacyOption PropertyManagementComponent::GetPrivacyOption() const {
|
||||
return privacyOption;
|
||||
}
|
||||
|
||||
void PropertyManagementComponent::SetPrivacyOption(PropertyPrivacyOption value)
|
||||
{
|
||||
void PropertyManagementComponent::SetPrivacyOption(PropertyPrivacyOption value) {
|
||||
if (owner == LWOOBJID_EMPTY) return;
|
||||
|
||||
if (value == static_cast<PropertyPrivacyOption>(3)) // Client sends 3 for private for some reason, but expects 0 in return?
|
||||
@@ -174,8 +159,7 @@ void PropertyManagementComponent::SetPrivacyOption(PropertyPrivacyOption value)
|
||||
propertyUpdate->executeUpdate();
|
||||
}
|
||||
|
||||
void PropertyManagementComponent::UpdatePropertyDetails(std::string name, std::string description)
|
||||
{
|
||||
void PropertyManagementComponent::UpdatePropertyDetails(std::string name, std::string description) {
|
||||
if (owner == LWOOBJID_EMPTY) return;
|
||||
|
||||
propertyName = name;
|
||||
@@ -193,10 +177,8 @@ void PropertyManagementComponent::UpdatePropertyDetails(std::string name, std::s
|
||||
OnQueryPropertyData(GetOwner(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||
}
|
||||
|
||||
bool PropertyManagementComponent::Claim(const LWOOBJID playerId)
|
||||
{
|
||||
if (owner != LWOOBJID_EMPTY)
|
||||
{
|
||||
bool PropertyManagementComponent::Claim(const LWOOBJID playerId) {
|
||||
if (owner != LWOOBJID_EMPTY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -228,19 +210,16 @@ bool PropertyManagementComponent::Claim(const LWOOBJID playerId)
|
||||
"VALUES (?, ?, ?, ?, ?, '', 0, 0, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), '', 0, ?, 0.0)"
|
||||
);
|
||||
insertion->setUInt64(1, propertyId);
|
||||
insertion->setUInt64(2, (uint32_t) playerId);
|
||||
insertion->setUInt64(2, (uint32_t)playerId);
|
||||
insertion->setUInt(3, templateId);
|
||||
insertion->setUInt64(4, playerCloneId);
|
||||
insertion->setString(5, zone->GetZoneName().c_str());
|
||||
insertion->setInt(6, propertyZoneId);
|
||||
|
||||
// Try and execute the query, print an error if it fails.
|
||||
try
|
||||
{
|
||||
try {
|
||||
insertion->execute();
|
||||
}
|
||||
catch (sql::SQLException& exception)
|
||||
{
|
||||
} catch (sql::SQLException& exception) {
|
||||
Game::logger->Log("PropertyManagementComponent", "Failed to execute query: (%s)!", exception.what());
|
||||
|
||||
throw exception;
|
||||
@@ -248,14 +227,13 @@ bool PropertyManagementComponent::Claim(const LWOOBJID playerId)
|
||||
}
|
||||
|
||||
auto* zoneControlObject = dZoneManager::Instance()->GetZoneControlObject();
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControlObject)) {
|
||||
script->OnZonePropertyRented(zoneControlObject, entity);
|
||||
}
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControlObject)) {
|
||||
script->OnZonePropertyRented(zoneControlObject, entity);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void PropertyManagementComponent::OnStartBuilding()
|
||||
{
|
||||
void PropertyManagementComponent::OnStartBuilding() {
|
||||
auto* ownerEntity = GetOwner();
|
||||
|
||||
if (ownerEntity == nullptr) return;
|
||||
@@ -270,18 +248,15 @@ void PropertyManagementComponent::OnStartBuilding()
|
||||
|
||||
SetPrivacyOption(PropertyPrivacyOption::Private); // Cant visit player which is building
|
||||
|
||||
if (!entrance.empty())
|
||||
{
|
||||
if (!entrance.empty()) {
|
||||
auto* rocketPad = entrance[0]->GetComponent<RocketLaunchpadControlComponent>();
|
||||
|
||||
if (rocketPad != nullptr)
|
||||
{
|
||||
if (rocketPad != nullptr) {
|
||||
zoneId = rocketPad->GetDefaultZone();
|
||||
}
|
||||
}
|
||||
|
||||
for (auto* player : players)
|
||||
{
|
||||
for (auto* player : players) {
|
||||
if (player == ownerEntity) continue;
|
||||
|
||||
player->SendToZone(zoneId);
|
||||
@@ -292,8 +267,7 @@ void PropertyManagementComponent::OnStartBuilding()
|
||||
if (inventoryComponent) inventoryComponent->PushEquippedItems();
|
||||
}
|
||||
|
||||
void PropertyManagementComponent::OnFinishBuilding()
|
||||
{
|
||||
void PropertyManagementComponent::OnFinishBuilding() {
|
||||
auto* ownerEntity = GetOwner();
|
||||
|
||||
if (ownerEntity == nullptr) return;
|
||||
@@ -305,28 +279,24 @@ void PropertyManagementComponent::OnFinishBuilding()
|
||||
Save();
|
||||
}
|
||||
|
||||
void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const NiPoint3 position, NiQuaternion rotation)
|
||||
{
|
||||
void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const NiPoint3 position, NiQuaternion rotation) {
|
||||
Game::logger->Log("PropertyManagementComponent", "Placing model <%f, %f, %f>", position.x, position.y, position.z);
|
||||
|
||||
auto* entity = GetOwner();
|
||||
|
||||
if (entity == nullptr)
|
||||
{
|
||||
if (entity == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto* inventoryComponent = entity->GetComponent<InventoryComponent>();
|
||||
|
||||
if (inventoryComponent == nullptr)
|
||||
{
|
||||
if (inventoryComponent == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto* item = inventoryComponent->FindItemById(id);
|
||||
|
||||
if (item == nullptr)
|
||||
{
|
||||
if (item == nullptr) {
|
||||
Game::logger->Log("PropertyManagementComponent", "Failed to find item with id %d", id);
|
||||
|
||||
return;
|
||||
@@ -336,8 +306,7 @@ void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const N
|
||||
|
||||
const auto modelLOT = item->GetLot();
|
||||
|
||||
if (rotation != NiQuaternion::IDENTITY)
|
||||
{
|
||||
if (rotation != NiQuaternion::IDENTITY) {
|
||||
rotation = { rotation.w, rotation.z, rotation.y, rotation.x };
|
||||
}
|
||||
|
||||
@@ -377,78 +346,73 @@ void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const N
|
||||
node->position = position;
|
||||
node->rotation = rotation;
|
||||
|
||||
ObjectIDManager::Instance()->RequestPersistentID([this, node, modelLOT, entity, position, rotation, originalRotation](uint32_t persistentId)
|
||||
{
|
||||
SpawnerInfo info{};
|
||||
ObjectIDManager::Instance()->RequestPersistentID([this, node, modelLOT, entity, position, rotation, originalRotation](uint32_t persistentId) {
|
||||
SpawnerInfo info{};
|
||||
|
||||
info.templateID = modelLOT;
|
||||
info.nodes = { node };
|
||||
info.templateScale = 1.0f;
|
||||
info.activeOnLoad = true;
|
||||
info.amountMaintained = 1;
|
||||
info.respawnTime = 10;
|
||||
info.templateID = modelLOT;
|
||||
info.nodes = { node };
|
||||
info.templateScale = 1.0f;
|
||||
info.activeOnLoad = true;
|
||||
info.amountMaintained = 1;
|
||||
info.respawnTime = 10;
|
||||
|
||||
info.emulated = true;
|
||||
info.emulator = EntityManager::Instance()->GetZoneControlEntity()->GetObjectID();
|
||||
info.emulated = true;
|
||||
info.emulator = EntityManager::Instance()->GetZoneControlEntity()->GetObjectID();
|
||||
|
||||
LWOOBJID id = static_cast<LWOOBJID>(persistentId) | 1ull << OBJECT_BIT_CLIENT;
|
||||
LWOOBJID id = static_cast<LWOOBJID>(persistentId) | 1ull << OBJECT_BIT_CLIENT;
|
||||
|
||||
info.spawnerID = id;
|
||||
info.spawnerID = id;
|
||||
|
||||
const auto spawnerId = dZoneManager::Instance()->MakeSpawner(info);
|
||||
const auto spawnerId = dZoneManager::Instance()->MakeSpawner(info);
|
||||
|
||||
auto* spawner = dZoneManager::Instance()->GetSpawner(spawnerId);
|
||||
auto* spawner = dZoneManager::Instance()->GetSpawner(spawnerId);
|
||||
|
||||
auto ldfModelBehavior = new LDFData<LWOOBJID>(u"modelBehaviors", 0);
|
||||
auto userModelID = new LDFData<LWOOBJID>(u"userModelID", id);
|
||||
auto modelType = new LDFData<int>(u"modelType", 2);
|
||||
auto propertyObjectID = new LDFData<bool>(u"propertyObjectID", true);
|
||||
auto componentWhitelist = new LDFData<int>(u"componentWhitelist", 1);
|
||||
info.nodes[0]->config.push_back(componentWhitelist);
|
||||
info.nodes[0]->config.push_back(ldfModelBehavior);
|
||||
info.nodes[0]->config.push_back(modelType);
|
||||
info.nodes[0]->config.push_back(propertyObjectID);
|
||||
info.nodes[0]->config.push_back(userModelID);
|
||||
auto ldfModelBehavior = new LDFData<LWOOBJID>(u"modelBehaviors", 0);
|
||||
auto userModelID = new LDFData<LWOOBJID>(u"userModelID", id);
|
||||
auto modelType = new LDFData<int>(u"modelType", 2);
|
||||
auto propertyObjectID = new LDFData<bool>(u"propertyObjectID", true);
|
||||
auto componentWhitelist = new LDFData<int>(u"componentWhitelist", 1);
|
||||
info.nodes[0]->config.push_back(componentWhitelist);
|
||||
info.nodes[0]->config.push_back(ldfModelBehavior);
|
||||
info.nodes[0]->config.push_back(modelType);
|
||||
info.nodes[0]->config.push_back(propertyObjectID);
|
||||
info.nodes[0]->config.push_back(userModelID);
|
||||
|
||||
auto* model = spawner->Spawn();
|
||||
auto* model = spawner->Spawn();
|
||||
|
||||
models.insert_or_assign(model->GetObjectID(), spawnerId);
|
||||
models.insert_or_assign(model->GetObjectID(), spawnerId);
|
||||
|
||||
GameMessages::SendPlaceModelResponse(entity->GetObjectID(), entity->GetSystemAddress(), position, m_Parent->GetObjectID(), 14, originalRotation);
|
||||
GameMessages::SendPlaceModelResponse(entity->GetObjectID(), entity->GetSystemAddress(), position, m_Parent->GetObjectID(), 14, originalRotation);
|
||||
|
||||
GameMessages::SendUGCEquipPreCreateBasedOnEditMode(entity->GetObjectID(), entity->GetSystemAddress(), 0, spawnerId);
|
||||
GameMessages::SendUGCEquipPreCreateBasedOnEditMode(entity->GetObjectID(), entity->GetSystemAddress(), 0, spawnerId);
|
||||
|
||||
GameMessages::SendGetModelsOnProperty(entity->GetObjectID(), GetModels(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||
GameMessages::SendGetModelsOnProperty(entity->GetObjectID(), GetModels(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
EntityManager::Instance()->GetZoneControlEntity()->OnZonePropertyModelPlaced(entity);
|
||||
EntityManager::Instance()->GetZoneControlEntity()->OnZonePropertyModelPlaced(entity);
|
||||
});
|
||||
// Progress place model missions
|
||||
auto missionComponent = entity->GetComponent<MissionComponent>();
|
||||
if (missionComponent != nullptr) missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_PLACE_MODEL, 0);
|
||||
// Progress place model missions
|
||||
auto missionComponent = entity->GetComponent<MissionComponent>();
|
||||
if (missionComponent != nullptr) missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_PLACE_MODEL, 0);
|
||||
}
|
||||
|
||||
void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int deleteReason)
|
||||
{
|
||||
void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int deleteReason) {
|
||||
Game::logger->Log("PropertyManagementComponent", "Delete model: (%llu) (%i)", id, deleteReason);
|
||||
|
||||
auto* entity = GetOwner();
|
||||
|
||||
if (entity == nullptr)
|
||||
{
|
||||
if (entity == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto* inventoryComponent = entity->GetComponent<InventoryComponent>();
|
||||
|
||||
if (inventoryComponent == nullptr)
|
||||
{
|
||||
if (inventoryComponent == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto index = models.find(id);
|
||||
|
||||
if (index == models.end())
|
||||
{
|
||||
if (index == models.end()) {
|
||||
Game::logger->Log("PropertyManagementComponent", "Failed to find model");
|
||||
|
||||
return;
|
||||
@@ -460,15 +424,13 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet
|
||||
|
||||
models.erase(id);
|
||||
|
||||
if (spawner == nullptr)
|
||||
{
|
||||
if (spawner == nullptr) {
|
||||
Game::logger->Log("PropertyManagementComponent", "Failed to find spawner");
|
||||
}
|
||||
|
||||
auto* model = EntityManager::Instance()->GetEntity(id);
|
||||
|
||||
if (model == nullptr)
|
||||
{
|
||||
if (model == nullptr) {
|
||||
Game::logger->Log("PropertyManagementComponent", "Failed to find model entity");
|
||||
|
||||
return;
|
||||
@@ -478,8 +440,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet
|
||||
|
||||
Game::logger->Log("PropertyManagementComponent", "Deleting model LOT %i", model->GetLOT());
|
||||
|
||||
if (model->GetLOT() == 14)
|
||||
{
|
||||
if (model->GetLOT() == 14) {
|
||||
//add it to the inv
|
||||
std::vector<LDFBaseData*> settings;
|
||||
|
||||
@@ -509,13 +470,11 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet
|
||||
return;
|
||||
}
|
||||
|
||||
if (deleteReason == 0)
|
||||
{
|
||||
if (deleteReason == 0) {
|
||||
//item->Equip();
|
||||
}
|
||||
|
||||
if (deleteReason == 0 || deleteReason == 2)
|
||||
{
|
||||
if (deleteReason == 0 || deleteReason == 2) {
|
||||
GameMessages::SendUGCEquipPostDeleteBasedOnEditMode(entity->GetObjectID(), entity->GetSystemAddress(), item->GetId(), item->GetCount());
|
||||
}
|
||||
|
||||
@@ -523,12 +482,9 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet
|
||||
|
||||
GameMessages::SendPlaceModelResponse(entity->GetObjectID(), entity->GetSystemAddress(), NiPoint3::ZERO, LWOOBJID_EMPTY, 16, NiQuaternion::IDENTITY);
|
||||
|
||||
if (spawner != nullptr)
|
||||
{
|
||||
if (spawner != nullptr) {
|
||||
dZoneManager::Instance()->RemoveSpawner(spawner->m_Info.spawnerID);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
model->Smash(SILENT);
|
||||
}
|
||||
|
||||
@@ -545,8 +501,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet
|
||||
return;
|
||||
}
|
||||
|
||||
switch (deleteReason)
|
||||
{
|
||||
switch (deleteReason) {
|
||||
case 0: // Pickup
|
||||
{
|
||||
item->Equip();
|
||||
@@ -580,18 +535,14 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet
|
||||
|
||||
GameMessages::SendPlaceModelResponse(entity->GetObjectID(), entity->GetSystemAddress(), NiPoint3::ZERO, LWOOBJID_EMPTY, 16, NiQuaternion::IDENTITY);
|
||||
|
||||
if (spawner != nullptr)
|
||||
{
|
||||
if (spawner != nullptr) {
|
||||
dZoneManager::Instance()->RemoveSpawner(spawner->m_Info.spawnerID);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
model->Smash(SILENT);
|
||||
}
|
||||
}
|
||||
|
||||
void PropertyManagementComponent::UpdateApprovedStatus(const bool value)
|
||||
{
|
||||
void PropertyManagementComponent::UpdateApprovedStatus(const bool value) {
|
||||
if (owner == LWOOBJID_EMPTY) return;
|
||||
|
||||
auto* update = Database::CreatePreppedStmt("UPDATE properties SET mod_approved = ? WHERE id = ?;");
|
||||
@@ -604,10 +555,8 @@ void PropertyManagementComponent::UpdateApprovedStatus(const bool value)
|
||||
delete update;
|
||||
}
|
||||
|
||||
void PropertyManagementComponent::Load()
|
||||
{
|
||||
if (propertyId == LWOOBJID_EMPTY)
|
||||
{
|
||||
void PropertyManagementComponent::Load() {
|
||||
if (propertyId == LWOOBJID_EMPTY) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -617,8 +566,7 @@ void PropertyManagementComponent::Load()
|
||||
|
||||
auto* lookupResult = lookup->executeQuery();
|
||||
|
||||
while (lookupResult->next())
|
||||
{
|
||||
while (lookupResult->next()) {
|
||||
const LWOOBJID id = lookupResult->getUInt64(1);
|
||||
const LOT lot = lookupResult->getInt(2);
|
||||
|
||||
@@ -703,10 +651,8 @@ void PropertyManagementComponent::Load()
|
||||
delete lookup;
|
||||
}
|
||||
|
||||
void PropertyManagementComponent::Save()
|
||||
{
|
||||
if (propertyId == LWOOBJID_EMPTY)
|
||||
{
|
||||
void PropertyManagementComponent::Save() {
|
||||
if (propertyId == LWOOBJID_EMPTY) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -724,8 +670,7 @@ void PropertyManagementComponent::Save()
|
||||
}
|
||||
std::vector<LWOOBJID> present;
|
||||
|
||||
while (lookupResult->next())
|
||||
{
|
||||
while (lookupResult->next()) {
|
||||
const auto dbId = lookupResult->getUInt64(1);
|
||||
|
||||
present.push_back(dbId);
|
||||
@@ -735,24 +680,21 @@ void PropertyManagementComponent::Save()
|
||||
|
||||
std::vector<LWOOBJID> modelIds;
|
||||
|
||||
for (const auto& pair : models)
|
||||
{
|
||||
for (const auto& pair : models) {
|
||||
const auto id = pair.second;
|
||||
|
||||
modelIds.push_back(id);
|
||||
|
||||
auto* entity = EntityManager::Instance()->GetEntity(pair.first);
|
||||
|
||||
if (entity == nullptr)
|
||||
{
|
||||
if (entity == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto position = entity->GetPosition();
|
||||
const auto rotation = entity->GetRotation();
|
||||
|
||||
if (std::find(present.begin(), present.end(), id) == present.end())
|
||||
{
|
||||
if (std::find(present.begin(), present.end(), id) == present.end()) {
|
||||
insertion->setInt64(1, id);
|
||||
insertion->setUInt64(2, propertyId);
|
||||
insertion->setNull(3, 0);
|
||||
@@ -769,9 +711,7 @@ void PropertyManagementComponent::Save()
|
||||
} catch (sql::SQLException& ex) {
|
||||
Game::logger->Log("PropertyManagementComponent", "Error inserting into properties_contents. Error %s", ex.what());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
update->setDouble(1, position.x);
|
||||
update->setDouble(2, position.y);
|
||||
update->setDouble(3, position.z);
|
||||
@@ -789,10 +729,8 @@ void PropertyManagementComponent::Save()
|
||||
}
|
||||
}
|
||||
|
||||
for (auto id : present)
|
||||
{
|
||||
if (std::find(modelIds.begin(), modelIds.end(), id) != modelIds.end())
|
||||
{
|
||||
for (auto id : present) {
|
||||
if (std::find(modelIds.begin(), modelIds.end(), id) != modelIds.end()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -815,26 +753,23 @@ void PropertyManagementComponent::Save()
|
||||
delete remove;
|
||||
}
|
||||
|
||||
void PropertyManagementComponent::AddModel(LWOOBJID modelId, LWOOBJID spawnerId)
|
||||
{
|
||||
void PropertyManagementComponent::AddModel(LWOOBJID modelId, LWOOBJID spawnerId) {
|
||||
models[modelId] = spawnerId;
|
||||
}
|
||||
|
||||
PropertyManagementComponent* PropertyManagementComponent::Instance()
|
||||
{
|
||||
PropertyManagementComponent* PropertyManagementComponent::Instance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
void PropertyManagementComponent::OnQueryPropertyData(Entity* originator, const SystemAddress& sysAddr, LWOOBJID author)
|
||||
{
|
||||
void PropertyManagementComponent::OnQueryPropertyData(Entity* originator, const SystemAddress& sysAddr, LWOOBJID author) {
|
||||
if (author == LWOOBJID_EMPTY) {
|
||||
author = m_Parent->GetObjectID();
|
||||
}
|
||||
|
||||
const auto& worldId = dZoneManager::Instance()->GetZone()->GetZoneID();
|
||||
const auto zoneId = worldId.GetMapID();
|
||||
const auto& worldId = dZoneManager::Instance()->GetZone()->GetZoneID();
|
||||
const auto zoneId = worldId.GetMapID();
|
||||
|
||||
Game::logger->Log("Properties", "Getting property info for %d", zoneId);
|
||||
Game::logger->Log("Properties", "Getting property info for %d", zoneId);
|
||||
GameMessages::PropertyDataMessage message = GameMessages::PropertyDataMessage(zoneId);
|
||||
|
||||
const auto isClaimed = GetOwnerId() != LWOOBJID_EMPTY;
|
||||
@@ -904,18 +839,15 @@ void PropertyManagementComponent::OnQueryPropertyData(Entity* originator, const
|
||||
// send rejection here?
|
||||
}
|
||||
|
||||
void PropertyManagementComponent::OnUse(Entity* originator)
|
||||
{
|
||||
void PropertyManagementComponent::OnUse(Entity* originator) {
|
||||
OnQueryPropertyData(originator, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
GameMessages::SendOpenPropertyManagment(m_Parent->GetObjectID(), originator->GetSystemAddress());
|
||||
}
|
||||
|
||||
void PropertyManagementComponent::SetOwnerId(const LWOOBJID value)
|
||||
{
|
||||
void PropertyManagementComponent::SetOwnerId(const LWOOBJID value) {
|
||||
owner = value;
|
||||
}
|
||||
|
||||
const std::map<LWOOBJID, LWOOBJID>& PropertyManagementComponent::GetModels() const
|
||||
{
|
||||
const std::map<LWOOBJID, LWOOBJID>& PropertyManagementComponent::GetModels() const {
|
||||
return models;
|
||||
}
|
||||
|
Reference in New Issue
Block a user