Skip to content
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

Closed
wants to merge 8 commits into from
Closed

Conversation

Jettford
Copy link
Collaborator

@Jettford Jettford commented Oct 30, 2023

Tested and working on Windows.

@Jettford Jettford marked this pull request as ready for review November 8, 2023 17:34
Copy link
Collaborator

@EmosewaMC EmosewaMC left a 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)

dGame/dGameMessages/PropertyData.h Show resolved Hide resolved
dGame/dGameMessages/GameMessages.cpp Outdated Show resolved Hide resolved
dGame/dComponents/PropertyEntranceComponent.cpp Outdated Show resolved Hide resolved
dGame/dComponents/PropertyEntranceComponent.cpp Outdated Show resolved Hide resolved
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()) {
Copy link
Collaborator

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.

dGame/dComponents/PropertyEntranceComponent.cpp Outdated Show resolved Hide resolved
nameLookup = nullptr;
PropertyData PropertyEntranceComponent::GetPropertyData(uint32_t propertyID) {
if (m_PropertyDataCache.find(propertyID) != m_PropertyDataCache.end()) {
return m_PropertyDataCache[propertyID];
Copy link
Collaborator

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;
Copy link
Collaborator

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();
Copy link
Collaborator

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?

aronwk-aaron
aronwk-aaron previously approved these changes Nov 11, 2023
@aronwk-aaron aronwk-aaron changed the title Property Entrance Component - Rewrite refactor: Property Entrance Component Nov 17, 2023
@EmosewaMC
Copy link
Collaborator

superceded by #1650 with an orm-like implementation.

@EmosewaMC EmosewaMC closed this Nov 18, 2024
@EmosewaMC EmosewaMC deleted the property-entrance-rewrite branch November 18, 2024 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants