mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-26 07:27:18 +00:00
idek if ill keep this but yeah
This commit is contained in:
parent
8678ed03c3
commit
a37ec326b9
@ -1,6 +1,6 @@
|
|||||||
#include "PropertyEntranceComponent.h"
|
#include "PropertyEntranceComponent.h"
|
||||||
|
|
||||||
#include <CDPropertyEntranceComponentTable.h>
|
#include "CDPropertyEntranceComponentTable.h"
|
||||||
|
|
||||||
#include "Character.h"
|
#include "Character.h"
|
||||||
#include "Database.h"
|
#include "Database.h"
|
||||||
@ -16,7 +16,7 @@
|
|||||||
#include "eGameMasterLevel.h"
|
#include "eGameMasterLevel.h"
|
||||||
#include "DluAssert.h"
|
#include "DluAssert.h"
|
||||||
|
|
||||||
PropertyEntranceComponent::PropertyEntranceComponent(Entity* parent, uint32_t componentID) : Component(parent) {
|
PropertyEntranceComponent::PropertyEntranceComponent(Entity* parent, int32_t componentID) : Component(parent) {
|
||||||
this->propertyQueries.clear();
|
this->propertyQueries.clear();
|
||||||
m_ComponentId = componentID;
|
m_ComponentId = componentID;
|
||||||
}
|
}
|
||||||
@ -57,14 +57,14 @@ void PropertyEntranceComponent::OnEnterProperty(Entity* entity, uint32_t index,
|
|||||||
// Increment index once here because the first index of other player properties is 2 in the propertyQueries cache.
|
// Increment index once here because the first index of other player properties is 2 in the propertyQueries cache.
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
const auto& pair = propertyQueries.find(entity->GetObjectID());
|
const auto& cachedQuery = propertyQueries.find(entity->GetObjectID());
|
||||||
|
|
||||||
if (pair == propertyQueries.end()) {
|
if (cachedQuery == propertyQueries.end()) {
|
||||||
Game::logger->Log("PropertyEntranceComponent", "Player %llu:%s did not have a property query open", entity->GetObjectID(), entity->GetCharacter()->GetName().c_str());
|
Game::logger->Log("PropertyEntranceComponent", "Player %llu:%s did not have a property query open", entity->GetObjectID(), entity->GetCharacter()->GetName().c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& query = pair->second;
|
const auto& query = cachedQuery->second;
|
||||||
|
|
||||||
if (index >= query.size()) return;
|
if (index >= query.size()) return;
|
||||||
|
|
||||||
@ -80,11 +80,25 @@ void PropertyEntranceComponent::OnEnterProperty(Entity* entity, uint32_t index,
|
|||||||
launcher->Launch(entity, launcher->GetTargetZone(), cloneId);
|
launcher->Launch(entity, launcher->GetTargetZone(), cloneId);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string PropertyEntranceComponent::BuildQuery(Entity* entity, int32_t sortMethod, Character* character, std::string customQuery, bool wantLimits) {
|
std::string PropertyEntranceComponent::BuildQuery(const ePropertySortType sortMethod, Character* character, const std::string& customQuery, const bool wantLimits) {
|
||||||
|
const std::string baseQueryForProperties =
|
||||||
|
R"QUERY(
|
||||||
|
SELECT p.*
|
||||||
|
FROM properties as p
|
||||||
|
JOIN charinfo as ci
|
||||||
|
ON ci.prop_clone_id = p.clone_id
|
||||||
|
WHERE p.zone_id = ?
|
||||||
|
AND (
|
||||||
|
p.description LIKE ?
|
||||||
|
OR p.name LIKE ?
|
||||||
|
OR ci.name LIKE ?
|
||||||
|
)
|
||||||
|
AND p.privacy_option >= ?
|
||||||
|
)QUERY";
|
||||||
DluAssert(character != nullptr);
|
DluAssert(character != nullptr);
|
||||||
std::string base = customQuery.empty() ? baseQueryForProperties : customQuery;
|
const std::string base = customQuery.empty() ? baseQueryForProperties : customQuery;
|
||||||
std::string orderBy;
|
std::string orderBy = "ORDER BY p.last_updated DESC";
|
||||||
if (sortMethod == SORT_TYPE_FEATURED || sortMethod == SORT_TYPE_FRIENDS) {
|
if (sortMethod == ePropertySortType::SORT_TYPE_FEATURED || sortMethod == ePropertySortType::SORT_TYPE_FRIENDS) {
|
||||||
std::stringstream friendsStream;
|
std::stringstream friendsStream;
|
||||||
friendsStream << " AND p.owner_id IN (";
|
friendsStream << " AND p.owner_id IN (";
|
||||||
|
|
||||||
@ -98,32 +112,28 @@ std::string PropertyEntranceComponent::BuildQuery(Entity* entity, int32_t sortMe
|
|||||||
std::unique_ptr<sql::ResultSet> friendsListQueryResult(friendsListQuery->executeQuery());
|
std::unique_ptr<sql::ResultSet> friendsListQueryResult(friendsListQuery->executeQuery());
|
||||||
|
|
||||||
if (friendsListQueryResult->next()) {
|
if (friendsListQueryResult->next()) {
|
||||||
friendsStream << friendsListQueryResult->getInt(1);
|
friendsStream << friendsListQueryResult->getInt("requested_player");
|
||||||
while (friendsListQueryResult->next()) {
|
while (friendsListQueryResult->next()) {
|
||||||
friendsStream << ',' << friendsListQueryResult->getInt(1);
|
friendsStream << ',' << friendsListQueryResult->getInt("requested_player");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Replace trailing comma with the closing parenthesis.
|
|
||||||
|
|
||||||
// If we have no friends then use a -1 for the query.
|
// If we have no friends then use a -1 for the query.
|
||||||
if (friendsListQueryResult->rowsCount() == 0) friendsStream << -1;
|
if (friendsListQueryResult->rowsCount() == 0) friendsStream << -1;
|
||||||
friendsStream << ')';
|
friendsStream << ')';
|
||||||
|
|
||||||
orderBy += friendsStream.str() + " ORDER BY ci.name ASC";
|
orderBy += friendsStream.str() + " ORDER BY ci.name ASC";
|
||||||
|
} else if (sortMethod == ePropertySortType::SORT_TYPE_RECENT) {
|
||||||
} else if (sortMethod == SORT_TYPE_RECENT) {
|
|
||||||
orderBy = "ORDER BY p.last_updated DESC";
|
orderBy = "ORDER BY p.last_updated DESC";
|
||||||
} else if (sortMethod == SORT_TYPE_REPUTATION) {
|
} else if (sortMethod == ePropertySortType::SORT_TYPE_REPUTATION) {
|
||||||
orderBy = "ORDER BY p.reputation DESC, p.last_updated DESC";
|
orderBy = "ORDER BY p.reputation DESC, p.last_updated DESC";
|
||||||
} else {
|
|
||||||
orderBy = "ORDER BY p.last_updated DESC";
|
|
||||||
}
|
}
|
||||||
return base + orderBy + (wantLimits ? " LIMIT ? OFFSET ?;" : " ;");
|
return base + orderBy + (wantLimits ? " LIMIT ? OFFSET ?;" : " ;");
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool includeNullAddress, bool includeNullDescription, bool playerOwn, bool updateUi, int32_t numResults, int32_t lReputationTime, int32_t sortMethod, int32_t startIndex, std::string filterText, const SystemAddress& sysAddr) {
|
void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool includeNullAddress, bool includeNullDescription, bool playerOwn, bool updateUi, int32_t numResults, int32_t lReputationTime, ePropertySortType sortMethod, int32_t startIndex, std::string filterText, const SystemAddress& sysAddr) {
|
||||||
std::vector<PropertySelectQueryProperty> entries;
|
std::vector<PropertySelectQueryProperty> propertyPageEntries;
|
||||||
PropertySelectQueryProperty playerEntry;
|
PropertySelectQueryProperty requestorEntry;
|
||||||
|
|
||||||
auto character = entity->GetCharacter();
|
auto character = entity->GetCharacter();
|
||||||
if (!character) return;
|
if (!character) return;
|
||||||
@ -139,42 +149,39 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl
|
|||||||
std::unique_ptr<sql::ResultSet> playerPropertyLookupResults(playerPropertyLookup->executeQuery());
|
std::unique_ptr<sql::ResultSet> playerPropertyLookupResults(playerPropertyLookup->executeQuery());
|
||||||
|
|
||||||
// If the player has a property this query will have a single result.
|
// If the player has a property this query will have a single result.
|
||||||
|
requestorEntry.CloneId = character->GetPropertyCloneID();
|
||||||
|
requestorEntry.OwnerName = character->GetName();
|
||||||
if (playerPropertyLookupResults->next()) {
|
if (playerPropertyLookupResults->next()) {
|
||||||
playerEntry.CloneId = playerPropertyLookupResults->getUInt64(4);;
|
requestorEntry.Name = std::string(playerPropertyLookupResults->getString("name").c_str());
|
||||||
playerEntry.OwnerName = character->GetName();
|
requestorEntry.Description = std::string(playerPropertyLookupResults->getString("description").c_str());
|
||||||
playerEntry.Name = playerPropertyLookupResults->getString(5).c_str();
|
requestorEntry.Reputation = playerPropertyLookupResults->getUInt("reputation");
|
||||||
playerEntry.Description = playerPropertyLookupResults->getString(6).c_str();
|
requestorEntry.IsBestFriend = true;
|
||||||
playerEntry.Reputation = playerPropertyLookupResults->getUInt(14);
|
requestorEntry.IsFriend = true;
|
||||||
playerEntry.IsBestFriend = true;
|
requestorEntry.IsModeratorApproved = playerPropertyLookupResults->getBoolean("mod_approved");
|
||||||
playerEntry.IsFriend = true;
|
requestorEntry.IsAlt = true;
|
||||||
playerEntry.IsModeratorApproved = playerPropertyLookupResults->getBoolean(10);
|
requestorEntry.IsOwned = true;
|
||||||
playerEntry.IsAlt = true;
|
requestorEntry.AccessType = playerPropertyLookupResults->getInt("privacy_option");
|
||||||
playerEntry.IsOwned = true;
|
requestorEntry.DateLastPublished = playerPropertyLookupResults->getInt64("last_updated");
|
||||||
playerEntry.AccessType = playerPropertyLookupResults->getInt(9);
|
requestorEntry.PerformanceCost = playerPropertyLookupResults->getDouble("performance_cost");
|
||||||
playerEntry.DateLastPublished = playerPropertyLookupResults->getInt64(11);
|
|
||||||
playerEntry.PerformanceCost = playerPropertyLookupResults->getDouble(16);
|
|
||||||
} else {
|
|
||||||
playerEntry.CloneId = character->GetPropertyCloneID();
|
|
||||||
playerEntry.OwnerName = character->GetName();
|
|
||||||
playerEntry.Description.clear();
|
|
||||||
playerEntry.Name.clear();
|
|
||||||
playerEntry.Reputation = 0.0f;
|
|
||||||
playerEntry.IsBestFriend = true;
|
|
||||||
playerEntry.IsFriend = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
entries.push_back(playerEntry);
|
propertyPageEntries.push_back(requestorEntry);
|
||||||
|
|
||||||
const auto query = BuildQuery(entity, sortMethod, character);
|
const auto query = BuildQuery(sortMethod, character);
|
||||||
|
|
||||||
std::unique_ptr<sql::PreparedStatement> propertyLookup(Database::CreatePreppedStmt(query));
|
std::unique_ptr<sql::PreparedStatement> propertyLookup(Database::CreatePreppedStmt(query));
|
||||||
|
|
||||||
const auto searchString = "%" + filterText + "%";
|
const auto searchString = "%" + filterText + "%";
|
||||||
|
PropertyPrivacyOption friendsLookup =
|
||||||
|
sortMethod == ePropertySortType::SORT_TYPE_FEATURED || sortMethod == ePropertySortType::SORT_TYPE_FRIENDS ?
|
||||||
|
PropertyPrivacyOption::Friends :
|
||||||
|
PropertyPrivacyOption::Public;
|
||||||
|
|
||||||
propertyLookup->setUInt(1, this->m_MapID);
|
propertyLookup->setUInt(1, this->m_MapID);
|
||||||
propertyLookup->setString(2, searchString.c_str());
|
propertyLookup->setString(2, searchString.c_str());
|
||||||
propertyLookup->setString(3, searchString.c_str());
|
propertyLookup->setString(3, searchString.c_str());
|
||||||
propertyLookup->setString(4, searchString.c_str());
|
propertyLookup->setString(4, searchString.c_str());
|
||||||
propertyLookup->setInt(5, sortMethod == SORT_TYPE_FEATURED || sortMethod == SORT_TYPE_FRIENDS ? (uint32_t)PropertyPrivacyOption::Friends : (uint32_t)PropertyPrivacyOption::Public);
|
propertyLookup->setInt(5, static_cast<uint32_t>(friendsLookup));
|
||||||
propertyLookup->setInt(6, numResults);
|
propertyLookup->setInt(6, numResults);
|
||||||
propertyLookup->setInt(7, startIndex);
|
propertyLookup->setInt(7, startIndex);
|
||||||
|
|
||||||
@ -182,15 +189,15 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl
|
|||||||
|
|
||||||
while (propertyEntry->next()) {
|
while (propertyEntry->next()) {
|
||||||
PropertySelectQueryProperty playerPropertyEntry;
|
PropertySelectQueryProperty playerPropertyEntry;
|
||||||
const auto owner = propertyEntry->getInt(2);
|
const auto owner = propertyEntry->getInt("owner_id");
|
||||||
playerPropertyEntry.CloneId = propertyEntry->getUInt64(4);
|
playerPropertyEntry.CloneId = propertyEntry->getUInt64("clone_id");
|
||||||
playerPropertyEntry.Name = std::string(propertyEntry->getString(5).c_str());
|
playerPropertyEntry.Name = std::string(propertyEntry->getString("name").c_str());
|
||||||
playerPropertyEntry.Description = std::string(propertyEntry->getString(6).c_str());
|
playerPropertyEntry.Description = std::string(propertyEntry->getString("description").c_str());
|
||||||
playerPropertyEntry.AccessType = propertyEntry->getInt(9);
|
playerPropertyEntry.AccessType = propertyEntry->getInt("privacy_option");
|
||||||
playerPropertyEntry.IsModeratorApproved = propertyEntry->getBoolean(10);
|
playerPropertyEntry.IsModeratorApproved = propertyEntry->getBoolean("mod_approved");
|
||||||
playerPropertyEntry.DateLastPublished = propertyEntry->getInt(11);
|
playerPropertyEntry.DateLastPublished = propertyEntry->getInt("last_updated");
|
||||||
playerPropertyEntry.Reputation = static_cast<float>(propertyEntry->getInt(14));
|
playerPropertyEntry.Reputation = static_cast<float>(propertyEntry->getInt("reputation"));
|
||||||
playerPropertyEntry.PerformanceCost = static_cast<float>(propertyEntry->getDouble(16));
|
playerPropertyEntry.PerformanceCost = static_cast<float>(propertyEntry->getDouble("performance_cost"));
|
||||||
playerPropertyEntry.OwnerName = "";
|
playerPropertyEntry.OwnerName = "";
|
||||||
playerPropertyEntry.IsBestFriend = false;
|
playerPropertyEntry.IsBestFriend = false;
|
||||||
playerPropertyEntry.IsFriend = false;
|
playerPropertyEntry.IsFriend = false;
|
||||||
@ -209,7 +216,7 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
playerPropertyEntry.IsOwned = playerPropertyEntry.CloneId == character->GetPropertyCloneID();
|
playerPropertyEntry.IsOwned = playerPropertyEntry.CloneId == character->GetPropertyCloneID();
|
||||||
playerPropertyEntry.OwnerName = std::string(nameResult->getString(1).c_str());
|
playerPropertyEntry.OwnerName = std::string(nameResult->getString("name").c_str());
|
||||||
|
|
||||||
// Query to get friend and best friend fields
|
// Query to get friend and best friend fields
|
||||||
std::unique_ptr<sql::PreparedStatement> friendCheck(
|
std::unique_ptr<sql::PreparedStatement> friendCheck(
|
||||||
@ -225,9 +232,9 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl
|
|||||||
|
|
||||||
// If we got a result than the two players are friends.
|
// If we got a result than the two players are friends.
|
||||||
playerPropertyEntry.IsFriend = friendResult->next();
|
playerPropertyEntry.IsFriend = friendResult->next();
|
||||||
playerPropertyEntry.IsBestFriend = playerPropertyEntry.IsFriend && friendResult->getInt(1) == 3;
|
playerPropertyEntry.IsBestFriend = playerPropertyEntry.IsFriend && friendResult->getInt("best_friend") == 3;
|
||||||
|
|
||||||
playerPropertyEntry.IsModeratorApproved = propertyEntry->getBoolean(10);
|
playerPropertyEntry.IsModeratorApproved = propertyEntry->getBoolean("mod_approved");
|
||||||
|
|
||||||
// So lead moderators can visit the property but also see that it is still awaiting approval.
|
// So lead moderators can visit the property but also see that it is still awaiting approval.
|
||||||
if (!playerPropertyEntry.IsModeratorApproved && entity->GetGMLevel() >= eGameMasterLevel::LEAD_MODERATOR) {
|
if (!playerPropertyEntry.IsModeratorApproved && entity->GetGMLevel() >= eGameMasterLevel::LEAD_MODERATOR) {
|
||||||
@ -248,23 +255,38 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl
|
|||||||
|
|
||||||
if (isAltQueryResults->next()) playerPropertyEntry.IsAlt = true;
|
if (isAltQueryResults->next()) playerPropertyEntry.IsAlt = true;
|
||||||
|
|
||||||
entries.push_back(playerPropertyEntry);
|
propertyPageEntries.push_back(playerPropertyEntry);
|
||||||
}
|
}
|
||||||
propertyQueries[entity->GetObjectID()] = entries;
|
propertyQueries[entity->GetObjectID()] = propertyPageEntries;
|
||||||
|
|
||||||
// Query here is to figure out whether or not to display the button to go to the next page or not.
|
// Query here is to figure out whether or not to display the button to go to the next page or not.
|
||||||
auto buttonQuery = BuildQuery(entity, sortMethod, character, "SELECT COUNT(*) as numProperties FROM properties as p JOIN charinfo as ci ON ci.prop_clone_id = p.clone_id where p.zone_id = ? AND (p.description LIKE ? OR p.name LIKE ? OR ci.name LIKE ?) AND p.privacy_option >= ? ", false);
|
const std::string baseButtonQuery =
|
||||||
|
R"QUERY(
|
||||||
|
SELECT COUNT(*) as numProperties
|
||||||
|
FROM properties as p
|
||||||
|
JOIN charinfo as ci
|
||||||
|
ON ci.prop_clone_id = p.clone_id
|
||||||
|
WHERE p.zone_id = ?
|
||||||
|
AND (
|
||||||
|
p.description LIKE ?
|
||||||
|
OR p.name LIKE ?
|
||||||
|
OR ci.name LIKE ?
|
||||||
|
)
|
||||||
|
AND p.privacy_option >= ?
|
||||||
|
)QUERY";
|
||||||
|
|
||||||
|
auto buttonQuery = BuildQuery(sortMethod, character, baseButtonQuery, false);
|
||||||
std::unique_ptr<sql::PreparedStatement> propertiesLeft(Database::CreatePreppedStmt(buttonQuery));
|
std::unique_ptr<sql::PreparedStatement> propertiesLeft(Database::CreatePreppedStmt(buttonQuery));
|
||||||
|
|
||||||
propertiesLeft->setUInt(1, this->m_MapID);
|
propertiesLeft->setUInt(1, this->m_MapID);
|
||||||
propertiesLeft->setString(2, searchString.c_str());
|
propertiesLeft->setString(2, searchString.c_str());
|
||||||
propertiesLeft->setString(3, searchString.c_str());
|
propertiesLeft->setString(3, searchString.c_str());
|
||||||
propertiesLeft->setString(4, searchString.c_str());
|
propertiesLeft->setString(4, searchString.c_str());
|
||||||
propertiesLeft->setInt(5, sortMethod == SORT_TYPE_FEATURED || sortMethod == SORT_TYPE_FRIENDS ? 1 : 2);
|
propertiesLeft->setInt(5, static_cast<uint32_t>(friendsLookup));
|
||||||
|
|
||||||
std::unique_ptr<sql::ResultSet> result(propertiesLeft->executeQuery());
|
std::unique_ptr<sql::ResultSet> result(propertiesLeft->executeQuery());
|
||||||
result->next();
|
result->next();
|
||||||
int32_t numberOfProperties = result->getInt("numProperties");
|
int32_t numberOfProperties = result->getInt("numProperties");
|
||||||
|
|
||||||
GameMessages::SendPropertySelectQuery(m_ParentEntity->GetObjectID(), startIndex, numberOfProperties - (startIndex + numResults) > 0, character->GetPropertyCloneID(), false, true, entries, sysAddr);
|
GameMessages::SendPropertySelectQuery(m_ParentEntity->GetObjectID(), startIndex, numberOfProperties - (startIndex + numResults) > 0, character->GetPropertyCloneID(), false, true, propertyPageEntries, sysAddr);
|
||||||
}
|
}
|
||||||
|
@ -6,13 +6,20 @@
|
|||||||
#include "eReplicaComponentType.h"
|
#include "eReplicaComponentType.h"
|
||||||
#include "PropertySelectQueryProperty.h"
|
#include "PropertySelectQueryProperty.h"
|
||||||
|
|
||||||
|
enum class ePropertySortType : int32_t {
|
||||||
|
SORT_TYPE_FRIENDS = 0,
|
||||||
|
SORT_TYPE_REPUTATION = 1,
|
||||||
|
SORT_TYPE_RECENT = 3,
|
||||||
|
SORT_TYPE_FEATURED = 5
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the launch pad that's used to select and browse properties
|
* Represents the launch pad that's used to select and browse properties
|
||||||
*/
|
*/
|
||||||
class PropertyEntranceComponent : public Component {
|
class PropertyEntranceComponent final : public Component {
|
||||||
public:
|
public:
|
||||||
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::PROPERTY_ENTRANCE;
|
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::PROPERTY_ENTRANCE;
|
||||||
explicit PropertyEntranceComponent(Entity* parent, uint32_t componentID);
|
explicit PropertyEntranceComponent(Entity* parent, int32_t componentID);
|
||||||
|
|
||||||
void LoadTemplateData() override;
|
void LoadTemplateData() override;
|
||||||
|
|
||||||
@ -45,7 +52,7 @@ public:
|
|||||||
* @param filterText property names to search for
|
* @param filterText property names to search for
|
||||||
* @param sysAddr the address to send gamemessage responses to
|
* @param sysAddr the address to send gamemessage responses to
|
||||||
*/
|
*/
|
||||||
void OnPropertyEntranceSync(Entity* entity, bool includeNullAddress, bool includeNullDescription, bool playerOwn, bool updateUi, int32_t numResults, int32_t lReputationTime, int32_t sortMethod, int32_t startIndex, std::string filterText, const SystemAddress& sysAddr);
|
void OnPropertyEntranceSync(Entity* entity, bool includeNullAddress, bool includeNullDescription, bool playerOwn, bool updateUi, int32_t numResults, int32_t lReputationTime, ePropertySortType sortMethod, int32_t startIndex, std::string filterText, const SystemAddress& sysAddr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of this property
|
* Returns the name of this property
|
||||||
@ -59,7 +66,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
[[nodiscard]] LWOMAPID GetMapID() const { return m_MapID; };
|
[[nodiscard]] LWOMAPID GetMapID() const { return m_MapID; };
|
||||||
|
|
||||||
std::string BuildQuery(Entity* entity, int32_t sortMethod, Character* character, std::string customQuery = "", bool wantLimits = true);
|
[[nodiscard]] static std::string BuildQuery(const ePropertySortType sortMethod, Character* character, const std::string& customQuery = "", const bool wantLimits = true);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
@ -77,14 +84,5 @@ private:
|
|||||||
*/
|
*/
|
||||||
LWOMAPID m_MapID;
|
LWOMAPID m_MapID;
|
||||||
|
|
||||||
enum ePropertySortType : int32_t {
|
|
||||||
SORT_TYPE_FRIENDS = 0,
|
|
||||||
SORT_TYPE_REPUTATION = 1,
|
|
||||||
SORT_TYPE_RECENT = 3,
|
|
||||||
SORT_TYPE_FEATURED = 5
|
|
||||||
};
|
|
||||||
|
|
||||||
std::string baseQueryForProperties = "SELECT p.* FROM properties as p JOIN charinfo as ci ON ci.prop_clone_id = p.clone_id where p.zone_id = ? AND (p.description LIKE ? OR p.name LIKE ? OR ci.name LIKE ?) AND p.privacy_option >= ? ";
|
|
||||||
|
|
||||||
int32_t m_ComponentId = -1;
|
int32_t m_ComponentId = -1;
|
||||||
};
|
};
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
/**
|
/**
|
||||||
* Information regarding which players may visit this property
|
* Information regarding which players may visit this property
|
||||||
*/
|
*/
|
||||||
enum class PropertyPrivacyOption
|
enum class PropertyPrivacyOption : uint32_t
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Default, only you can visit your property
|
* Default, only you can visit your property
|
||||||
|
@ -2752,7 +2752,7 @@ void GameMessages::HandlePropertyEntranceSync(RakNet::BitStream* inStream, Entit
|
|||||||
bool updateUi{};
|
bool updateUi{};
|
||||||
int32_t numResults{};
|
int32_t numResults{};
|
||||||
int32_t reputation{};
|
int32_t reputation{};
|
||||||
int32_t sortMethod{};
|
ePropertySortType sortMethod{};
|
||||||
int32_t startIndex{};
|
int32_t startIndex{};
|
||||||
uint32_t filterTextLength{};
|
uint32_t filterTextLength{};
|
||||||
std::string filterText{};
|
std::string filterText{};
|
||||||
@ -2769,15 +2769,14 @@ void GameMessages::HandlePropertyEntranceSync(RakNet::BitStream* inStream, Entit
|
|||||||
|
|
||||||
for (auto i = 0u; i < filterTextLength; i++) {
|
for (auto i = 0u; i < filterTextLength; i++) {
|
||||||
char c;
|
char c;
|
||||||
inStream->Read(c);
|
if (inStream->Read(c)) filterText.push_back(c);
|
||||||
filterText.push_back(c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* player = Player::GetPlayer(sysAddr);
|
auto* player = Player::GetPlayer(sysAddr);
|
||||||
|
|
||||||
auto* entranceComponent = entity->GetComponent<PropertyEntranceComponent>();
|
auto* entranceComponent = entity->GetComponent<PropertyEntranceComponent>();
|
||||||
|
|
||||||
if (entranceComponent == nullptr) return;
|
if (!entranceComponent) return;
|
||||||
|
|
||||||
entranceComponent->OnPropertyEntranceSync(player,
|
entranceComponent->OnPropertyEntranceSync(player,
|
||||||
includeNullAddress,
|
includeNullAddress,
|
||||||
|
@ -3,22 +3,19 @@
|
|||||||
void PropertySelectQueryProperty::Serialize(RakNet::BitStream& stream) const {
|
void PropertySelectQueryProperty::Serialize(RakNet::BitStream& stream) const {
|
||||||
stream.Write(CloneId);
|
stream.Write(CloneId);
|
||||||
|
|
||||||
const auto& owner = GeneralUtils::UTF8ToUTF16(OwnerName);
|
stream.Write<uint32_t>(OwnerName.size());
|
||||||
stream.Write(uint32_t(owner.size()));
|
for (const auto& c : OwnerName) {
|
||||||
for (uint32_t i = 0; i < owner.size(); ++i) {
|
stream.Write<uint16_t>(c);
|
||||||
stream.Write(static_cast<uint16_t>(owner[i]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& name = GeneralUtils::UTF8ToUTF16(Name);
|
stream.Write<uint32_t>(Name.size());
|
||||||
stream.Write(uint32_t(name.size()));
|
for (const auto& c : Name) {
|
||||||
for (uint32_t i = 0; i < name.size(); ++i) {
|
stream.Write<uint16_t>(c);
|
||||||
stream.Write(static_cast<uint16_t>(name[i]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& description = GeneralUtils::UTF8ToUTF16(Description);
|
stream.Write<uint32_t>(Description.size());
|
||||||
stream.Write(uint32_t(description.size()));
|
for (const auto& c : Description) {
|
||||||
for (uint32_t i = 0; i < description.size(); ++i) {
|
stream.Write<uint16_t>(c);
|
||||||
stream.Write(static_cast<uint16_t>(description[i]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stream.Write(Reputation);
|
stream.Write(Reputation);
|
||||||
@ -32,7 +29,3 @@ void PropertySelectQueryProperty::Serialize(RakNet::BitStream& stream) const {
|
|||||||
stream.Write(PerformanceIndex);
|
stream.Write(PerformanceIndex);
|
||||||
stream.Write(PerformanceCost);
|
stream.Write(PerformanceCost);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertySelectQueryProperty::Deserialize(RakNet::BitStream& stream) const {
|
|
||||||
// Do we need this?
|
|
||||||
}
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifndef PROPERTYSELECTQUERY_H
|
#ifndef __PROPERTYSELECTQUERY_H__
|
||||||
#define PROPERTYSELECTQUERY_H
|
#define __PROPERTYSELECTQUERY_H__
|
||||||
|
|
||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
|
|
||||||
@ -10,12 +10,10 @@ class PropertySelectQueryProperty final
|
|||||||
public:
|
public:
|
||||||
void Serialize(RakNet::BitStream& stream) const;
|
void Serialize(RakNet::BitStream& stream) const;
|
||||||
|
|
||||||
void Deserialize(RakNet::BitStream& stream) const;
|
|
||||||
|
|
||||||
LWOCLONEID CloneId = LWOCLONEID_INVALID; // The cloneID of the property
|
LWOCLONEID CloneId = LWOCLONEID_INVALID; // The cloneID of the property
|
||||||
std::string OwnerName = ""; // The property owners name
|
std::string OwnerName; // The property owners name
|
||||||
std::string Name = ""; // The property name
|
std::string Name; // The property name
|
||||||
std::string Description = ""; // The property description
|
std::string Description; // The property description
|
||||||
float Reputation = 0; // The reputation of the property
|
float Reputation = 0; // The reputation of the property
|
||||||
bool IsBestFriend = false; // Whether or not the property belongs to a best friend
|
bool IsBestFriend = false; // Whether or not the property belongs to a best friend
|
||||||
bool IsFriend = false; // Whether or not the property belongs to a friend
|
bool IsFriend = false; // Whether or not the property belongs to a friend
|
||||||
@ -28,4 +26,4 @@ public:
|
|||||||
uint32_t PerformanceIndex = 0; // The performance index of the property? Always 0?
|
uint32_t PerformanceIndex = 0; // The performance index of the property? Always 0?
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // __PROPERTYSELECTQUERY_H__
|
||||||
|
Loading…
Reference in New Issue
Block a user