mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-30 01:41:40 +00:00
fix(property): the property search honours bIncludeNullAddress and bIncludeNullDescription
LWOPropertyEntranceComponent::onRequestPropertyInfo sets the two flags of PropertyEntranceSync when the search text is part of the map's default property name / description, which the client shows for a property that has none of its own. Both were read and ignored, so a property without a name or description was never found by the text the player sees on it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -34,6 +34,9 @@ public:
|
||||
uint32_t numResults{};
|
||||
uint32_t startIndex{};
|
||||
uint32_t playerSort{};
|
||||
// Also match properties with no name / no description of their own, whatever the search text
|
||||
bool includeNullName{};
|
||||
bool includeNullDescription{};
|
||||
};
|
||||
|
||||
struct PropertyEntranceResult {
|
||||
|
||||
@@ -25,6 +25,11 @@ IProperty::PropertyEntranceResult MySQLDatabase::GetProperties(const IProperty::
|
||||
std::string query;
|
||||
PreparedStmtResultSet properties;
|
||||
|
||||
// The client sets these when the search text is part of the map's default property name / description, which it
|
||||
// shows for a property with none of its own (LWOPropertyEntranceComponent::onRequestPropertyInfo)
|
||||
const uint32_t includeNullName = params.includeNullName ? 1 : 0;
|
||||
const uint32_t includeNullDescription = params.includeNullDescription ? 1 : 0;
|
||||
|
||||
if (params.sortChoice == SORT_TYPE_FEATURED || params.sortChoice == SORT_TYPE_FRIENDS) {
|
||||
query = R"QUERY(
|
||||
FROM properties as p
|
||||
@@ -35,6 +40,8 @@ IProperty::PropertyEntranceResult MySQLDatabase::GetProperties(const IProperty::
|
||||
p.description LIKE ?
|
||||
OR p.name LIKE ?
|
||||
OR ci.name LIKE ?
|
||||
OR (? != 0 AND p.name = '')
|
||||
OR (? != 0 AND p.description = '')
|
||||
)
|
||||
AND p.privacy_option >= ?
|
||||
AND (
|
||||
@@ -62,6 +69,8 @@ IProperty::PropertyEntranceResult MySQLDatabase::GetProperties(const IProperty::
|
||||
"%" + params.searchString + "%",
|
||||
"%" + params.searchString + "%",
|
||||
"%" + params.searchString + "%",
|
||||
includeNullName,
|
||||
includeNullDescription,
|
||||
params.playerSort,
|
||||
params.playerId,
|
||||
params.playerId,
|
||||
@@ -78,6 +87,8 @@ IProperty::PropertyEntranceResult MySQLDatabase::GetProperties(const IProperty::
|
||||
"%" + params.searchString + "%",
|
||||
"%" + params.searchString + "%",
|
||||
"%" + params.searchString + "%",
|
||||
includeNullName,
|
||||
includeNullDescription,
|
||||
params.playerSort,
|
||||
params.playerId,
|
||||
params.playerId,
|
||||
@@ -99,6 +110,8 @@ IProperty::PropertyEntranceResult MySQLDatabase::GetProperties(const IProperty::
|
||||
p.description LIKE ?
|
||||
OR p.name LIKE ?
|
||||
OR ci.name LIKE ?
|
||||
OR (? != 0 AND p.name = '')
|
||||
OR (? != 0 AND p.description = '')
|
||||
)
|
||||
AND p.privacy_option >= ?
|
||||
ORDER BY p.reputation DESC, p.last_updated DESC
|
||||
@@ -113,6 +126,8 @@ IProperty::PropertyEntranceResult MySQLDatabase::GetProperties(const IProperty::
|
||||
p.description LIKE ?
|
||||
OR p.name LIKE ?
|
||||
OR ci.name LIKE ?
|
||||
OR (? != 0 AND p.name = '')
|
||||
OR (? != 0 AND p.description = '')
|
||||
)
|
||||
AND p.privacy_option >= ?
|
||||
ORDER BY p.last_updated DESC
|
||||
@@ -125,6 +140,8 @@ IProperty::PropertyEntranceResult MySQLDatabase::GetProperties(const IProperty::
|
||||
"%" + params.searchString + "%",
|
||||
"%" + params.searchString + "%",
|
||||
"%" + params.searchString + "%",
|
||||
includeNullName,
|
||||
includeNullDescription,
|
||||
params.playerSort,
|
||||
params.numResults,
|
||||
params.startIndex
|
||||
@@ -136,6 +153,8 @@ IProperty::PropertyEntranceResult MySQLDatabase::GetProperties(const IProperty::
|
||||
"%" + params.searchString + "%",
|
||||
"%" + params.searchString + "%",
|
||||
"%" + params.searchString + "%",
|
||||
includeNullName,
|
||||
includeNullDescription,
|
||||
params.playerSort
|
||||
);
|
||||
if (count->next()) {
|
||||
|
||||
@@ -25,6 +25,11 @@ IProperty::PropertyEntranceResult SQLiteDatabase::GetProperties(const IProperty:
|
||||
std::string query;
|
||||
std::pair<CppSQLite3Statement, CppSQLite3Query> propertiesRes;
|
||||
|
||||
// The client sets these when the search text is part of the map's default property name / description, which it
|
||||
// shows for a property with none of its own (LWOPropertyEntranceComponent::onRequestPropertyInfo)
|
||||
const uint32_t includeNullName = params.includeNullName ? 1 : 0;
|
||||
const uint32_t includeNullDescription = params.includeNullDescription ? 1 : 0;
|
||||
|
||||
if (params.sortChoice == SORT_TYPE_FEATURED || params.sortChoice == SORT_TYPE_FRIENDS) {
|
||||
query = R"QUERY(
|
||||
FROM properties as p
|
||||
@@ -35,6 +40,8 @@ IProperty::PropertyEntranceResult SQLiteDatabase::GetProperties(const IProperty:
|
||||
p.description LIKE ?
|
||||
OR p.name LIKE ?
|
||||
OR ci.name LIKE ?
|
||||
OR (? != 0 AND p.name = '')
|
||||
OR (? != 0 AND p.description = '')
|
||||
)
|
||||
AND p.privacy_option >= ?
|
||||
AND (
|
||||
@@ -62,6 +69,8 @@ IProperty::PropertyEntranceResult SQLiteDatabase::GetProperties(const IProperty:
|
||||
"%" + params.searchString + "%",
|
||||
"%" + params.searchString + "%",
|
||||
"%" + params.searchString + "%",
|
||||
includeNullName,
|
||||
includeNullDescription,
|
||||
params.playerSort,
|
||||
params.playerId,
|
||||
params.playerId,
|
||||
@@ -78,6 +87,8 @@ IProperty::PropertyEntranceResult SQLiteDatabase::GetProperties(const IProperty:
|
||||
"%" + params.searchString + "%",
|
||||
"%" + params.searchString + "%",
|
||||
"%" + params.searchString + "%",
|
||||
includeNullName,
|
||||
includeNullDescription,
|
||||
params.playerSort,
|
||||
params.playerId,
|
||||
params.playerId,
|
||||
@@ -99,6 +110,8 @@ IProperty::PropertyEntranceResult SQLiteDatabase::GetProperties(const IProperty:
|
||||
p.description LIKE ?
|
||||
OR p.name LIKE ?
|
||||
OR ci.name LIKE ?
|
||||
OR (? != 0 AND p.name = '')
|
||||
OR (? != 0 AND p.description = '')
|
||||
)
|
||||
AND p.privacy_option >= ?
|
||||
ORDER BY p.reputation DESC, p.last_updated DESC
|
||||
@@ -113,6 +126,8 @@ IProperty::PropertyEntranceResult SQLiteDatabase::GetProperties(const IProperty:
|
||||
p.description LIKE ?
|
||||
OR p.name LIKE ?
|
||||
OR ci.name LIKE ?
|
||||
OR (? != 0 AND p.name = '')
|
||||
OR (? != 0 AND p.description = '')
|
||||
)
|
||||
AND p.privacy_option >= ?
|
||||
ORDER BY p.last_updated DESC
|
||||
@@ -125,6 +140,8 @@ IProperty::PropertyEntranceResult SQLiteDatabase::GetProperties(const IProperty:
|
||||
"%" + params.searchString + "%",
|
||||
"%" + params.searchString + "%",
|
||||
"%" + params.searchString + "%",
|
||||
includeNullName,
|
||||
includeNullDescription,
|
||||
params.playerSort,
|
||||
params.numResults,
|
||||
params.startIndex
|
||||
@@ -136,6 +153,8 @@ IProperty::PropertyEntranceResult SQLiteDatabase::GetProperties(const IProperty:
|
||||
"%" + params.searchString + "%",
|
||||
"%" + params.searchString + "%",
|
||||
"%" + params.searchString + "%",
|
||||
includeNullName,
|
||||
includeNullDescription,
|
||||
params.playerSort
|
||||
);
|
||||
if (!count.eof()) {
|
||||
|
||||
@@ -154,6 +154,8 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl
|
||||
IProperty::PropertyLookup propertyLookup;
|
||||
propertyLookup.mapId = m_MapID;
|
||||
propertyLookup.searchString = filterText;
|
||||
propertyLookup.includeNullName = includeNullAddress;
|
||||
propertyLookup.includeNullDescription = includeNullDescription;
|
||||
propertyLookup.sortChoice = static_cast<ePropertySortType>(sortMethod);
|
||||
// Live listed every property of the player's friends and of the account's other characters in the friends list,
|
||||
// whatever its access type (64 friend entries with accessType 0 in the captured replies); the client locks the
|
||||
|
||||
@@ -107,3 +107,30 @@ TEST_F(PropertyListSqlite, PublicListsHoldPublicPropertiesOnly) {
|
||||
EXPECT_EQ(Owners(db->GetProperties(Lookup(SORT_TYPE_RECENT, 2))), (std::set<LWOOBJID>{ P_CAROL, P_DAVE }));
|
||||
EXPECT_EQ(Owners(db->GetProperties(Lookup(SORT_TYPE_REPUTATION, 2))), (std::set<LWOOBJID>{ P_CAROL, P_DAVE }));
|
||||
}
|
||||
|
||||
// The client shows the map's default name and description for a property with none of its own, and sets
|
||||
// bIncludeNullAddress / bIncludeNullDescription when the search text is part of that default, so these are found.
|
||||
TEST_F(PropertyListSqlite, SearchFindsUnnamedPropertiesWhenAskedTo) {
|
||||
auto lookup = Lookup(SORT_TYPE_RECENT, 2, "Avant");
|
||||
EXPECT_TRUE(Owners(db->GetProperties(lookup)).empty());
|
||||
|
||||
lookup.includeNullName = true;
|
||||
EXPECT_EQ(Owners(db->GetProperties(lookup)), (std::set<LWOOBJID>{ P_DAVE }));
|
||||
|
||||
lookup.includeNullName = false;
|
||||
lookup.includeNullDescription = true;
|
||||
EXPECT_EQ(Owners(db->GetProperties(lookup)), (std::set<LWOOBJID>{ P_DAVE }));
|
||||
|
||||
// A named property is still only found by its own text
|
||||
lookup.searchString = "Keep";
|
||||
EXPECT_EQ(Owners(db->GetProperties(lookup)), (std::set<LWOOBJID>{ P_CAROL, P_DAVE }));
|
||||
lookup.includeNullDescription = false;
|
||||
EXPECT_EQ(Owners(db->GetProperties(lookup)), (std::set<LWOOBJID>{ P_CAROL }));
|
||||
}
|
||||
|
||||
TEST_F(PropertyListSqlite, FriendsSearchFindsUnnamedPropertiesWhenAskedTo) {
|
||||
auto lookup = Lookup(SORT_TYPE_FRIENDS, 0, "Avant");
|
||||
EXPECT_TRUE(Owners(db->GetProperties(lookup)).empty());
|
||||
lookup.includeNullName = true;
|
||||
EXPECT_EQ(Owners(db->GetProperties(lookup)), (std::set<LWOOBJID>{ P_ALICE_TWO, P_BOB }));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user