2022-08-06 03:01:59 +00:00
|
|
|
#include "PropertyManagementComponent.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
|
2022-07-05 06:00:10 +00:00
|
|
|
#include "MissionComponent.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
#include "EntityManager.h"
|
|
|
|
#include "PropertyDataMessage.h"
|
|
|
|
#include "UserManager.h"
|
|
|
|
#include "GameMessages.h"
|
|
|
|
#include "Character.h"
|
|
|
|
#include "CDClientDatabase.h"
|
|
|
|
#include "dZoneManager.h"
|
|
|
|
#include "Game.h"
|
|
|
|
#include "Item.h"
|
|
|
|
#include "Database.h"
|
2024-01-05 12:31:22 +00:00
|
|
|
#include "ObjectIDManager.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
#include "RocketLaunchpadControlComponent.h"
|
|
|
|
#include "PropertyEntranceComponent.h"
|
2022-12-18 15:46:04 +00:00
|
|
|
#include "InventoryComponent.h"
|
2023-01-22 23:38:47 +00:00
|
|
|
#include "eMissionTaskType.h"
|
2023-04-25 18:17:40 +00:00
|
|
|
#include "eObjectBits.h"
|
2024-01-12 17:39:51 +00:00
|
|
|
#include "CharacterComponent.h"
|
2024-01-13 09:40:56 +00:00
|
|
|
#include "PlayerManager.h"
|
2024-05-18 09:05:55 +00:00
|
|
|
#include "ModelComponent.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include "CppScripts.h"
|
2024-05-18 09:05:55 +00:00
|
|
|
#include <ranges>
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
PropertyManagementComponent* PropertyManagementComponent::instance = nullptr;
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
PropertyManagementComponent::PropertyManagementComponent(Entity* parent) : Component(parent) {
|
2021-12-05 17:54:36 +00:00
|
|
|
this->owner = LWOOBJID_EMPTY;
|
|
|
|
this->templateId = 0;
|
|
|
|
this->propertyId = LWOOBJID_EMPTY;
|
|
|
|
this->models = {};
|
|
|
|
this->propertyName = "";
|
|
|
|
this->propertyDescription = "";
|
|
|
|
this->privacyOption = PropertyPrivacyOption::Private;
|
|
|
|
this->originalPrivacyOption = PropertyPrivacyOption::Private;
|
|
|
|
|
|
|
|
instance = this;
|
|
|
|
|
2023-07-17 22:55:33 +00:00
|
|
|
const auto& worldId = Game::zoneManager->GetZone()->GetZoneID();
|
2021-12-05 17:54:36 +00:00
|
|
|
const auto zoneId = worldId.GetMapID();
|
|
|
|
const auto cloneId = worldId.GetCloneID();
|
|
|
|
|
2023-11-18 00:47:18 +00:00
|
|
|
auto query = CDClientDatabase::CreatePreppedStmt("SELECT id FROM PropertyTemplate WHERE mapID = ?;");
|
|
|
|
|
|
|
|
query.bind(1, static_cast<int32_t>(zoneId));
|
2022-01-13 03:48:27 +00:00
|
|
|
|
|
|
|
auto result = query.execQuery();
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2024-04-14 04:41:51 +00:00
|
|
|
if (result.eof() || result.fieldIsNull("id")) {
|
2021-12-05 17:54:36 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-07-25 02:26:51 +00:00
|
|
|
|
2024-04-14 04:41:51 +00:00
|
|
|
templateId = result.getIntField("id");
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-11-18 00:47:18 +00:00
|
|
|
auto propertyInfo = Database::Get()->GetPropertyInfo(zoneId, cloneId);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-11-18 00:47:18 +00:00
|
|
|
if (propertyInfo) {
|
|
|
|
this->propertyId = propertyInfo->id;
|
|
|
|
this->owner = propertyInfo->ownerId;
|
2023-04-25 18:17:40 +00:00
|
|
|
GeneralUtils::SetBit(this->owner, eObjectBits::CHARACTER);
|
|
|
|
GeneralUtils::SetBit(this->owner, eObjectBits::PERSISTENT);
|
2023-11-18 00:47:18 +00:00
|
|
|
this->clone_Id = propertyInfo->cloneId;
|
|
|
|
this->propertyName = propertyInfo->name;
|
|
|
|
this->propertyDescription = propertyInfo->description;
|
|
|
|
this->privacyOption = static_cast<PropertyPrivacyOption>(propertyInfo->privacyOption);
|
|
|
|
this->rejectionReason = propertyInfo->rejectionReason;
|
|
|
|
this->moderatorRequested = propertyInfo->modApproved == 0 && rejectionReason == "" && privacyOption == PropertyPrivacyOption::Public;
|
|
|
|
this->LastUpdatedTime = propertyInfo->lastUpdatedTime;
|
|
|
|
this->claimedTime = propertyInfo->claimedTime;
|
|
|
|
this->reputation = propertyInfo->reputation;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
Load();
|
2022-07-25 02:26:51 +00:00
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
LWOOBJID PropertyManagementComponent::GetOwnerId() const {
|
2021-12-05 17:54:36 +00:00
|
|
|
return owner;
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
Entity* PropertyManagementComponent::GetOwner() const {
|
2023-07-15 20:56:33 +00:00
|
|
|
return Game::entityManager->GetEntity(owner);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void PropertyManagementComponent::SetOwner(Entity* value) {
|
2021-12-05 17:54:36 +00:00
|
|
|
owner = value->GetObjectID();
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
std::vector<NiPoint3> PropertyManagementComponent::GetPaths() const {
|
2023-07-17 22:55:33 +00:00
|
|
|
const auto zoneId = Game::zoneManager->GetZone()->GetWorldID();
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-01-13 03:48:27 +00:00
|
|
|
auto query = CDClientDatabase::CreatePreppedStmt(
|
|
|
|
"SELECT path FROM PropertyTemplate WHERE mapID = ?;");
|
2023-12-28 04:18:20 +00:00
|
|
|
query.bind(1, static_cast<int>(zoneId));
|
2022-01-13 03:48:27 +00:00
|
|
|
|
|
|
|
auto result = query.execQuery();
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
std::vector<NiPoint3> paths{};
|
2022-07-25 02:26:51 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (result.eof()) {
|
2021-12-05 17:54:36 +00:00
|
|
|
return paths;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<float> points;
|
2022-07-25 02:26:51 +00:00
|
|
|
|
2024-04-14 04:41:51 +00:00
|
|
|
std::istringstream stream(result.getStringField("path"));
|
2021-12-05 17:54:36 +00:00
|
|
|
std::string token;
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
while (std::getline(stream, token, ' ')) {
|
|
|
|
try {
|
2021-12-05 17:54:36 +00:00
|
|
|
auto value = std::stof(token);
|
|
|
|
|
|
|
|
points.push_back(value);
|
2022-07-28 13:39:57 +00:00
|
|
|
} catch (std::invalid_argument& exception) {
|
2023-10-21 23:31:55 +00:00
|
|
|
LOG("Failed to parse value (%s): (%s)!", token.c_str(), exception.what());
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
for (auto i = 0u; i < points.size(); i += 3) {
|
2021-12-05 17:54:36 +00:00
|
|
|
paths.emplace_back(points[i], points[i + 1], points[i + 2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return paths;
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
PropertyPrivacyOption PropertyManagementComponent::GetPrivacyOption() const {
|
2021-12-05 17:54:36 +00:00
|
|
|
return privacyOption;
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void PropertyManagementComponent::SetPrivacyOption(PropertyPrivacyOption value) {
|
2021-12-05 17:54:36 +00:00
|
|
|
if (owner == LWOOBJID_EMPTY) return;
|
|
|
|
|
|
|
|
if (value == static_cast<PropertyPrivacyOption>(3)) // Client sends 3 for private for some reason, but expects 0 in return?
|
|
|
|
{
|
|
|
|
value = PropertyPrivacyOption::Private;
|
|
|
|
}
|
|
|
|
|
2022-03-31 03:33:37 +00:00
|
|
|
if (value == PropertyPrivacyOption::Public && privacyOption != PropertyPrivacyOption::Public) {
|
|
|
|
rejectionReason = "";
|
|
|
|
moderatorRequested = true;
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
privacyOption = value;
|
|
|
|
|
2023-11-18 00:47:18 +00:00
|
|
|
IProperty::Info info;
|
|
|
|
info.id = propertyId;
|
|
|
|
info.privacyOption = static_cast<uint32_t>(privacyOption);
|
|
|
|
info.rejectionReason = rejectionReason;
|
|
|
|
info.modApproved = 0;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-11-18 00:47:18 +00:00
|
|
|
Database::Get()->UpdatePropertyModerationInfo(info);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void PropertyManagementComponent::UpdatePropertyDetails(std::string name, std::string description) {
|
2021-12-05 17:54:36 +00:00
|
|
|
if (owner == LWOOBJID_EMPTY) return;
|
|
|
|
|
|
|
|
propertyName = name;
|
|
|
|
|
|
|
|
propertyDescription = description;
|
|
|
|
|
2023-11-18 00:47:18 +00:00
|
|
|
IProperty::Info info;
|
|
|
|
info.id = propertyId;
|
|
|
|
info.name = propertyName;
|
|
|
|
info.description = propertyDescription;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-11-18 00:47:18 +00:00
|
|
|
Database::Get()->UpdatePropertyDetails(info);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
OnQueryPropertyData(GetOwner(), UNASSIGNED_SYSTEM_ADDRESS);
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
bool PropertyManagementComponent::Claim(const LWOOBJID playerId) {
|
|
|
|
if (owner != LWOOBJID_EMPTY) {
|
2022-03-31 04:58:59 +00:00
|
|
|
return false;
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2023-07-15 20:56:33 +00:00
|
|
|
auto* entity = Game::entityManager->GetEntity(playerId);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-03-30 07:33:31 +00:00
|
|
|
auto character = entity->GetCharacter();
|
2022-03-31 04:58:59 +00:00
|
|
|
if (!character) return false;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-07-17 22:55:33 +00:00
|
|
|
auto* zone = Game::zoneManager->GetZone();
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
const auto& worldId = zone->GetZoneID();
|
2022-03-31 04:58:59 +00:00
|
|
|
const auto propertyZoneId = worldId.GetMapID();
|
|
|
|
const auto propertyCloneId = worldId.GetCloneID();
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-03-31 04:58:59 +00:00
|
|
|
const auto playerCloneId = character->GetPropertyCloneID();
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-03-31 04:58:59 +00:00
|
|
|
// If we are not on our clone do not allow us to claim the property
|
|
|
|
if (propertyCloneId != playerCloneId) return false;
|
|
|
|
|
2022-11-12 14:44:13 +00:00
|
|
|
std::string name = zone->GetZoneName();
|
|
|
|
std::string description = "";
|
|
|
|
|
|
|
|
auto prop_path = zone->GetPath(m_Parent->GetVarAsString(u"propertyName"));
|
|
|
|
|
|
|
|
if (prop_path){
|
|
|
|
if (!prop_path->property.displayName.empty()) name = prop_path->property.displayName;
|
|
|
|
description = prop_path->property.displayDesc;
|
|
|
|
}
|
|
|
|
|
2022-03-31 04:58:59 +00:00
|
|
|
SetOwnerId(playerId);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
propertyId = ObjectIDManager::GenerateRandomObjectID();
|
2022-03-31 04:58:59 +00:00
|
|
|
|
2023-11-18 00:47:18 +00:00
|
|
|
IProperty::Info info;
|
|
|
|
info.id = propertyId;
|
|
|
|
info.ownerId = character->GetID();
|
|
|
|
info.cloneId = playerCloneId;
|
|
|
|
info.name = name;
|
|
|
|
info.description = description;
|
|
|
|
|
|
|
|
Database::Get()->InsertNewProperty(info, templateId, worldId);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-07-17 22:55:33 +00:00
|
|
|
auto* zoneControlObject = Game::zoneManager->GetZoneControlObject();
|
2024-03-07 01:49:29 +00:00
|
|
|
if (zoneControlObject) zoneControlObject->GetScript()->OnZonePropertyRented(zoneControlObject, entity);
|
2022-03-31 04:58:59 +00:00
|
|
|
return true;
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void PropertyManagementComponent::OnStartBuilding() {
|
2021-12-05 17:54:36 +00:00
|
|
|
auto* ownerEntity = GetOwner();
|
|
|
|
|
|
|
|
if (ownerEntity == nullptr) return;
|
|
|
|
|
2024-01-13 09:40:56 +00:00
|
|
|
const auto players = PlayerManager::GetAllPlayers();
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
LWOMAPID zoneId = 1100;
|
|
|
|
|
2023-07-15 20:56:33 +00:00
|
|
|
const auto entrance = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::PROPERTY_ENTRANCE);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
originalPrivacyOption = privacyOption;
|
|
|
|
|
|
|
|
SetPrivacyOption(PropertyPrivacyOption::Private); // Cant visit player which is building
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (!entrance.empty()) {
|
2021-12-05 17:54:36 +00:00
|
|
|
auto* rocketPad = entrance[0]->GetComponent<RocketLaunchpadControlComponent>();
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (rocketPad != nullptr) {
|
2021-12-05 17:54:36 +00:00
|
|
|
zoneId = rocketPad->GetDefaultZone();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
for (auto* player : players) {
|
2021-12-05 17:54:36 +00:00
|
|
|
if (player == ownerEntity) continue;
|
|
|
|
|
2024-01-12 17:39:51 +00:00
|
|
|
auto* characterComponent = player->GetComponent<CharacterComponent>();
|
|
|
|
if (characterComponent) characterComponent->SendToZone(zoneId);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
2022-07-06 08:30:13 +00:00
|
|
|
auto inventoryComponent = ownerEntity->GetComponent<InventoryComponent>();
|
|
|
|
|
|
|
|
// Push equipped items
|
|
|
|
if (inventoryComponent) inventoryComponent->PushEquippedItems();
|
2024-11-03 04:40:48 +00:00
|
|
|
|
|
|
|
for (const auto obj : models | std::views::keys) {
|
|
|
|
auto* const model = Game::entityManager->GetEntity(obj);
|
|
|
|
|
|
|
|
if (!model) continue;
|
|
|
|
|
|
|
|
auto* const modelComponent = model->GetComponent<ModelComponent>();
|
|
|
|
if (modelComponent) modelComponent->SetIsRunning(false);
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void PropertyManagementComponent::OnFinishBuilding() {
|
2021-12-05 17:54:36 +00:00
|
|
|
auto* ownerEntity = GetOwner();
|
|
|
|
|
|
|
|
if (ownerEntity == nullptr) return;
|
|
|
|
|
|
|
|
SetPrivacyOption(originalPrivacyOption);
|
|
|
|
|
|
|
|
UpdateApprovedStatus(false);
|
2022-03-31 05:51:09 +00:00
|
|
|
|
|
|
|
Save();
|
2024-11-03 04:40:48 +00:00
|
|
|
for (const auto obj : models | std::views::keys) {
|
|
|
|
auto* const model = Game::entityManager->GetEntity(obj);
|
|
|
|
|
|
|
|
if (!model) continue;
|
|
|
|
|
|
|
|
auto* const modelComponent = model->GetComponent<ModelComponent>();
|
|
|
|
if (modelComponent) modelComponent->SetIsRunning(true);
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const NiPoint3 position, NiQuaternion rotation) {
|
2023-10-21 23:31:55 +00:00
|
|
|
LOG("Placing model <%f, %f, %f>", position.x, position.y, position.z);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
auto* entity = GetOwner();
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (entity == nullptr) {
|
2021-12-05 17:54:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto* inventoryComponent = entity->GetComponent<InventoryComponent>();
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (inventoryComponent == nullptr) {
|
2021-12-05 17:54:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto* item = inventoryComponent->FindItemById(id);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (item == nullptr) {
|
2023-10-21 23:31:55 +00:00
|
|
|
LOG("Failed to find item with id %d", id);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
NiQuaternion originalRotation = rotation;
|
|
|
|
|
|
|
|
const auto modelLOT = item->GetLot();
|
|
|
|
|
2024-01-29 07:53:12 +00:00
|
|
|
if (rotation != NiQuaternionConstant::IDENTITY) {
|
2021-12-05 17:54:36 +00:00
|
|
|
rotation = { rotation.w, rotation.z, rotation.y, rotation.x };
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item->GetLot() == 6662) {
|
|
|
|
LWOOBJID spawnerID = item->GetSubKey();
|
|
|
|
|
|
|
|
EntityInfo info;
|
|
|
|
info.lot = 14;
|
|
|
|
info.pos = {};
|
|
|
|
info.rot = {};
|
|
|
|
info.spawner = nullptr;
|
|
|
|
info.spawnerID = spawnerID;
|
|
|
|
info.spawnerNodeID = 0;
|
|
|
|
|
|
|
|
for (auto* setting : item->GetConfig()) {
|
|
|
|
info.settings.push_back(setting->Copy());
|
|
|
|
}
|
|
|
|
|
2023-07-15 20:56:33 +00:00
|
|
|
Entity* newEntity = Game::entityManager->CreateEntity(info);
|
2021-12-05 17:54:36 +00:00
|
|
|
if (newEntity != nullptr) {
|
2023-07-15 20:56:33 +00:00
|
|
|
Game::entityManager->ConstructEntity(newEntity);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-19 21:51:35 +00:00
|
|
|
// Make sure the propMgmt doesn't delete our model after the server dies
|
|
|
|
// Trying to do this after the entity is constructed. Shouldn't really change anything but
|
|
|
|
// There was an issue with builds not appearing since it was placed above ConstructEntity.
|
2021-12-05 17:54:36 +00:00
|
|
|
PropertyManagementComponent::Instance()->AddModel(newEntity->GetObjectID(), spawnerID);
|
|
|
|
}
|
|
|
|
|
|
|
|
item->SetCount(item->GetCount() - 1);
|
|
|
|
return;
|
|
|
|
}
|
2022-07-25 02:26:51 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
item->SetCount(item->GetCount() - 1);
|
|
|
|
|
|
|
|
auto* node = new SpawnerNode();
|
|
|
|
|
|
|
|
node->position = position;
|
|
|
|
node->rotation = rotation;
|
|
|
|
|
2024-01-05 12:31:22 +00:00
|
|
|
ObjectIDManager::RequestPersistentID([this, node, modelLOT, entity, position, rotation, originalRotation](uint32_t persistentId) {
|
2022-07-28 13:39:57 +00:00
|
|
|
SpawnerInfo info{};
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
info.templateID = modelLOT;
|
|
|
|
info.nodes = { node };
|
|
|
|
info.templateScale = 1.0f;
|
|
|
|
info.activeOnLoad = true;
|
|
|
|
info.amountMaintained = 1;
|
|
|
|
info.respawnTime = 10;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
info.emulated = true;
|
2023-07-15 20:56:33 +00:00
|
|
|
info.emulator = Game::entityManager->GetZoneControlEntity()->GetObjectID();
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-04-25 18:17:40 +00:00
|
|
|
info.spawnerID = persistentId;
|
|
|
|
GeneralUtils::SetBit(info.spawnerID, eObjectBits::CLIENT);
|
2022-07-25 02:26:51 +00:00
|
|
|
|
2023-07-17 22:55:33 +00:00
|
|
|
const auto spawnerId = Game::zoneManager->MakeSpawner(info);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-07-17 22:55:33 +00:00
|
|
|
auto* spawner = Game::zoneManager->GetSpawner(spawnerId);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2024-04-05 05:51:40 +00:00
|
|
|
info.nodes[0]->config.push_back(new LDFData<LWOOBJID>(u"modelBehaviors", 0));
|
|
|
|
info.nodes[0]->config.push_back(new LDFData<LWOOBJID>(u"userModelID", info.spawnerID));
|
|
|
|
info.nodes[0]->config.push_back(new LDFData<int>(u"modelType", 2));
|
|
|
|
info.nodes[0]->config.push_back(new LDFData<bool>(u"propertyObjectID", true));
|
|
|
|
info.nodes[0]->config.push_back(new LDFData<int>(u"componentWhitelist", 1));
|
2022-07-19 21:51:35 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
auto* model = spawner->Spawn();
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
models.insert_or_assign(model->GetObjectID(), spawnerId);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
GameMessages::SendPlaceModelResponse(entity->GetObjectID(), entity->GetSystemAddress(), position, m_Parent->GetObjectID(), 14, originalRotation);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
GameMessages::SendUGCEquipPreCreateBasedOnEditMode(entity->GetObjectID(), entity->GetSystemAddress(), 0, spawnerId);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
GameMessages::SendGetModelsOnProperty(entity->GetObjectID(), GetModels(), UNASSIGNED_SYSTEM_ADDRESS);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-07-15 20:56:33 +00:00
|
|
|
Game::entityManager->GetZoneControlEntity()->OnZonePropertyModelPlaced(entity);
|
2021-12-05 17:54:36 +00:00
|
|
|
});
|
2022-07-28 13:39:57 +00:00
|
|
|
// Progress place model missions
|
|
|
|
auto missionComponent = entity->GetComponent<MissionComponent>();
|
2023-01-22 23:38:47 +00:00
|
|
|
if (missionComponent != nullptr) missionComponent->Progress(eMissionTaskType::PLACE_MODEL, 0);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int deleteReason) {
|
2023-10-21 23:31:55 +00:00
|
|
|
LOG("Delete model: (%llu) (%i)", id, deleteReason);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
auto* entity = GetOwner();
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (entity == nullptr) {
|
2021-12-05 17:54:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto* inventoryComponent = entity->GetComponent<InventoryComponent>();
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (inventoryComponent == nullptr) {
|
2021-12-05 17:54:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-11-16 01:32:17 +00:00
|
|
|
auto* model = Game::entityManager->GetEntity(id);
|
|
|
|
|
|
|
|
if (model == nullptr) {
|
|
|
|
LOG("Failed to find model entity");
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (model->GetLOT() == 14 && deleteReason == 0) {
|
|
|
|
LOG("User is trying to pick up a BBB model, but this is not implemented, so we return to prevent the user from losing the model");
|
|
|
|
|
|
|
|
GameMessages::SendUGCEquipPostDeleteBasedOnEditMode(entity->GetObjectID(), entity->GetSystemAddress(), LWOOBJID_EMPTY, 0);
|
|
|
|
|
|
|
|
// Need this to pop the user out of their current state
|
|
|
|
GameMessages::SendPlaceModelResponse(entity->GetObjectID(), entity->GetSystemAddress(), entity->GetPosition(), m_Parent->GetObjectID(), 14, entity->GetRotation());
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
const auto index = models.find(id);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (index == models.end()) {
|
2023-10-21 23:31:55 +00:00
|
|
|
LOG("Failed to find model");
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto spawnerId = index->second;
|
2022-07-25 02:26:51 +00:00
|
|
|
|
2023-07-17 22:55:33 +00:00
|
|
|
auto* spawner = Game::zoneManager->GetSpawner(spawnerId);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
models.erase(id);
|
2022-07-25 02:26:51 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (spawner == nullptr) {
|
2023-10-21 23:31:55 +00:00
|
|
|
LOG("Failed to find spawner");
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2023-07-15 20:56:33 +00:00
|
|
|
Game::entityManager->DestructEntity(model);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-10-21 23:31:55 +00:00
|
|
|
LOG("Deleting model LOT %i", model->GetLOT());
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (model->GetLOT() == 14) {
|
2021-12-05 17:54:36 +00:00
|
|
|
//add it to the inv
|
|
|
|
std::vector<LDFBaseData*> settings;
|
|
|
|
|
|
|
|
//fill our settings with BBB gurbage
|
|
|
|
LDFBaseData* ldfBlueprintID = new LDFData<LWOOBJID>(u"blueprintid", model->GetVar<LWOOBJID>(u"blueprintid"));
|
|
|
|
LDFBaseData* userModelDesc = new LDFData<std::u16string>(u"userModelDesc", u"A cool model you made!");
|
|
|
|
LDFBaseData* userModelHasBhvr = new LDFData<bool>(u"userModelHasBhvr", false);
|
|
|
|
LDFBaseData* userModelID = new LDFData<LWOOBJID>(u"userModelID", model->GetVar<LWOOBJID>(u"userModelID"));
|
|
|
|
LDFBaseData* userModelMod = new LDFData<bool>(u"userModelMod", false);
|
|
|
|
LDFBaseData* userModelName = new LDFData<std::u16string>(u"userModelName", u"My Cool Model");
|
|
|
|
LDFBaseData* propertyObjectID = new LDFData<bool>(u"userModelOpt", true);
|
|
|
|
LDFBaseData* modelType = new LDFData<int>(u"userModelPhysicsType", 2);
|
|
|
|
|
|
|
|
settings.push_back(ldfBlueprintID);
|
|
|
|
settings.push_back(userModelDesc);
|
|
|
|
settings.push_back(userModelHasBhvr);
|
|
|
|
settings.push_back(userModelID);
|
|
|
|
settings.push_back(userModelMod);
|
|
|
|
settings.push_back(userModelName);
|
|
|
|
settings.push_back(propertyObjectID);
|
|
|
|
settings.push_back(modelType);
|
|
|
|
|
2023-05-02 22:39:21 +00:00
|
|
|
inventoryComponent->AddItem(6662, 1, eLootSourceType::DELETION, eInventoryType::MODELS_IN_BBB, settings, LWOOBJID_EMPTY, false, false, spawnerId);
|
2021-12-05 17:54:36 +00:00
|
|
|
auto* item = inventoryComponent->FindItemBySubKey(spawnerId);
|
|
|
|
|
|
|
|
if (item == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (deleteReason == 0) {
|
2021-12-05 17:54:36 +00:00
|
|
|
//item->Equip();
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (deleteReason == 0 || deleteReason == 2) {
|
2021-12-05 17:54:36 +00:00
|
|
|
GameMessages::SendUGCEquipPostDeleteBasedOnEditMode(entity->GetObjectID(), entity->GetSystemAddress(), item->GetId(), item->GetCount());
|
|
|
|
}
|
|
|
|
|
|
|
|
GameMessages::SendGetModelsOnProperty(entity->GetObjectID(), GetModels(), UNASSIGNED_SYSTEM_ADDRESS);
|
|
|
|
|
2024-01-29 07:53:12 +00:00
|
|
|
GameMessages::SendPlaceModelResponse(entity->GetObjectID(), entity->GetSystemAddress(), NiPoint3Constant::ZERO, LWOOBJID_EMPTY, 16, NiQuaternionConstant::IDENTITY);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (spawner != nullptr) {
|
2023-07-17 22:55:33 +00:00
|
|
|
Game::zoneManager->RemoveSpawner(spawner->m_Info.spawnerID);
|
2022-07-28 13:39:57 +00:00
|
|
|
} else {
|
2023-05-02 22:39:21 +00:00
|
|
|
model->Smash(LWOOBJID_EMPTY, eKillType::SILENT);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
item->SetCount(0, true, false, false);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2022-07-25 02:26:51 +00:00
|
|
|
|
2023-05-02 22:39:21 +00:00
|
|
|
inventoryComponent->AddItem(model->GetLOT(), 1, eLootSourceType::DELETION, INVALID, {}, LWOOBJID_EMPTY, false);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
auto* item = inventoryComponent->FindItemByLot(model->GetLOT());
|
|
|
|
|
|
|
|
if (item == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
switch (deleteReason) {
|
2021-12-05 17:54:36 +00:00
|
|
|
case 0: // Pickup
|
|
|
|
{
|
|
|
|
item->Equip();
|
|
|
|
|
|
|
|
GameMessages::SendUGCEquipPostDeleteBasedOnEditMode(entity->GetObjectID(), entity->GetSystemAddress(), item->GetId(), item->GetCount());
|
2023-07-15 20:56:33 +00:00
|
|
|
Game::entityManager->GetZoneControlEntity()->OnZonePropertyModelPickedUp(entity);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 1: // Return to inv
|
|
|
|
{
|
2023-07-15 20:56:33 +00:00
|
|
|
Game::entityManager->GetZoneControlEntity()->OnZonePropertyModelRemoved(entity);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2: // Break apart
|
|
|
|
{
|
|
|
|
item->SetCount(item->GetCount() - 1);
|
|
|
|
|
2024-01-11 04:57:41 +00:00
|
|
|
LOG("DLU currently does not support breaking apart brick by brick models.");
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
2023-10-21 23:31:55 +00:00
|
|
|
LOG("Invalid delete reason");
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
}
|
2022-07-25 02:26:51 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
GameMessages::SendGetModelsOnProperty(entity->GetObjectID(), GetModels(), UNASSIGNED_SYSTEM_ADDRESS);
|
|
|
|
|
2024-01-29 07:53:12 +00:00
|
|
|
GameMessages::SendPlaceModelResponse(entity->GetObjectID(), entity->GetSystemAddress(), NiPoint3Constant::ZERO, LWOOBJID_EMPTY, 16, NiQuaternionConstant::IDENTITY);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (spawner != nullptr) {
|
2023-07-17 22:55:33 +00:00
|
|
|
Game::zoneManager->RemoveSpawner(spawner->m_Info.spawnerID);
|
2022-07-28 13:39:57 +00:00
|
|
|
} else {
|
2023-05-02 22:39:21 +00:00
|
|
|
model->Smash(LWOOBJID_EMPTY, eKillType::SILENT);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void PropertyManagementComponent::UpdateApprovedStatus(const bool value) {
|
2021-12-05 17:54:36 +00:00
|
|
|
if (owner == LWOOBJID_EMPTY) return;
|
2022-07-25 02:26:51 +00:00
|
|
|
|
2023-11-18 00:47:18 +00:00
|
|
|
IProperty::Info info;
|
|
|
|
info.id = propertyId;
|
|
|
|
info.modApproved = value;
|
|
|
|
info.privacyOption = static_cast<uint32_t>(privacyOption);
|
|
|
|
info.rejectionReason = "";
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-11-18 00:47:18 +00:00
|
|
|
Database::Get()->UpdatePropertyModerationInfo(info);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void PropertyManagementComponent::Load() {
|
|
|
|
if (propertyId == LWOOBJID_EMPTY) {
|
2021-12-05 17:54:36 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-07-25 02:26:51 +00:00
|
|
|
|
2023-11-18 00:47:18 +00:00
|
|
|
auto propertyModels = Database::Get()->GetPropertyModels(propertyId);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-11-18 00:47:18 +00:00
|
|
|
for (const auto& databaseModel : propertyModels) {
|
2021-12-05 17:54:36 +00:00
|
|
|
auto* node = new SpawnerNode();
|
|
|
|
|
2023-11-18 00:47:18 +00:00
|
|
|
node->position = databaseModel.position;
|
|
|
|
node->rotation = databaseModel.rotation;
|
2022-07-25 02:26:51 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
SpawnerInfo info{};
|
|
|
|
|
2023-11-18 00:47:18 +00:00
|
|
|
info.templateID = databaseModel.lot;
|
2021-12-05 17:54:36 +00:00
|
|
|
info.nodes = { node };
|
|
|
|
info.templateScale = 1.0f;
|
|
|
|
info.activeOnLoad = true;
|
|
|
|
info.amountMaintained = 1;
|
|
|
|
info.respawnTime = 10;
|
|
|
|
|
|
|
|
//info.emulated = true;
|
2023-07-15 20:56:33 +00:00
|
|
|
//info.emulator = Game::entityManager->GetZoneControlEntity()->GetObjectID();
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-11-18 00:47:18 +00:00
|
|
|
info.spawnerID = databaseModel.id;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
std::vector<LDFBaseData*> settings;
|
|
|
|
|
|
|
|
//BBB property models need to have extra stuff set for them:
|
2023-11-18 00:47:18 +00:00
|
|
|
if (databaseModel.lot == 14) {
|
|
|
|
LWOOBJID blueprintID = databaseModel.ugcId;
|
2023-04-25 18:17:40 +00:00
|
|
|
GeneralUtils::SetBit(blueprintID, eObjectBits::CHARACTER);
|
|
|
|
GeneralUtils::SetBit(blueprintID, eObjectBits::PERSISTENT);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2024-04-05 05:51:40 +00:00
|
|
|
settings.push_back(new LDFData<LWOOBJID>(u"blueprintid", blueprintID));
|
|
|
|
settings.push_back(new LDFData<int>(u"componentWhitelist", 1));
|
|
|
|
settings.push_back(new LDFData<int>(u"modelType", 2));
|
|
|
|
settings.push_back(new LDFData<bool>(u"propertyObjectID", true));
|
|
|
|
settings.push_back(new LDFData<LWOOBJID>(u"userModelID", databaseModel.id));
|
2022-07-19 21:51:35 +00:00
|
|
|
} else {
|
2024-04-05 05:51:40 +00:00
|
|
|
settings.push_back(new LDFData<int>(u"modelType", 2));
|
|
|
|
settings.push_back(new LDFData<LWOOBJID>(u"userModelID", databaseModel.id));
|
|
|
|
settings.push_back(new LDFData<LWOOBJID>(u"modelBehaviors", 0));
|
|
|
|
settings.push_back(new LDFData<bool>(u"propertyObjectID", true));
|
|
|
|
settings.push_back(new LDFData<int>(u"componentWhitelist", 1));
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2024-05-18 10:36:29 +00:00
|
|
|
std::ostringstream userModelBehavior;
|
|
|
|
bool firstAdded = false;
|
2024-05-18 10:52:36 +00:00
|
|
|
for (auto behavior : databaseModel.behaviors) {
|
|
|
|
if (behavior < 0) {
|
|
|
|
LOG("Invalid behavior ID: %d, removing behavior reference from model", behavior);
|
|
|
|
behavior = 0;
|
|
|
|
}
|
2024-05-18 10:36:29 +00:00
|
|
|
if (firstAdded) userModelBehavior << ",";
|
|
|
|
userModelBehavior << behavior;
|
|
|
|
firstAdded = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
settings.push_back(new LDFData<std::string>(u"userModelBehaviors", userModelBehavior.str()));
|
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
node->config = settings;
|
|
|
|
|
2023-07-17 22:55:33 +00:00
|
|
|
const auto spawnerId = Game::zoneManager->MakeSpawner(info);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-07-17 22:55:33 +00:00
|
|
|
auto* spawner = Game::zoneManager->GetSpawner(spawnerId);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
auto* model = spawner->Spawn();
|
|
|
|
|
|
|
|
models.insert_or_assign(model->GetObjectID(), spawnerId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void PropertyManagementComponent::Save() {
|
|
|
|
if (propertyId == LWOOBJID_EMPTY) {
|
2021-12-05 17:54:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-05-18 09:05:55 +00:00
|
|
|
const auto* const owner = GetOwner();
|
|
|
|
if (!owner) return;
|
|
|
|
|
|
|
|
const auto* const character = owner->GetCharacter();
|
|
|
|
if (!character) return;
|
|
|
|
|
2023-11-18 00:47:18 +00:00
|
|
|
auto present = Database::Get()->GetPropertyModels(propertyId);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
std::vector<LWOOBJID> modelIds;
|
2022-07-25 02:26:51 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
for (const auto& pair : models) {
|
2021-12-05 17:54:36 +00:00
|
|
|
const auto id = pair.second;
|
|
|
|
|
|
|
|
modelIds.push_back(id);
|
|
|
|
|
2023-07-15 20:56:33 +00:00
|
|
|
auto* entity = Game::entityManager->GetEntity(pair.first);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (entity == nullptr) {
|
2021-12-05 17:54:36 +00:00
|
|
|
continue;
|
|
|
|
}
|
2024-05-18 09:05:55 +00:00
|
|
|
auto* modelComponent = entity->GetComponent<ModelComponent>();
|
|
|
|
if (!modelComponent) continue;
|
|
|
|
const auto modelBehaviors = modelComponent->GetBehaviorsForSave();
|
|
|
|
|
|
|
|
// save the behaviors of the model
|
|
|
|
for (const auto& [behaviorId, behaviorStr] : modelBehaviors) {
|
2024-05-18 10:36:29 +00:00
|
|
|
if (behaviorStr.empty() || behaviorId == -1 || behaviorId == 0) continue;
|
2024-05-18 09:05:55 +00:00
|
|
|
IBehaviors::Info info {
|
|
|
|
.behaviorId = behaviorId,
|
|
|
|
.characterId = character->GetID(),
|
|
|
|
.behaviorInfo = behaviorStr
|
|
|
|
};
|
|
|
|
Database::Get()->AddBehavior(info);
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
const auto position = entity->GetPosition();
|
|
|
|
const auto rotation = entity->GetRotation();
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (std::find(present.begin(), present.end(), id) == present.end()) {
|
2023-11-18 00:47:18 +00:00
|
|
|
IPropertyContents::Model model;
|
|
|
|
model.id = id;
|
|
|
|
model.lot = entity->GetLOT();
|
|
|
|
model.position = position;
|
|
|
|
model.rotation = rotation;
|
|
|
|
model.ugcId = 0;
|
2024-05-18 09:05:55 +00:00
|
|
|
for (auto i = 0; i < model.behaviors.size(); i++) {
|
|
|
|
model.behaviors[i] = modelBehaviors[i].first;
|
|
|
|
}
|
2023-11-18 00:47:18 +00:00
|
|
|
|
|
|
|
Database::Get()->InsertNewPropertyModel(propertyId, model, "Objects_" + std::to_string(model.lot) + "_name");
|
2022-07-28 13:39:57 +00:00
|
|
|
} else {
|
2024-05-18 09:05:55 +00:00
|
|
|
Database::Get()->UpdateModel(id, position, rotation, modelBehaviors);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-18 00:47:18 +00:00
|
|
|
for (auto model : present) {
|
|
|
|
if (std::find(modelIds.begin(), modelIds.end(), model.id) != modelIds.end()) {
|
2021-12-05 17:54:36 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2023-11-18 00:47:18 +00:00
|
|
|
Database::Get()->RemoveModel(model.id);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void PropertyManagementComponent::AddModel(LWOOBJID modelId, LWOOBJID spawnerId) {
|
2021-12-05 17:54:36 +00:00
|
|
|
models[modelId] = spawnerId;
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
PropertyManagementComponent* PropertyManagementComponent::Instance() {
|
2021-12-05 17:54:36 +00:00
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void PropertyManagementComponent::OnQueryPropertyData(Entity* originator, const SystemAddress& sysAddr, LWOOBJID author) {
|
2021-12-05 17:54:36 +00:00
|
|
|
if (author == LWOOBJID_EMPTY) {
|
|
|
|
author = m_Parent->GetObjectID();
|
|
|
|
}
|
|
|
|
|
2023-07-17 22:55:33 +00:00
|
|
|
const auto& worldId = Game::zoneManager->GetZone()->GetZoneID();
|
2022-07-28 13:39:57 +00:00
|
|
|
const auto zoneId = worldId.GetMapID();
|
2023-11-18 00:47:18 +00:00
|
|
|
const auto cloneId = worldId.GetCloneID();
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-10-21 23:31:55 +00:00
|
|
|
LOG("Getting property info for %d", zoneId);
|
2021-12-05 17:54:36 +00:00
|
|
|
GameMessages::PropertyDataMessage message = GameMessages::PropertyDataMessage(zoneId);
|
|
|
|
|
|
|
|
const auto isClaimed = GetOwnerId() != LWOOBJID_EMPTY;
|
|
|
|
|
|
|
|
LWOOBJID ownerId = GetOwnerId();
|
2023-11-18 00:47:18 +00:00
|
|
|
std::string ownerName;
|
|
|
|
auto charInfo = Database::Get()->GetCharacterInfo(ownerId);
|
|
|
|
if (charInfo) ownerName = charInfo->name;
|
2021-12-05 17:54:36 +00:00
|
|
|
std::string name = "";
|
|
|
|
std::string description = "";
|
|
|
|
uint64_t claimed = 0;
|
|
|
|
char privacy = 0;
|
2022-07-25 02:26:51 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
if (isClaimed) {
|
|
|
|
name = propertyName;
|
|
|
|
description = propertyDescription;
|
|
|
|
claimed = claimedTime;
|
|
|
|
privacy = static_cast<char>(this->privacyOption);
|
2022-03-31 03:33:37 +00:00
|
|
|
if (moderatorRequested) {
|
2023-11-18 00:47:18 +00:00
|
|
|
auto moderationInfo = Database::Get()->GetPropertyInfo(zoneId, cloneId);
|
|
|
|
if (moderationInfo->rejectionReason != "") {
|
2022-03-31 03:33:37 +00:00
|
|
|
moderatorRequested = false;
|
2023-11-18 00:47:18 +00:00
|
|
|
rejectionReason = moderationInfo->rejectionReason;
|
|
|
|
} else if (moderationInfo->rejectionReason == "" && moderationInfo->modApproved == 1) {
|
2022-03-31 03:33:37 +00:00
|
|
|
moderatorRequested = false;
|
|
|
|
rejectionReason = "";
|
|
|
|
} else {
|
|
|
|
moderatorRequested = true;
|
|
|
|
rejectionReason = "";
|
|
|
|
}
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
2022-03-30 06:49:04 +00:00
|
|
|
message.moderatorRequested = moderatorRequested;
|
|
|
|
message.reputation = reputation;
|
|
|
|
message.LastUpdatedTime = LastUpdatedTime;
|
2021-12-05 17:54:36 +00:00
|
|
|
message.OwnerId = ownerId;
|
|
|
|
message.OwnerName = ownerName;
|
|
|
|
message.Name = name;
|
|
|
|
message.Description = description;
|
|
|
|
message.ClaimedTime = claimed;
|
|
|
|
message.PrivacyOption = privacy;
|
2022-03-30 06:49:04 +00:00
|
|
|
message.cloneId = clone_Id;
|
|
|
|
message.rejectionReason = rejectionReason;
|
2021-12-05 17:54:36 +00:00
|
|
|
message.Paths = GetPaths();
|
|
|
|
|
|
|
|
SendDownloadPropertyData(author, message, UNASSIGNED_SYSTEM_ADDRESS);
|
2022-03-31 03:33:37 +00:00
|
|
|
// send rejection here?
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void PropertyManagementComponent::OnUse(Entity* originator) {
|
2021-12-05 17:54:36 +00:00
|
|
|
OnQueryPropertyData(originator, UNASSIGNED_SYSTEM_ADDRESS);
|
|
|
|
GameMessages::SendOpenPropertyManagment(m_Parent->GetObjectID(), originator->GetSystemAddress());
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void PropertyManagementComponent::SetOwnerId(const LWOOBJID value) {
|
2021-12-05 17:54:36 +00:00
|
|
|
owner = value;
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
const std::map<LWOOBJID, LWOOBJID>& PropertyManagementComponent::GetModels() const {
|
2021-12-05 17:54:36 +00:00
|
|
|
return models;
|
|
|
|
}
|