-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Property Entrance Component #1246
Conversation
This is very WIP
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
general feedback so far with mostly questions, and a couple small changes (see the unordered_map -> unordered_set and long winded if statements)
friendsList = friendsList + std::to_string(playerIDToConvert) + ","; | ||
while (propertyIdRes->next()) { | ||
if (sortMethod == SORT_TYPE_FRIENDS || sortMethod == SORT_TYPE_FEATURED) { | ||
if (m_UserFriendMap[(uint32_t)requestor->GetObjectID()].find(propertyIdRes->getUInt(2)) == m_UserFriendMap[(uint32_t)requestor->GetObjectID()].end()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This statement is a bit long, we could reduce it to m_UserFriendMap[static_cast<uint32_t>(requestor->GetObjectID())].count(propertyIdRes->getUInt(2)) == 0
so that we dont need to do the same work twice here. I would also recommend replacing the cast to uint32_t from an object id (which clearly means to be a characterId, to getting the characterid from the character as that is the intention of the code at a glance.
nameLookup = nullptr; | ||
PropertyData PropertyEntranceComponent::GetPropertyData(uint32_t propertyID) { | ||
if (m_PropertyDataCache.find(propertyID) != m_PropertyDataCache.end()) { | ||
return m_PropertyDataCache[propertyID]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if a user updates their property name, description or has their player name updated while the data here is cached, when is this updated?
std::unordered_map<LWOOBJID, std::vector<uint32_t>> m_UserRequestedCloneMap; | ||
std::unordered_map<uint32_t, PropertyData> m_PropertyDataCache; | ||
|
||
std::unordered_map<LWOOBJID, std::unordered_map<LWOOBJID, bool>> m_UserFriendMap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an unordered map of bool can be exchanged with unordered set to save memory and readability, however there are concerns above on if this can even be used due to this data not being updated after the initial query. The same applies for the propertyDataCache. Are both of these updated if there is a change in the users friend list or if there is a change in the property status? for example if you removed a friend they could visit your property still if you never update the cache here until the world shutsdown, and someone could make an unapproved property and then fly to it because the property was approved previously. Are these concerns resolved somewhere else that I missed?
|
||
delete isAltQuery; | ||
isAltQuery = nullptr; | ||
personalData.IsFriend = m_UserFriendMap[(uint32_t)queryingUser->GetObjectID()].find(propertyData.PrimaryData.OwnerID) != m_UserFriendMap[(uint32_t)queryingUser->GetObjectID()].end(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the above logic follows, this should attempt to fill the user friend map if the user is not found in it correct? would be a good safeguard for future users unless this is a private method upon which this can be dismissed. Same goes for the other new methods; can these be made private/const if possible?
superceded by #1650 with an orm-like implementation. |
Tested and working on Windows.