mirror of
https://github.com/DarkflameUniverse/DarkflameServer
synced 2024-08-30 18:43:58 +00:00
Added query for friends list next page
This commit is contained in:
parent
e244fbccc2
commit
c838f4f422
@ -322,22 +322,47 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl
|
|||||||
|
|
||||||
propertyQueries[entity->GetObjectID()] = entries;
|
propertyQueries[entity->GetObjectID()] = entries;
|
||||||
|
|
||||||
auto propertiesLeft = Database::CreatePreppedStmt("SELECT COUNT(*) FROM properties WHERE zone_id = ?;");
|
uint32_t numberOfProperties = 0;
|
||||||
|
if (sortMethod != SORT_TYPE_FRIENDS || sortMethod != SORT_TYPE_FEATURED) {
|
||||||
|
auto propertiesLeft = Database::CreatePreppedStmt("SELECT COUNT(*) FROM properties WHERE zone_id = ?;");
|
||||||
|
|
||||||
propertiesLeft->setInt(1, this->m_MapID);
|
propertiesLeft->setInt(1, this->m_MapID);
|
||||||
|
|
||||||
auto result = propertiesLeft->executeQuery();
|
auto result = propertiesLeft->executeQuery();
|
||||||
result->next();
|
result->next();
|
||||||
auto numberOfProperties = result->getInt(1);
|
numberOfProperties = result->getInt(1);
|
||||||
|
|
||||||
delete result;
|
delete result;
|
||||||
result = nullptr;
|
result = nullptr;
|
||||||
|
|
||||||
delete propertiesLeft;
|
delete propertiesLeft;
|
||||||
propertiesLeft = nullptr;
|
propertiesLeft = nullptr;
|
||||||
|
} else {
|
||||||
|
auto forFriends = query;
|
||||||
|
forFriends.replace(7, 3, "COUNT(*)");
|
||||||
|
|
||||||
auto forFriends = query;
|
auto friendsQuery = Database::CreatePreppedStmt(query);
|
||||||
forFriends.replace(7, 3, "COUNT(*)");
|
|
||||||
|
propertyLookup->setUInt(1, this->m_MapID);
|
||||||
|
propertyLookup->setString(2, searchString.c_str());
|
||||||
|
propertyLookup->setString(3, searchString.c_str());
|
||||||
|
propertyLookup->setString(4, searchString.c_str());
|
||||||
|
propertyLookup->setInt(5, entity->GetGMLevel() >= GAME_MASTER_LEVEL_LEAD_MODERATOR || sortMethod == SORT_TYPE_FRIENDS ? 0 : 1);
|
||||||
|
propertyLookup->setInt(6, sortMethod == SORT_TYPE_FEATURED || sortMethod == SORT_TYPE_FRIENDS ? 1 : 2);
|
||||||
|
propertyLookup->setInt(7, numResults);
|
||||||
|
propertyLookup->setInt(8, startIndex);
|
||||||
|
|
||||||
|
auto result = friendsQuery->executeQuery();
|
||||||
|
result->next();
|
||||||
|
numberOfProperties = result->getInt(1);
|
||||||
|
|
||||||
|
delete friendsQuery;
|
||||||
|
friendsQuery = nullptr;
|
||||||
|
|
||||||
|
delete result;
|
||||||
|
result = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
// if sort method is friends or featured do above query.
|
// if sort method is friends or featured do above query.
|
||||||
// do same maths below with resulting query
|
// do same maths below with resulting query
|
||||||
// else use default count.
|
// else use default count.
|
||||||
|
Loading…
Reference in New Issue
Block a user